summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-24 15:33:41 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-24 15:33:41 +0300
commit2f91a45e4c0c59a962059890ed5ab708a059788f (patch)
treecd156d8291ce9b56a635454a6292d9f3d98f737f /src
parent1f7122e76f28ec851ef7d9361396575dde381287 (diff)
downloadmanaplus-2f91a45e4c0c59a962059890ed5ab708a059788f.tar.gz
manaplus-2f91a45e4c0c59a962059890ed5ab708a059788f.tar.bz2
manaplus-2f91a45e4c0c59a962059890ed5ab708a059788f.tar.xz
manaplus-2f91a45e4c0c59a962059890ed5ab708a059788f.zip
Add enum for buy dialog types.
Diffstat (limited to 'src')
-rw-r--r--src/gui/windows/buydialog.cpp14
-rw-r--r--src/gui/windows/buydialog.h7
-rw-r--r--src/net/eathena/markethandler.cpp2
3 files changed, 15 insertions, 8 deletions
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();
/**
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index e0525753e..3c5c873ce 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -76,7 +76,7 @@ void MarketHandler::processMarketOpen(Net::MessageIn &msg)
{
const int len = (msg.readInt16("len") - 4) / 13;
- mBuyDialog = new BuyDialog(-3);
+ mBuyDialog = new BuyDialog(BuyDialog::Market);
mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
for (int f = 0; f < len; f ++)