summaryrefslogtreecommitdiff
path: root/src/gui/buydialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-11 20:49:20 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-11 20:52:50 +0300
commite36c735ce6569cd9c0e668632e59bcbe3280d507 (patch)
treeeb8fa3f8800d95bcd0c6b3c1ea314567f56debb4 /src/gui/buydialog.cpp
parentffd452cd1ee7d252355c259ca2bae1d40c0e97e9 (diff)
downloadmanaplus-e36c735ce6569cd9c0e668632e59bcbe3280d507.tar.gz
manaplus-e36c735ce6569cd9c0e668632e59bcbe3280d507.tar.bz2
manaplus-e36c735ce6569cd9c0e668632e59bcbe3280d507.tar.xz
manaplus-e36c735ce6569cd9c0e668632e59bcbe3280d507.zip
Add chat command for gms for creating items.
New command: /createitems It will open creation window.
Diffstat (limited to 'src/gui/buydialog.cpp')
-rw-r--r--src/gui/buydialog.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index a6d56e220..6c9cc0bd7 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -37,6 +37,7 @@
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
+#include "net/adminhandler.h"
#include "net/buysellhandler.h"
#include "net/net.h"
#include "net/npchandler.h"
@@ -188,6 +189,18 @@ class SortItemTypeFunctor final
BuyDialog::DialogList BuyDialog::instances;
+BuyDialog::BuyDialog() :
+ // TRANSLATORS: buy dialog name
+ Window(_("Create items"), false, nullptr, "buy.xml"),
+ gcn::ActionListener(),
+ gcn::SelectionListener(),
+ mNpcId(0), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(),
+ mSortModel(nullptr),
+ mSortDropDown(nullptr)
+{
+ init();
+}
+
BuyDialog::BuyDialog(const int npcId) :
// TRANSLATORS: buy dialog name
Window(_("Buy"), false, nullptr, "buy.xml"),
@@ -210,7 +223,6 @@ BuyDialog::BuyDialog(std::string nick) :
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort"))
{
init();
- logger->log("BuyDialog::BuyDialog nick:" + mNick);
}
void BuyDialog::init()
@@ -255,7 +267,8 @@ 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, _("Buy"), "buy", this);
+ mBuyButton = new Button(this, mNpcId == 0
+ ? _("Create") :_("Buy"), "buy", this);
// TRANSLATORS: buy dialog button
mQuitButton = new Button(this, _("Quit"), "quit", this);
// TRANSLATORS: buy dialog button
@@ -420,7 +433,13 @@ void BuyDialog::action(const gcn::ActionEvent &event)
}
else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
- if (mNpcId != -1)
+ if (!mNpcId)
+ {
+ const ShopItem *const item = mShopItems->at(selectedItem);
+ Net::getAdminHandler()->createItems(item->getId(),
+ mAmountItems, item->getColor());
+ }
+ else if (mNpcId != -1)
{
const ShopItem *const item = mShopItems->at(selectedItem);
Net::getNpcHandler()->buyItem(mNpcId, item->getId(),
@@ -444,7 +463,6 @@ void BuyDialog::action(const gcn::ActionEvent &event)
{
Net::getBuySellHandler()->sendBuyRequest(mNick,
item, mAmountItems);
-// logger->log("buy button mNick:" + mNick);
if (tradeWindow)
{
tradeWindow->addAutoMoney(mNick,
@@ -480,7 +498,9 @@ void BuyDialog::updateButtonsAndLabels()
const int itemPrice = item->getPrice();
// Calculate how many the player can afford
- if (itemPrice)
+ if (!mNpcId)
+ mMaxItems = 100;
+ else if (itemPrice)
mMaxItems = mMoney / itemPrice;
else
mMaxItems = 1;