summaryrefslogtreecommitdiff
path: root/src/gui
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
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')
-rw-r--r--src/gui/buydialog.cpp30
-rw-r--r--src/gui/buydialog.h9
-rw-r--r--src/gui/itemamountwindow.cpp2
-rw-r--r--src/gui/textcommandeditor.cpp2
4 files changed, 36 insertions, 7 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;
diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h
index 35cc2d8db..875184851 100644
--- a/src/gui/buydialog.h
+++ b/src/gui/buydialog.h
@@ -54,10 +54,19 @@ class BuyDialog final : public Window,
*
* @see Window::Window
*/
+ BuyDialog();
+
+ /**
+ * Constructor.
+ *
+ * @see Window::Window
+ */
explicit BuyDialog(const int npcId);
/**
* Constructor.
+ *
+ * @see Window::Window
*/
explicit BuyDialog(std::string nick);
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index 3df003bfb..61760f6d3 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -53,7 +53,7 @@ public:
ItemsModal() :
mStrings()
{
- std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
+ const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 449196ed8..029089704 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -57,7 +57,7 @@ public:
IconsModal() :
mStrings()
{
- std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
+ const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator