From 81459cad43110d394f544d7bb854a467e55784f1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 3 Feb 2015 00:27:30 +0300 Subject: eathena: allow rename shop. --- src/gui/windows/shopwindow.cpp | 51 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'src/gui/windows/shopwindow.cpp') 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(); +} -- cgit v1.2.3-70-g09d2