diff options
Diffstat (limited to 'src/gui/widgets/itemshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 4d9e6dd2d..0585f59cd 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -113,14 +113,24 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) graphics->setFont(getFont()); + if (mBackgroundImg) + { + for (unsigned i = 0; i < mMaxItems; i++) + { + g->drawImage(mBackgroundImg, (i % mGridWidth) * mBoxWidth, + (i / mGridWidth) * mBoxHeight); + } + } + + Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return; + for (unsigned i = 0; i < mMaxItems; i++) { const int itemX = (i % mGridWidth) * mBoxWidth; const int itemY = (i / mGridWidth) * mBoxHeight; - if (mBackgroundImg) - g->drawImage(mBackgroundImg, itemX, itemY); - // Draw item keyboard shortcut. std::string key = inputManager.getKeyValueString( Input::KEY_SHORTCUT_1 + i); @@ -137,11 +147,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // this is item if (itemId < SPELL_MIN_ID) { - if (!PlayerInfo::getInventory()) - continue; - - Item *item = PlayerInfo::getInventory()->findItem( - itemId, itemColor); + Item *item = inv->findItem(itemId, itemColor); if (item) { |