summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/shopwindow.cpp51
-rw-r--r--src/gui/windows/shopwindow.h6
2 files changed, 50 insertions, 7 deletions
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 1068aca2b..41bf90958 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -27,6 +27,7 @@
#include "gui/windows/buydialog.h"
#include "gui/windows/chatwindow.h"
#include "gui/windows/confirmdialog.h"
+#include "gui/windows/editdialog.h"
#include "gui/windows/itemamountwindow.h"
#include "gui/windows/shopselldialog.h"
#include "gui/windows/setupwindow.h"
@@ -43,6 +44,8 @@
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/tabstrip.h"
+#include "listeners/shoprenamelistener.h"
+
#include "actormanager.h"
#include "configuration.h"
#include "inventory.h"
@@ -100,10 +103,12 @@ ShopWindow::ShopWindow() :
mDeleteButton(new Button(this, _("Delete"), "delete", this)),
mAnnounceButton(nullptr),
mPublishButton(nullptr),
+ mRenameButton(nullptr),
mAnnounceLinks(nullptr),
mTabs(nullptr),
mAcceptPlayer(),
mTradeNick(),
+ mSellShopName(serverConfig.getStringValue("sellShopName")),
mSelectedItem(-1),
mAnnonceTime(0),
mLastRequestTimeList(0),
@@ -122,7 +127,7 @@ ShopWindow::ShopWindow() :
setResizable(true);
setCloseButton(true);
setStickyButtonLock(true);
- setMinWidth(260);
+ setMinWidth(300);
setMinHeight(220);
if (mainGraphics->mWidth > 600)
setDefaultSize(500, 300, ImageRect::CENTER);
@@ -132,7 +137,6 @@ ShopWindow::ShopWindow() :
if (setupWindow)
setupWindow->registerWindowForReset(this);
-
const int size = config.getIntValue("fontSize")
+ getOption("tabHeightAdjust", 16);
mTabs = new TabStrip(this, "shop", size);
@@ -143,7 +147,6 @@ ShopWindow::ShopWindow() :
// TRANSLATORS: shop window tab name
mTabs->addButton(_("Sell"), "sell", false);
-
loadList();
mBuyShopItemList->setPriceCheck(false);
@@ -159,11 +162,14 @@ ShopWindow::ShopWindow() :
placer(0, 0, mTabs, 8).setPadding(3);
- if (isBuySelected)
+ if (mHaveVending)
{
// TRANSLATORS: shop window button
mPublishButton = new Button(this, _("Publish"), "publish", this);
+ // TRANSLATORS: shop window button
+ mRenameButton = new Button(this, _("Rename"), "rename", this);
placer(2, 6, mPublishButton);
+ placer(3, 6, mRenameButton);
}
else
{
@@ -180,14 +186,14 @@ ShopWindow::ShopWindow() :
placer(0, 1, mScrollArea, 8, 5).setPadding(3);
placer(0, 6, mAddButton);
placer(1, 6, mDeleteButton);
- placer(7, 7, mCloseButton);
+ placer(7, 6, mCloseButton);
Layout &layout = getLayout();
layout.setRowHeight(0, LayoutType::SET);
center();
loadWindowState();
-
+ updateShopName();
instances.push_back(this);
}
@@ -304,9 +310,17 @@ void ShopWindow::action(const ActionEvent &event)
break;
}
if (!items.empty())
- vendingHandler->createShop("test shop", true, items);
+ vendingHandler->createShop(mSellShopName, true, items);
}
}
+ else if (eventId == "rename")
+ {
+ EditDialog *const dialog = new EditDialog(
+ _("Please enter new shop name"), mSellShopName, "OK");
+ dialog->postInit();
+ shopRenameListener.setDialog(dialog);
+ dialog->addActionListener(&shopRenameListener);
+ }
if (mSelectedItem < 1)
return;
@@ -403,6 +417,8 @@ void ShopWindow::updateButtonsAndLabels()
mPublishButton->setEnabled(false);
}
}
+ if (mRenameButton)
+ mRenameButton->setEnabled(!mEnableVending);
}
void ShopWindow::setVisible(bool visible)
@@ -989,3 +1005,24 @@ void ShopWindow::vendingEnabled(const bool b)
mSellShopSize = 0;
updateButtonsAndLabels();
}
+
+void ShopWindow::updateShopName()
+{
+ if (mSellShopName.empty())
+ {
+ // TRANSLATORS: shop window name
+ setCaption(_("Personal Shop"));
+ }
+ else
+ {
+ // TRANSLATORS: shop window name
+ setCaption(strprintf(_("Personal Shop - %s"), mSellShopName.c_str()));
+ }
+}
+
+void ShopWindow::setShopName(const std::string &name)
+{
+ mSellShopName = name;
+ serverConfig.setValue("sellShopName", mSellShopName);
+ updateShopName();
+}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index c746bff17..0acc814b1 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -145,11 +145,15 @@ class ShopWindow final : public Window,
void vendingEnabled(const bool b) override final;
+ void setShopName(const std::string &name);
+
private:
void startTrade();
void updateSelection();
+ void updateShopName();
+
typedef std::list<ShopWindow*> DialogList;
static DialogList instances;
@@ -167,10 +171,12 @@ class ShopWindow final : public Window,
Button *mDeleteButton;
Button *mAnnounceButton;
Button *mPublishButton;
+ Button *mRenameButton;
CheckBox *mAnnounceLinks;
TabStrip *mTabs;
std::string mAcceptPlayer;
std::string mTradeNick;
+ std::string mSellShopName;
int mSelectedItem;
int mAnnonceTime;
int mLastRequestTimeList;