From 1a34e0c62d1d033d79b28c4a9bfd85a2ccd093ad Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 2 Feb 2015 21:48:15 +0300 Subject: Fix buttons in shop window based on state. --- src/gui/windows/shopwindow.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/gui/windows/shopwindow.cpp') diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index a845d3404..1068aca2b 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -365,18 +365,23 @@ void ShopWindow::valueChanged(const SelectionEvent &event A_UNUSED) void ShopWindow::updateButtonsAndLabels() { - mAddButton->setEnabled(mSelectedItem != -1); bool allowDel(false); + bool allowAdd(false); const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0; if (isBuySelected) { + allowAdd = !mEnableVending; allowDel = mBuyShopItemList->getSelected() != -1 && mBuyShopItems->getNumberOfElements() > 0; } else { - allowDel = mSellShopItemList->getSelected() != -1 && sellNotEmpty; + allowAdd = !mEnableVending && mSelectedItem != -1; + allowDel = !mEnableVending + && mSellShopItemList->getSelected() != -1 + && sellNotEmpty; } + mAddButton->setEnabled(allowAdd); mDeleteButton->setEnabled(allowDel); if (mPublishButton) { @@ -973,11 +978,14 @@ void ShopWindow::updateSelection() void ShopWindow::vendingSlotsChanged(const int slots) { mSellShopSize = slots; + updateButtonsAndLabels(); } void ShopWindow::vendingEnabled(const bool b) { mEnableVending = b; - updateButtonsAndLabels(); localPlayer->enableShop(b); + if (!b) + mSellShopSize = 0; + updateButtonsAndLabels(); } -- cgit v1.2.3-70-g09d2