summaryrefslogtreecommitdiff
path: root/src/gui/widgets/virtshortcutcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2020-02-23 09:30:51 +0300
committerAndrei Karas <akaras@inbox.ru>2020-02-23 09:30:51 +0300
commit1e2a88e975019929c4c7e3154537865cc09550a6 (patch)
treeae8bc68ad3a3f6b61a5e2d511d7fc17daa22bd0e /src/gui/widgets/virtshortcutcontainer.cpp
parent6941fd4eeb1dce20aba8c42fd030c2690c37b731 (diff)
downloadmanaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.gz
manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.bz2
manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.xz
manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.zip
Fix some code style issues
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());