summaryrefslogtreecommitdiff
path: root/src/gui/widgets/virtshortcutcontainer.cpp
diff options
context:
space:
mode:
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)