summaryrefslogtreecommitdiff
path: root/src/itemshortcut.cpp
diff options
context:
space:
mode:
authorNikos Giagtzoglou <gnikos21@yahoo.gr>2008-11-22 11:43:53 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-22 14:40:26 +0100
commit124aef95eff5b9fe3692d847d288e6470f33f812 (patch)
tree2e6744763e1cd0cbff0f98f27675d7b34bf70439 /src/itemshortcut.cpp
parentf7179cdca447c534029bb36a776595bbe3fc999e (diff)
downloadmana-client-124aef95eff5b9fe3692d847d288e6470f33f812.tar.gz
mana-client-124aef95eff5b9fe3692d847d288e6470f33f812.tar.bz2
mana-client-124aef95eff5b9fe3692d847d288e6470f33f812.tar.xz
mana-client-124aef95eff5b9fe3692d847d288e6470f33f812.zip
Added ability to add equipment to the shurtcut bar
Patch by Nikos, with some improvements.
Diffstat (limited to 'src/itemshortcut.cpp')
-rw-r--r--src/itemshortcut.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 5a92e216..babe3dfb 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -62,14 +62,8 @@ void ItemShortcut::save()
{
for (int i = 0; i < SHORTCUT_ITEMS; i++)
{
- if (mItems[i])
- {
- config.setValue("shortcut" + toString(i), mItems[i]);
- }
- else
- {
- config.setValue("shortcut" + toString(i), -1);
- }
+ const int itemId = mItems[i] ? mItems[i] : -1;
+ config.setValue("shortcut" + toString(i), itemId);
}
}
@@ -79,6 +73,16 @@ void ItemShortcut::useItem(int index)
{
Item *item = player_node->getInventory()->findItem(mItems[index]);
if (item && item->getQuantity())
- player_node->useItem(item);
+ {
+ if (item->isEquipment()) {
+ if (item->isEquipped()) {
+ player_node->unequipItem(item);
+ } else {
+ player_node->equipItem(item);
+ }
+ } else {
+ player_node->useItem(item);
+ }
+ }
}
}