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.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index a6553b132..229bdf2de 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -100,17 +100,18 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
for (unsigned i = 0; i < mMaxItems; i++)
{
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- if (mShortcut->getItem(i) < 0)
+ const int itemId = mShortcut->getItem(i);
+ if (itemId < 0)
continue;
- const Item *const item = inv->findItem(mShortcut->getItem(i),
+ const Item *const item = inv->findItem(itemId,
mShortcut->getItemColor(i));
if (item != nullptr)
{
+ const int itemX = (i % mGridWidth) * mBoxWidth;
+ const int itemY = (i / mGridWidth) * mBoxHeight;
+
// Draw item icon.
Image *const image = item->getImage();
@@ -176,13 +177,14 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
for (unsigned i = 0; i < mMaxItems; i++)
{
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
+ const int itemId = mShortcut->getItem(i);
+ if (itemId < 0)
+ continue;
- if (mShortcut->getItem(i) < 0)
+ if (itemId < 0)
continue;
- const Item *const item = inv->findItem(mShortcut->getItem(i),
+ const Item *const item = inv->findItem(itemId,
mShortcut->getItemColor(i));
if (item != nullptr)
@@ -192,6 +194,9 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
if (image != nullptr)
{
+ const int itemX = (i % mGridWidth) * mBoxWidth;
+ const int itemY = (i / mGridWidth) * mBoxHeight;
+
std::string caption;
if (item->getQuantity() > 1)
caption = toString(item->getQuantity());