From 2c273a20b2cd3e1628840f2d87df16f0cce9ad33 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 1 Feb 2017 00:43:24 +0300 Subject: Set currency to buy dialog based on selected npc type id. For now this type never set. --- src/gui/windows/buydialog.cpp | 12 +++++++++--- src/gui/windows/buydialog.h | 10 +++++++--- src/gui/windows/shopwindow.cpp | 6 +++--- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index c5fdac885..620c95817 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -203,7 +203,8 @@ BuyDialog::BuyDialog() : init(); } -BuyDialog::BuyDialog(const BeingId npcId) : +BuyDialog::BuyDialog(const BeingId npcId, + const std::string ¤cy) : // TRANSLATORS: buy dialog name Window(_("Buy"), Modal_false, nullptr, "buy.xml"), ActionListener(), @@ -214,6 +215,7 @@ BuyDialog::BuyDialog(const BeingId npcId) : this, "namefilter", true)), mFilterLabel(nullptr), mNick(), + mCurrency(currency), mNpcId(npcId), mMoney(0), mAmountItems(0), @@ -224,7 +226,8 @@ BuyDialog::BuyDialog(const BeingId npcId) : } #ifdef TMWA_SUPPORT -BuyDialog::BuyDialog(std::string nick) : +BuyDialog::BuyDialog(const std::string &nick, + const std::string ¤cy) : // TRANSLATORS: buy dialog name Window(_("Buy"), Modal_false, nullptr, "buy.xml"), ActionListener(), @@ -236,6 +239,7 @@ BuyDialog::BuyDialog(std::string nick) : this, "namefilter", true)), mFilterLabel(nullptr), mNick(nick), + mCurrency(currency), mNpcId(fromInt(Nick, BeingId)), mMoney(0), mAmountItems(0), @@ -246,7 +250,8 @@ BuyDialog::BuyDialog(std::string nick) : } #endif // TMWA_SUPPORT -BuyDialog::BuyDialog(const Being *const being) : +BuyDialog::BuyDialog(const Being *const being, + const std::string ¤cy) : // TRANSLATORS: buy dialog name Window(_("Buy"), Modal_false, nullptr, "buy.xml"), ActionListener(), @@ -258,6 +263,7 @@ BuyDialog::BuyDialog(const Being *const being) : this, "namefilter", true)), mFilterLabel(nullptr), mNick(being ? being->getName() : std::string()), + mCurrency(currency), mNpcId(fromInt(Vending, BeingId)), mMoney(0), mAmountItems(0), diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 4fdd4f210..7914c0ef3 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -68,7 +68,8 @@ class BuyDialog final : public Window, * * @see Window::Window */ - explicit BuyDialog(const BeingId npcId); + BuyDialog(const BeingId npcId, + const std::string ¤cy); #ifdef TMWA_SUPPORT /** @@ -76,7 +77,8 @@ class BuyDialog final : public Window, * * @see Window::Window */ - explicit BuyDialog(std::string nick); + BuyDialog(const std::string &nick, + const std::string ¤cy); #endif // TMWA_SUPPORT /** @@ -84,7 +86,8 @@ class BuyDialog final : public Window, * * @see Window::Window */ - explicit BuyDialog(const Being *const being); + BuyDialog(const Being *const being, + const std::string ¤cy); A_DELETE_COPY(BuyDialog) @@ -193,6 +196,7 @@ class BuyDialog final : public Window, Label *mFilterLabel; std::string mNick; + std::string mCurrency; BeingId mNpcId; int mMoney; int mAmountItems; diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index d7b629a4e..b09b44a46 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -23,6 +23,8 @@ #include "gui/windows/shopwindow.h" #ifdef TMWA_SUPPORT +#include "const/resources/currency.h" + #include "gui/windows/buydialog.h" #include "gui/windows/chatwindow.h" #include "gui/windows/confirmdialog.h" @@ -829,7 +831,7 @@ void ShopWindow::showList(const std::string &nick, std::string data) if (data.find("B1") == 0) { data = data.substr(2); - CREATEWIDGETV(buyDialog, BuyDialog, nick); + CREATEWIDGETV(buyDialog, BuyDialog, nick, DEFAULT_CURRENCY); } else if (data.find("S1") == 0) { @@ -854,7 +856,6 @@ void ShopWindow::showList(const std::string &nick, std::string data) const int id = decodeStr(data.substr(f, 2)); const int price = decodeStr(data.substr(f + 2, 4)); int amount = decodeStr(data.substr(f + 6, 3)); - // +++ need impliment colors? if (buyDialog && amount > 0) { buyDialog->addItem(id, @@ -865,7 +866,6 @@ void ShopWindow::showList(const std::string &nick, std::string data) } if (sellDialog) { - // +++ need support for colors const Item *const item = inv->findItem(id, ItemColor_zero); if (item) { -- cgit v1.2.3-60-g2f50