diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-04 21:37:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-04 21:37:27 +0300 |
commit | 41115f28f500f3acde44c9118b157f81d8ad6078 (patch) | |
tree | 8086692f252e411b11c279d0f0567dcc1fad4383 /src/gui | |
parent | 836459705f715f882b287b06b0e3c02af7dfbf8d (diff) | |
download | manaplus-41115f28f500f3acde44c9118b157f81d8ad6078.tar.gz manaplus-41115f28f500f3acde44c9118b157f81d8ad6078.tar.bz2 manaplus-41115f28f500f3acde44c9118b157f81d8ad6078.tar.xz manaplus-41115f28f500f3acde44c9118b157f81d8ad6078.zip |
Improve itemshortcutcontainer.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 3cfe52393..416f2092c 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -136,16 +136,16 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) return; } + // +++ for future usage need reorder drawing images before text or back for (unsigned i = 0; i < mMaxItems; i++) { const int itemX = (i % mGridWidth) * mBoxWidth; const int itemY = (i / mGridWidth) * mBoxHeight; // Draw item keyboard shortcut. - std::string key = inputManager.getKeyValueString( + const std::string key = inputManager.getKeyValueString( Input::KEY_SHORTCUT_1 + i); g->setColorAll(mForegroundColor, mForegroundColor); - font->drawString(g, key, itemX + 2, itemY + 2); const int itemId = selShortcut->getItem(i); @@ -158,12 +158,10 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) if (itemId < SPELL_MIN_ID) { const Item *const item = inv->findItem(itemId, itemColor); - if (item) { // Draw item icon. Image *const image = item->getImage(); - if (image) { std::string caption; @@ -255,7 +253,6 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (!mItemMoved && mItemClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); - if (index == -1) return; @@ -371,7 +368,6 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) } } -// Show ItemTooltip void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) { const ItemShortcut *const selShortcut = itemShortcut[mNumber]; @@ -393,12 +389,11 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) { mSpellPopup->setVisible(false); - if (!PlayerInfo::getInventory()) + Inventory *const inv = PlayerInfo::getInventory(); + if (!inv) return; - const Item *const item = PlayerInfo::getInventory()->findItem( - itemId, itemColor); - + const Item *const item = inv->findItem(itemId, itemColor); if (item && viewport) { mItemPopup->setItem(item); |