summaryrefslogtreecommitdiff
path: root/src/gui/widgets/virtshortcutcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:07:58 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:07:58 +0300
commit9569e469a481076bdbc330377bf8445eb32fbaa6 (patch)
tree5afe0076206954d5f1649aedc5bcd9529757be14 /src/gui/widgets/virtshortcutcontainer.cpp
parent0bcc82648c49db05980e879a13baba2c76264bd4 (diff)
downloadmanaverse-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.gz
manaverse-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.bz2
manaverse-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.xz
manaverse-9569e469a481076bdbc330377bf8445eb32fbaa6.zip
Add safeDraw method into shortcutcontainer childs.
Diffstat (limited to 'src/gui/widgets/virtshortcutcontainer.cpp')
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index c4a85a0ed..138d3f5a6 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -144,6 +144,80 @@ void VirtShortcutContainer::draw(Graphics *graphics)
BLOCK_END("VirtShortcutContainer::draw")
}
+void VirtShortcutContainer::safeDraw(Graphics *graphics)
+{
+ if (!mShortcut)
+ return;
+
+ BLOCK_START("VirtShortcutContainer::safeDraw")
+ if (settings.guiAlpha != mAlpha)
+ {
+ mAlpha = settings.guiAlpha;
+ if (mBackgroundImg)
+ mBackgroundImg->setAlpha(mAlpha);
+ }
+
+ safeDrawBackground(graphics);
+
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (!inv)
+ {
+ BLOCK_END("VirtShortcutContainer::safeDraw")
+ return;
+ }
+
+ Font *const font = getFont();
+
+ for (unsigned i = 0; i < mMaxItems; i++)
+ {
+ const int itemX = (i % mGridWidth) * mBoxWidth;
+ const int itemY = (i / mGridWidth) * mBoxHeight;
+
+ if (mShortcut->getItem(i) < 0)
+ continue;
+
+ const Item *const item = inv->findItem(mShortcut->getItem(i),
+ mShortcut->getItemColor(i));
+
+ if (item)
+ {
+ // Draw item icon.
+ Image *const image = item->getImage();
+
+ if (image)
+ {
+ std::string caption;
+ if (item->getQuantity() > 1)
+ caption = toString(item->getQuantity());
+ else if (item->isEquipped() == Equipped_true)
+ caption = "Eq.";
+
+ image->setAlpha(1.0F);
+ graphics->drawImage(image, itemX, itemY);
+ if (item->isEquipped() == Equipped_true)
+ {
+ font->drawString(graphics,
+ mEquipedColor,
+ mEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
+ }
+ else
+ {
+ font->drawString(graphics,
+ mUnEquipedColor,
+ mUnEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
+ }
+ }
+ }
+ }
+ BLOCK_END("VirtShortcutContainer::safeDraw")
+}
+
void VirtShortcutContainer::mouseDragged(MouseEvent &event)
{
if (!mShortcut)