summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-14 03:01:07 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-14 03:01:07 +0300
commitf3781554bf946a22ac307d1c8fe6154db05bbf2e (patch)
tree30bae5fdc65a5a1cf6eecb552f6380712fcf900f /src
parent12398ad6f56888be71e4575d90442b2172f9876d (diff)
downloadmanaverse-f3781554bf946a22ac307d1c8fe6154db05bbf2e.tar.gz
manaverse-f3781554bf946a22ac307d1c8fe6154db05bbf2e.tar.bz2
manaverse-f3781554bf946a22ac307d1c8fe6154db05bbf2e.tar.xz
manaverse-f3781554bf946a22ac307d1c8fe6154db05bbf2e.zip
Add ability to load/save additional data for each shortcut in shortcuts window.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp4
-rw-r--r--src/gui/shortcut/itemshortcut.cpp20
-rw-r--r--src/gui/shortcut/itemshortcut.h3
-rw-r--r--src/gui/windows/skilldialog.cpp13
-rw-r--r--src/gui/windows/skilldialog.h3
5 files changed, 37 insertions, 6 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index f41640f6c..94dd1765e 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1550,9 +1550,11 @@ impHandler(useItem)
}
else if (skillDialog)
{
+ // +++ probably need get data parameter from args
skillDialog->useItem(itemId,
fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- 0);
+ 0,
+ std::string());
}
return true;
}
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
index 664f7e859..e52c72129 100644
--- a/src/gui/shortcut/itemshortcut.cpp
+++ b/src/gui/shortcut/itemshortcut.cpp
@@ -42,6 +42,9 @@
ItemShortcut *itemShortcut[SHORTCUT_TABS];
ItemShortcut::ItemShortcut(const int number) :
+ mItems(),
+ mItemColors(),
+ mItemData(),
mItemSelected(-1),
mItemColorSelected(ItemColor_one),
mNumber(number)
@@ -58,6 +61,7 @@ void ItemShortcut::load(const bool oldConfig)
{
std::string name;
std::string color;
+ std::string data;
const Configuration *cfg;
if (oldConfig)
cfg = &config;
@@ -69,11 +73,13 @@ void ItemShortcut::load(const bool oldConfig)
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
toString(mNumber)).append("_");
+ data = std::string("shortcutData").append(toString(mNumber)).append("_");
}
else
{
name = "shortcut";
color = "shortcutColor";
+ data = "shortcutData";
}
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
@@ -84,6 +90,7 @@ void ItemShortcut::load(const bool oldConfig)
mItems[i] = itemId;
mItemColors[i] = itemColor;
+ mItemData[i] = cfg->getValue(data + toString(i), std::string());
}
}
@@ -91,31 +98,37 @@ void ItemShortcut::save() const
{
std::string name;
std::string color;
+ std::string data;
if (mNumber)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
color = std::string("shortcutColor").append(
toString(mNumber)).append("_");
+ data = std::string("shortcutData").append(toString(mNumber)).append("_");
}
else
{
name = "shortcut";
color = "shortcutColor";
+ data = "shortcutData";
}
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
const int itemId = mItems[i] ? mItems[i] : -1;
const int itemColor = toInt(mItemColors[i], int);
+ const std::string itemData = mItemData[i];
if (itemId != -1)
{
serverConfig.setValue(name + toString(i), itemId);
serverConfig.setValue(color + toString(i), itemColor);
+ serverConfig.setValue(data + toString(i), itemData);
}
else
{
serverConfig.deleteKey(name + toString(i));
serverConfig.deleteKey(color + toString(i));
+ serverConfig.deleteKey(data + toString(i));
}
}
}
@@ -144,7 +157,8 @@ void ItemShortcut::useItem(const int index) const
{
skillDialog->useItem(itemId,
fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- toInt(itemColor, int));
+ toInt(itemColor, int),
+ mItemData[index]);
}
}
}
@@ -235,5 +249,9 @@ void ItemShortcut::swap(const int index1, const int index2)
const ItemColor tmpColor = mItemColors[index1];
mItemColors[index1] = mItemColors[index2];
mItemColors[index2] = tmpColor;
+
+ const std::string tmpData = mItemData[index1];
+ mItemData[index1] = mItemData[index2];
+ mItemData[index2] = tmpData;
save();
}
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
index c28a094b3..d3418eadd 100644
--- a/src/gui/shortcut/itemshortcut.h
+++ b/src/gui/shortcut/itemshortcut.h
@@ -25,6 +25,8 @@
#include "enums/simpletypes/itemcolor.h"
+#include <string>
+
#include "localconsts.h"
const unsigned int SHORTCUT_ITEMS = 20;
@@ -155,6 +157,7 @@ class ItemShortcut final
private:
int mItems[SHORTCUT_ITEMS]; /**< The items. */
ItemColor mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
+ std::string mItemData[SHORTCUT_ITEMS];
int mItemSelected;
ItemColor mItemColorSelected;
int mNumber;
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index eed99542c..66ffb6378 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -615,7 +615,8 @@ void SkillDialog::widgetResized(const Event &event)
void SkillDialog::useItem(const int itemId,
const AutoTarget autoTarget,
- const int level) const
+ const int level,
+ const std::string &data) const
{
const std::map<int, SkillInfo*>::const_iterator
it = mSkills.find(itemId - SKILL_MIN_ID);
@@ -623,8 +624,14 @@ void SkillDialog::useItem(const int itemId,
return;
const SkillInfo *const info = (*it).second;
- // +++ need add skill level here
- useSkill(info, autoTarget, level);
+ if (data.empty())
+ {
+ useSkill(info, autoTarget, level);
+ }
+ else if (data.size() > 1)
+ {
+
+ }
}
void SkillDialog::updateTabSelection()
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 5e53c7362..f12f9621b 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -117,7 +117,8 @@ class SkillDialog final : public Window,
void useItem(const int itemId,
const AutoTarget autoTarget,
- const int level) const;
+ const int level,
+ const std::string &data) const;
void updateTabSelection();