summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/shopwindow.cpp16
-rw-r--r--src/gui/windows/shopwindow.h7
2 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 307c6ac61..6490ff746 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -88,6 +88,7 @@ ShopWindow::ShopWindow() :
SelectionListener(),
VendingModeListener(),
VendingSlotsListener(),
+ BuyingStoreSlotsListener(),
// TRANSLATORS: shop window button
mCloseButton(new Button(this, _("Close"), "close", this)),
mBuyShopItems(new ShopItems),
@@ -117,6 +118,7 @@ ShopWindow::ShopWindow() :
mRandCounter(0),
mTradeMoney(0),
mSellShopSize(0),
+ mBuyShopSize(0),
isBuySelected(true),
mHaveVending(serverFeatures->haveVending()),
mEnableVending(false)
@@ -412,7 +414,10 @@ void ShopWindow::updateButtonsAndLabels()
{
mPublishButton->setCaption(_("Publish"));
mPublishButton->adjustSize();
- mPublishButton->setEnabled(true);
+ if (mBuyShopSize > 0)
+ mPublishButton->setEnabled(true);
+ else
+ mPublishButton->setEnabled(false);
}
}
else
@@ -428,8 +433,7 @@ void ShopWindow::updateButtonsAndLabels()
else
mPublishButton->setCaption(_("Publish"));
mPublishButton->adjustSize();
- if (!isBuySelected
- && sellNotEmpty
+ if (sellNotEmpty
&& mSellShopSize > 0
&& localPlayer
&& localPlayer->getHaveCart())
@@ -1053,3 +1057,9 @@ void ShopWindow::setShopName(const std::string &name)
serverConfig.setValue("sellShopName", mSellShopName);
updateShopName();
}
+
+void ShopWindow::buyingStoreSlotsChanged(const int slots)
+{
+ mBuyShopSize = slots;
+ updateButtonsAndLabels();
+}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index 0acc814b1..e3398d093 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -26,6 +26,7 @@
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
+#include "listeners/buyingstoreslotslistener.h"
#include "listeners/selectionlistener.h"
#include "listeners/vendingmodelistener.h"
#include "listeners/vendingslotslistener.h"
@@ -48,7 +49,8 @@ class ShopWindow final : public Window,
public ActionListener,
public SelectionListener,
public VendingModeListener,
- public VendingSlotsListener
+ public VendingSlotsListener,
+ public BuyingStoreSlotsListener
{
public:
enum ShopMode
@@ -143,6 +145,8 @@ class ShopWindow final : public Window,
void vendingSlotsChanged(const int slots) override final;
+ void buyingStoreSlotsChanged(const int slots) override final;
+
void vendingEnabled(const bool b) override final;
void setShopName(const std::string &name);
@@ -184,6 +188,7 @@ class ShopWindow final : public Window,
int mRandCounter;
int mTradeMoney;
int mSellShopSize;
+ int mBuyShopSize;
bool isBuySelected;
bool mHaveVending;
bool mEnableVending;