diff options
author | Nikos Giagtzoglou <gnikos21@yahoo.gr> | 2008-11-22 11:43:53 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-11-22 14:40:26 +0100 |
commit | 124aef95eff5b9fe3692d847d288e6470f33f812 (patch) | |
tree | 2e6744763e1cd0cbff0f98f27675d7b34bf70439 /src/gui | |
parent | f7179cdca447c534029bb36a776595bbe3fc999e (diff) | |
download | mana-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/gui')
-rw-r--r-- | src/gui/itemcontainer.cpp | 25 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 6 |
2 files changed, 12 insertions, 19 deletions
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); |