summaryrefslogtreecommitdiff
path: root/src/gui/shortcut
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-02 21:32:53 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-02 21:32:53 +0300
commitf886c62eee04a89c01d30322db1a9eb85f699ac3 (patch)
treed1cf48972f652b66986e14b9034493883c57dc22 /src/gui/shortcut
parent7a56bfad4c7297863c717a7ca8c8cf42c712a220 (diff)
downloadmv-f886c62eee04a89c01d30322db1a9eb85f699ac3.tar.gz
mv-f886c62eee04a89c01d30322db1a9eb85f699ac3.tar.bz2
mv-f886c62eee04a89c01d30322db1a9eb85f699ac3.tar.xz
mv-f886c62eee04a89c01d30322db1a9eb85f699ac3.zip
Add item shortcuts tab with automatically filled with skills.
Diffstat (limited to 'src/gui/shortcut')
-rw-r--r--src/gui/shortcut/itemshortcut.cpp24
-rw-r--r--src/gui/shortcut/itemshortcut.h9
2 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
index 5828ae4e7..d4e96a3e2 100644
--- a/src/gui/shortcut/itemshortcut.cpp
+++ b/src/gui/shortcut/itemshortcut.cpp
@@ -62,8 +62,10 @@ void ItemShortcut::load()
std::string name;
std::string color;
std::string data;
- const Configuration *cfg = &serverConfig;
+ if (mNumber == SHORTCUT_AUTO_TAB)
+ return;
+ const Configuration *cfg = &serverConfig;
if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
@@ -96,6 +98,8 @@ void ItemShortcut::save() const
std::string name;
std::string color;
std::string data;
+ if (mNumber == SHORTCUT_AUTO_TAB)
+ return;
if (mNumber != 0)
{
name = std::string("shortcut").append(toString(mNumber)).append("_");
@@ -131,6 +135,16 @@ void ItemShortcut::save() const
}
}
+void ItemShortcut::clear()
+{
+ for (size_t i = 0; i < SHORTCUT_ITEMS; i++)
+ {
+ mItems[i] = 0;
+ mItemColors[i] = ItemColor_zero;
+ mItemData[i].clear();
+ }
+}
+
void ItemShortcut::useItem(const int index) const
{
const Inventory *const inv = PlayerInfo::getInventory();
@@ -232,6 +246,14 @@ void ItemShortcut::setItem(const int index,
save();
}
+void ItemShortcut::setItemFast(const int index,
+ const int item,
+ const ItemColor color)
+{
+ mItems[index] = item;
+ mItemColors[index] = color;
+}
+
void ItemShortcut::swap(const int index1, const int index2)
{
if (index1 < 0 || index2 < 0
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
index c62fe3721..a2107207d 100644
--- a/src/gui/shortcut/itemshortcut.h
+++ b/src/gui/shortcut/itemshortcut.h
@@ -30,7 +30,8 @@
#include "localconsts.h"
const unsigned int SHORTCUT_ITEMS = 20;
-const unsigned int SHORTCUT_TABS = 4;
+const unsigned int SHORTCUT_TABS = 5;
+const unsigned int SHORTCUT_AUTO_TAB = 4;
class Item;
@@ -103,6 +104,10 @@ class ItemShortcut final
const int item,
const ItemColor color);
+ void setItemFast(const int index,
+ const int item,
+ const ItemColor color);
+
/**
* Adds an item to the items store specified by the index.
*
@@ -161,6 +166,8 @@ class ItemShortcut final
void swap(const int index1, const int index2);
+ void clear();
+
private:
int mItems[SHORTCUT_ITEMS]; /**< The items. */
ItemColor mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */