From 2f91a45e4c0c59a962059890ed5ab708a059788f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Dec 2014 15:33:41 +0300 Subject: Add enum for buy dialog types. --- src/gui/windows/buydialog.cpp | 14 +++++++------- src/gui/windows/buydialog.h | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index ac3c9e588..33e3932bc 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -170,7 +170,7 @@ BuyDialog::BuyDialog() : SelectionListener(), mSortModel(nullptr), mSortDropDown(nullptr), - mNpcId(-2), + mNpcId(Items), mMoney(0), mAmountItems(0), mMaxItems(0), @@ -202,7 +202,7 @@ BuyDialog::BuyDialog(std::string nick) : SelectionListener(), mSortModel(new SortListModelBuy), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")), - mNpcId(-1), + mNpcId(Nick), mMoney(0), mAmountItems(0), mMaxItems(0), @@ -257,7 +257,7 @@ void BuyDialog::init() // You may change this symbol if your language uses another. mDecreaseButton = new Button(this, _("-"), "dec", this); // TRANSLATORS: buy dialog button - mBuyButton = new Button(this, mNpcId == -2 + mBuyButton = new Button(this, mNpcId == Items ? _("Create") :_("Buy"), "buy", this); // TRANSLATORS: buy dialog button mQuitButton = new Button(this, _("Quit"), "quit", this); @@ -435,14 +435,14 @@ void BuyDialog::action(const ActionEvent &event) else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) { ShopItem *const item = mShopItems->at(selectedItem); - if (mNpcId == -2) + if (mNpcId == Items) { adminHandler->createItems(item->getId(), mAmountItems, item->getColor()); } - else if (mNpcId != -1) + else if (mNpcId != Nick) { - if (mNpcId != -3) + if (mNpcId != Market) { npcHandler->buyItem(mNpcId, item->getId(), @@ -508,7 +508,7 @@ void BuyDialog::updateButtonsAndLabels() const int itemPrice = item->getPrice(); // Calculate how many the player can afford - if (mNpcId == -2) + if (mNpcId == Items) mMaxItems = 100; else if (itemPrice) mMaxItems = mMoney / itemPrice; diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index af63432f7..088e9c2ba 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -76,6 +76,13 @@ class BuyDialog final : public Window, */ ~BuyDialog(); + enum + { + Nick = -1, + Items = -2, + Market = -3 + }; + void init(); /** -- cgit v1.2.3-70-g09d2