summaryrefslogtreecommitdiff
path: root/src/gui
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
parent6941fd4eeb1dce20aba8c42fd030c2690c37b731 (diff)
downloadmv-1e2a88e975019929c4c7e3154537865cc09550a6.tar.gz
mv-1e2a88e975019929c4c7e3154537865cc09550a6.tar.bz2
mv-1e2a88e975019929c4c7e3154537865cc09550a6.tar.xz
mv-1e2a88e975019929c4c7e3154537865cc09550a6.zip
Fix some code style issues
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/itempopup.cpp2
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/popups/skillpopup.cpp2
-rw-r--r--src/gui/shortcut/itemshortcut.cpp2
-rw-r--r--src/gui/shortcut/shortcutbase.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp4
-rw-r--r--src/gui/widgets/button.cpp6
-rw-r--r--src/gui/widgets/dropdown.cpp7
-rw-r--r--src/gui/widgets/extendedlistbox.cpp4
-rw-r--r--src/gui/widgets/itemcontainer.cpp10
-rw-r--r--src/gui/widgets/label.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp19
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp1
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp23
-rw-r--r--src/gui/widgets/window.cpp2
-rw-r--r--src/gui/windows/chatwindow.cpp6
-rw-r--r--src/gui/windows/inventorywindow.cpp6
-rw-r--r--src/gui/windows/ministatuswindow.cpp2
-rw-r--r--src/gui/windows/shopwindow.cpp2
-rw-r--r--src/gui/windows/shortcutwindow.cpp2
21 files changed, 59 insertions, 53 deletions
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 0e9dd031f..3cb80b7ac 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -294,7 +294,6 @@ void ItemPopup::setItem(const ItemInfo &item,
minWidth = mItemOptions->getMinWidth();
const int numRowsDesc = mItemDesc->getNumberOfRows();
- const int numRowsEffect = mItemEffect->getNumberOfRows();
const int numRowsWeight = mItemWeight->getNumberOfRows();
const int numRowsCards = mItemCards->getNumberOfRows();
const int numRowsOptions = mItemOptions->getNumberOfRows();
@@ -312,6 +311,7 @@ void ItemPopup::setItem(const ItemInfo &item,
}
else
{
+ const int numRowsEffect = mItemEffect->getNumberOfRows();
setContentSize(minWidth, (numRowsDesc + numRowsEffect + 2
+ numRowsWeight + numRowsCards + numRowsOptions) * height);
mItemEffect->setPosition(0, (numRowsDesc + 2) * height);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index dcba43e1f..6ecbd6a9f 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1393,10 +1393,10 @@ void PopupMenu::handleLink(const std::string &link,
{
if (localPlayer != nullptr)
{
- const int num = atoi(link.substr(10).c_str());
const Guild *const guild = localPlayer->getGuild();
if (guild != nullptr)
{
+ const int num = atoi(link.substr(10).c_str());
guildHandler->changeMemberPostion(
guild->getMember(mName), num);
}
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp
index f7d86d85c..8d5950b11 100644
--- a/src/gui/popups/skillpopup.cpp
+++ b/src/gui/popups/skillpopup.cpp
@@ -209,7 +209,6 @@ void SkillPopup::show(const SkillInfo *const skill,
minWidth = mSkillCastType->getMinWidth();
const int numRowsDesc = mSkillDesc->getNumberOfRows();
- const int numRowsEffect = mSkillEffect->getNumberOfRows();
const int numRowsLevel = mSkillLevel->getNumberOfRows();
const int numRowsCast = mSkillCastType->getNumberOfRows();
const int height = getFont()->getHeight();
@@ -223,6 +222,7 @@ void SkillPopup::show(const SkillInfo *const skill,
}
else
{
+ const int numRowsEffect = mSkillEffect->getNumberOfRows();
setContentSize(minWidth,
(numRowsDesc + numRowsLevel + numRowsEffect + numRowsCast + 1) *
height);
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
index 51c1532bb..60d6ef72d 100644
--- a/src/gui/shortcut/itemshortcut.cpp
+++ b/src/gui/shortcut/itemshortcut.cpp
@@ -120,9 +120,9 @@ void ItemShortcut::save() const
for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
{
const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = toInt(mItemColors[i], int);
if (itemId != -1)
{
+ const int itemColor = toInt(mItemColors[i], int);
const std::string itemData = mItemData[i];
serverConfig.setValue(name + toString(i), itemId);
serverConfig.setValue(color + toString(i), itemColor);
diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp
index e6e1a5923..3fe0250fa 100644
--- a/src/gui/shortcut/shortcutbase.cpp
+++ b/src/gui/shortcut/shortcutbase.cpp
@@ -76,11 +76,11 @@ void ShortcutBase::save() const
for (size_t i = 0; i < mMaxSize; i++)
{
const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = (mItemColors[i] != ItemColor_zero)
- ? toInt(mItemColors[i], int) : 1;
const std::string num = toString(CAST_S32(i));
if (itemId != -1)
{
+ const int itemColor = (mItemColors[i] != ItemColor_zero)
+ ? toInt(mItemColors[i], int) : 1;
serverConfig.setValue(mItemName + num, itemId);
serverConfig.setValue(mColorName + num, itemColor);
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index cfacab828..cac97c092 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -174,9 +174,9 @@ void AvatarListBox::draw(Graphics *const graphics)
text = strprintf("%s %d/%d", a->getComplexName().c_str(),
a->getHp(), a->getMaxHp());
}
- const bool isPoison = a->getPoison();
if (a->getMaxHp() != 0)
{
+ const bool isPoison = a->getPoison();
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
: ProgressColorId::PROG_HP);
@@ -412,9 +412,9 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
text = strprintf("%s %d/%d", a->getComplexName().c_str(),
a->getHp(), a->getMaxHp());
}
- const bool isPoison = a->getPoison();
if (a->getMaxHp() != 0)
{
+ const bool isPoison = a->getPoison();
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
: ProgressColorId::PROG_HP);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 1f51d8ba9..44e41be5a 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -805,12 +805,16 @@ void Button::adjustSize()
if (mImages != nullptr)
{
- const int spacing = mSpacing[BUTTON_STANDARD];
const int width = font->getWidth(mCaption);
if (width != 0)
+ {
+ const int spacing = mSpacing[BUTTON_STANDARD];
setWidth(width + mImageWidth + spacing + 2 * padding);
+ }
else
+ {
setWidth(mImageWidth + 2 * padding);
+ }
int height = font->getHeight();
if (height < mImageHeight)
height = mImageHeight;
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 1d09d5c97..f4fb56f9e 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -226,7 +226,6 @@ void DropDown::draw(Graphics *const graphics)
updateAlpha();
const unsigned int alpha = CAST_U32(mAlpha * 255.0F);
- const int pad = 2 * mPadding;
mHighlightColor.a = alpha;
mShadowColor.a = alpha;
@@ -272,6 +271,7 @@ void DropDown::draw(Graphics *const graphics)
if (isFocused())
{
+ const int pad = 2 * mPadding;
graphics->setColor(mHighlightColor);
graphics->drawRectangle(Rect(mPadding, mPadding,
mDimension.width - h - pad, h - pad));
@@ -321,11 +321,10 @@ void DropDown::safeDrawFrame(Graphics *const graphics)
void DropDown::drawButton(Graphics *const graphics)
{
- const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
-
- Image *image = buttons[mDroppedDown][mPushed];
+ Image *const image = buttons[mDroppedDown][mPushed];
if (image != nullptr)
{
+ const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
graphics->drawImage(image,
mDimension.width - image->getWidth() - mImagePadding,
(height - image->getHeight()) / 2);
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 036c42ac3..b19e18fc8 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -141,9 +141,9 @@ void ExtendedListBox::draw(Graphics *const graphics)
for (size_t f = 0; f < itemsSz; ++f)
{
const ExtendedListBoxItem &item = mListItems[f];
- const int row1 = item.row;
if (item.image)
{
+ const int row1 = item.row;
const Image *const image = model->getImageAt(row1);
if (image != nullptr)
{
@@ -201,9 +201,9 @@ void ExtendedListBox::draw(Graphics *const graphics)
for (size_t f = 0; f < selSz; ++f)
{
const ExtendedListBoxItem &item = mSelectedItems[f];
- const int row1 = item.row;
if (item.image)
{
+ const int row1 = item.row;
const Image *const image = model->getImageAt(row1);
if (image != nullptr)
{
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 9c566c9c7..e60e70332 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -365,8 +365,6 @@ void ItemContainer::draw(Graphics *const graphics)
int itemIndex = j * mGridColumns - 1;
for (int i = 0; i < mGridColumns; i++)
{
- int itemX = i * mBoxWidth;
- int itemY = intY0;
itemIndex ++;
if (mShowMatrix[itemIndex] < 0)
continue;
@@ -380,6 +378,8 @@ void ItemContainer::draw(Graphics *const graphics)
Image *const image = item->getImage();
if (image != nullptr)
{
+ int itemX = i * mBoxWidth;
+ int itemY = intY0;
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
if (mSelImg != nullptr)
@@ -487,8 +487,6 @@ void ItemContainer::safeDraw(Graphics *const graphics)
int itemIndex = j * mGridColumns - 1;
for (int i = 0; i < mGridColumns; i++)
{
- int itemX = i * mBoxWidth;
- int itemY = intY0;
itemIndex ++;
if (mShowMatrix[itemIndex] < 0)
continue;
@@ -502,6 +500,8 @@ void ItemContainer::safeDraw(Graphics *const graphics)
Image *const image = item->getImage();
if (image != nullptr)
{
+ int itemX = i * mBoxWidth;
+ int itemY = intY0;
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
if (mSelImg != nullptr)
@@ -1148,9 +1148,9 @@ void ItemContainer::adjustHeight()
mGridRows = maxRows;
}
- const int num = updateMatrix();
if (mShowEmptyRows == ShowEmptyRows_false)
{
+ const int num = updateMatrix();
mDrawRows = num / mGridColumns;
if (mDrawRows == 0 || num % mGridColumns > 0)
++mDrawRows;
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 193c28ec6..9dfa7ce4d 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -152,7 +152,6 @@ void Label::draw(Graphics *const graphics)
BLOCK_START("Label::draw")
int textX;
const Rect &rect = mDimension;
- const int textY = rect.height / 2 - getFont()->getHeight() / 2;
Font *const font = getFont();
switch (mAlignment)
@@ -185,7 +184,10 @@ void Label::draw(Graphics *const graphics)
const Image *const image = mTextChunk.img;
if (image != nullptr)
+ {
+ const int textY = rect.height / 2 - font->getHeight() / 2;
graphics->drawImage(image, textX, textY);
+ }
BLOCK_END("Label::draw")
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 27e21593d..172461e64 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -457,14 +457,13 @@ void ScrollArea::drawFrame(Graphics *const graphics)
BLOCK_START("ScrollArea::drawFrame")
if (mOpaque == Opaque_true)
{
- const int bs = mFrameSize * 2;
- const int w = mDimension.width + bs;
- const int h = mDimension.height + bs;
-
updateCalcFlag(graphics);
if (mRedraw)
{
+ const int bs = mFrameSize * 2;
+ const int w = mDimension.width + bs;
+ const int h = mDimension.height + bs;
mVertexes2->clear();
graphics->calcWindow(mVertexes2,
0, 0,
@@ -759,10 +758,10 @@ void ScrollArea::mouseExited(MouseEvent& event A_UNUSED)
void ScrollArea::widgetResized(const Event &event A_UNUSED)
{
mRedraw = true;
- const unsigned int frameSize = 2 * mFrameSize;
Widget *const content = getContent();
if (content != nullptr)
{
+ const unsigned int frameSize = 2 * mFrameSize;
content->setSize(mDimension.width - frameSize,
mDimension.height - frameSize);
}
@@ -935,13 +934,12 @@ void ScrollArea::mouseDragged(MouseEvent &event)
if (mIsVerticalMarkerDragged)
{
const Rect barDim = getVerticalBarDimension();
-
- const int pos = event.getY() - barDim.y
- - mVerticalMarkerDragOffset;
const int length = getVerticalMarkerDimension().height;
if ((barDim.height - length) > 0)
{
+ const int pos = event.getY() - barDim.y
+ - mVerticalMarkerDragOffset;
setVerticalScrollAmount((getVerticalMaxScroll() * pos)
/ (barDim.height - length));
}
@@ -954,13 +952,12 @@ void ScrollArea::mouseDragged(MouseEvent &event)
if (mIsHorizontalMarkerDragged)
{
const Rect barDim = getHorizontalBarDimension();
-
- const int pos = event.getX() - barDim.x
- - mHorizontalMarkerDragOffset;
const int length = getHorizontalMarkerDimension().width;
if ((barDim.width - length) > 0)
{
+ const int pos = event.getX() - barDim.x
+ - mHorizontalMarkerDragOffset;
setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
/ (barDim.width - length));
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 32da8e700..3900be438 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -478,7 +478,6 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize();
const int w1 = mDimension.width;
const int h1 = mDimension.height;
- const int width = w1 - frameSize - widgetFrameSize;
const int height = h1 - frameSize
- mWidgetContainer->getY() - widgetFrameSize;
@@ -529,6 +528,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
if (mArrowButton[1] != nullptr)
{
+ const int width = w1 - frameSize - widgetFrameSize;
// Move the right arrow to fit the windows content.
newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
if (newWidth < 0)
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index acd6ffcef..63b2b132d 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -242,7 +242,6 @@ Setup_Theme::~Setup_Theme()
delete2(mFontSizeListModel)
delete2(mNpcFontSizeListModel)
delete2(mLangListModel)
- delete2(mInfo)
}
void Setup_Theme::updateInfo()
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());
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index deebfd5ef..2d51a49c0 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -1011,7 +1011,6 @@ void Window::mouseDragged(MouseEvent &event)
if ((mouseResize != 0) && !mMoved)
{
- const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
Rect newDim = getDimension();
@@ -1028,6 +1027,7 @@ void Window::mouseDragged(MouseEvent &event)
if ((mouseResize & (LEFT | RIGHT)) != 0)
{
+ const int dx = event.getX() - mDragOffsetX;
const int newWidth = newDim.width
+ ((mouseResize & LEFT) != 0 ? -dx : dx);
newDim.width = std::min(mMaxWinWidth,
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index f96cf976d..ad7fc1573 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1883,12 +1883,12 @@ void ChatWindow::loadState()
if (nick.empty())
break;
- const int flags = serverConfig.getValue(
- "chatWhisperFlags" + toString(num), 1);
-
ChatTab *const tab = addChatTab(nick, false, false);
if (tab != nullptr)
{
+ const int flags = serverConfig.getValue(
+ "chatWhisperFlags" + toString(num), 1);
+
tab->setAllowHighlight((flags & 1) != 0);
tab->setRemoveNames(((flags & 2) / 2) != 0);
tab->setNoAway(((flags & 4) / 4) != 0);
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 8722e35e3..28d83b10f 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -643,11 +643,11 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
/* Convert relative to the window coordinates to absolute screen
* coordinates.
*/
- const int mx = event.getX() + getX();
- const int my = event.getY() + getY();
-
if (popupMenu != nullptr)
{
+ const int mx = event.getX() + getX();
+ const int my = event.getY() + getY();
+
popupMenu->showPopup(this,
mx, my,
item,
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 2a1b3e16c..42e7d8804 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -432,7 +432,6 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
Attributes::PLAYER_JOB_LEVEL);
const std::string expStr = toString(CAST_U64(exp));
const std::string expNeedStr = toString(CAST_U64(expNeed));
- const std::string expLeftStr = toString(CAST_U64(expNeed - exp));
// TRANSLATORS: job bar label
const std::string level = strprintf(_("Job level: %d"),
@@ -447,6 +446,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
}
else
{
+ const std::string expLeftStr = toString(CAST_U64(expNeed - exp));
textPopup->show(x + rect.x,
y + rect.y,
level,
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index eb28639f8..6bd298e2b 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -439,7 +439,6 @@ void ShopWindow::updateButtonsAndLabels()
{
bool allowDel(false);
bool allowAdd(false);
- const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0;
if (isBuySelected)
{
allowAdd = !mEnableBuyingStore;
@@ -467,6 +466,7 @@ void ShopWindow::updateButtonsAndLabels()
}
else
{
+ const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0;
allowAdd = !mEnableVending && mSelectedItem != -1;
allowDel = !mEnableVending
&& mSellShopItemList->getSelected() != -1
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index e45ca266c..faa8e6fa5 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -78,9 +78,9 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
setMinWidth(32);
setMinHeight(32);
- const int border = SCROLL_PADDING * 2 + getPadding() * 2;
if (mItems != nullptr)
{
+ const int border = SCROLL_PADDING * 2 + getPadding() * 2;
const int bw = mItems->getBoxWidth();
const int bh = mItems->getBoxHeight();
const int maxItems = mItems->getMaxItems();