diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 25 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 6 | ||||
-rw-r--r-- | src/itemshortcut.cpp | 22 |
4 files changed, 26 insertions, 28 deletions
@@ -4,6 +4,7 @@ - Added --data parameter for developers - Added particle effect for critical hits - Added support for dynamic skill names and hair colors +- Added ability to add equipment to the shurtcut bar - Inventory window now displays amount of slots used - Center minimap on player when it is larger than the minimap window - Extended particle emitters with properties that can change over time diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 68978db2..5342e3fe 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -59,8 +59,7 @@ ItemContainer::~ItemContainer() mSelImg->decRef(); } -void -ItemContainer::logic() +void ItemContainer::logic() { gcn::Widget::logic(); @@ -73,8 +72,7 @@ ItemContainer::logic() } } -void -ItemContainer::draw(gcn::Graphics *graphics) +void ItemContainer::draw(gcn::Graphics *graphics) { int columns = getWidth() / gridWidth; @@ -147,20 +145,17 @@ void ItemContainer::recalculateHeight() setHeight(height); } -Item* -ItemContainer::getSelectedItem() const +Item *ItemContainer::getSelectedItem() const { return mSelectedItem; } -void -ItemContainer::selectNone() +void ItemContainer::selectNone() { setSelectedItem(NULL); } -void -ItemContainer::setSelectedItem(Item *item) +void ItemContainer::setSelectedItem(Item *item) { if (mSelectedItem != item) { @@ -169,8 +164,7 @@ ItemContainer::setSelectedItem(Item *item) } } -void -ItemContainer::distributeValueChangedEvent() +void ItemContainer::distributeValueChangedEvent() { gcn::SelectionEvent event(this); std::list<gcn::SelectionListener*>::iterator i_end = mListeners.end(); @@ -182,8 +176,7 @@ ItemContainer::distributeValueChangedEvent() } } -void -ItemContainer::mousePressed(gcn::MouseEvent &event) +void ItemContainer::mousePressed(gcn::MouseEvent &event) { int button = event.getButton(); @@ -203,9 +196,7 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) } Item *item = mInventory->getItem(index); setSelectedItem(item); - if (item && !item->isEquipment()) - { + if (item) itemShortcut->setItemSelected(item->getId()); - } } } diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 687f8d16..2ea5d584 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -86,7 +86,7 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0+i)); + (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0 + i)); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); if (itemShortcut->getItem(i) < 0) @@ -98,9 +98,11 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item icon. Image* image = item->getImage(); if (image) { + const std::string label = + item->isEquipped() ? "Eq." : toString(item->getQuantity()); g->drawImage(image, itemX, itemY); g->drawText( - toString(item->getQuantity()), + label, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); 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); + } + } } } |