diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-25 02:55:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-25 02:55:51 +0300 |
commit | 1ad3e55c431b61e6fe6638ee0afc5e8f4c14496c (patch) | |
tree | c198baa8b7c57b2a4b118e6d740961a126d0e528 /src/gui/windows/buydialog.cpp | |
parent | 290ae8ba45bb706f32da15978459022e633aa626 (diff) | |
download | mv-1ad3e55c431b61e6fe6638ee0afc5e8f4c14496c.tar.gz mv-1ad3e55c431b61e6fe6638ee0afc5e8f4c14496c.tar.bz2 mv-1ad3e55c431b61e6fe6638ee0afc5e8f4c14496c.tar.xz mv-1ad3e55c431b61e6fe6638ee0afc5e8f4c14496c.zip |
Allow buy more than one item at vending shop at once.
Diffstat (limited to 'src/gui/windows/buydialog.cpp')
-rw-r--r-- | src/gui/windows/buydialog.cpp | 77 |
1 files changed, 53 insertions, 24 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index eb01e0562..9dc2b8111 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -26,6 +26,8 @@ #include "configuration.h" #include "units.h" +#include "being/being.h" + #include "gui/windows/setupwindow.h" #include "gui/windows/tradewindow.h" @@ -226,6 +228,26 @@ BuyDialog::BuyDialog(std::string nick) : init(); } +BuyDialog::BuyDialog(const Being *const being) : + // TRANSLATORS: buy dialog name + Window(_("Buy"), Modal_false, nullptr, "buy.xml"), + ActionListener(), + SelectionListener(), + mSortModel(new SortListModelBuy), + mSortDropDown(new DropDown(this, mSortModel, false, + Modal_false, this, "sort")), + mFilterTextField(new TextField(this, "", true, this, "namefilter", true)), + mFilterLabel(nullptr), + mNick(being ? being->getName() : std::string()), + mNpcId(fromInt(Vending, BeingId)), + mMoney(0), + mAmountItems(0), + mMaxItems(0), + mAdvanced(true) +{ + init(); +} + void BuyDialog::init() { setWindowName("Buy"); @@ -446,6 +468,9 @@ void BuyDialog::close() case Cash: cashShopHandler->close(); break; + case Vending: + vendingHandler->close(); + break; default: buySellHandler->close(); break; @@ -523,6 +548,23 @@ void BuyDialog::action(const ActionEvent &event) item->getColor(), mAmountItems); } + else if (mNpcId == fromInt(Nick, BeingId)) + { + if (tradeWindow) + { + buySellHandler->sendBuyRequest(mNick, + item, mAmountItems); + tradeWindow->addAutoMoney(mNick, + item->getPrice() * mAmountItems); + } + } + else if (mNpcId == fromInt(Vending, BeingId)) + { + item->increaseUsedQuantity(mAmountItems); + item->update(); + if (mConfirmButton) + mConfirmButton->setEnabled(true); + } else if (mNpcId != fromInt(Nick, BeingId)) { if (mAdvanced) @@ -558,30 +600,6 @@ void BuyDialog::action(const ActionEvent &event) updateSlider(selectedItem); } - else if (mNpcId == fromInt(Nick, BeingId)) - { - if (serverFeatures->haveVending()) - { - const Being *const being = actorManager->findBeingByName( - mNick); - if (being) - { - vendingHandler->buy(being, - item->getInvIndex(), - mAmountItems); - item->increaseQuantity(-mAmountItems); - item->update(); - updateSlider(selectedItem); - } - } - else if (tradeWindow) - { - buySellHandler->sendBuyRequest(mNick, - item, mAmountItems); - tradeWindow->addAutoMoney(mNick, - item->getPrice() * mAmountItems); - } - } } else if (eventId == "confirm") { @@ -591,6 +609,17 @@ void BuyDialog::action(const ActionEvent &event) { marketHandler->buyItems(items); } + else if (mNpcId == fromInt(Vending, BeingId)) + { + const Being *const being = actorManager->findBeingByName( + mNick, + ActorType::Player); + if (being) + { + vendingHandler->buyItems(being, + items); + } + } else { npcHandler->buyItems(items); |