diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-23 23:46:23 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-23 23:46:23 +0000 |
commit | 5c1093ffa9fea3d979a720169e97ed31725e95c4 (patch) | |
tree | 3f40c4000c2f0317e12640eb818a781c3a892497 /src/gui | |
parent | 1fcefe616a39c2e572b8078c5c51c8e81a59c487 (diff) | |
download | mana-5c1093ffa9fea3d979a720169e97ed31725e95c4.tar.gz mana-5c1093ffa9fea3d979a720169e97ed31725e95c4.tar.bz2 mana-5c1093ffa9fea3d979a720169e97ed31725e95c4.tar.xz mana-5c1093ffa9fea3d979a720169e97ed31725e95c4.zip |
Committed patch by Mra, which fixes multiple NPCs talks in one window and
moves the action listener used with BuySellDialog into that class.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 3 | ||||
-rw-r--r-- | src/gui/buysell.cpp | 31 | ||||
-rw-r--r-- | src/gui/buysell.h | 10 | ||||
-rw-r--r-- | src/gui/npc.cpp | 3 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 1 | ||||
-rw-r--r-- | src/gui/sell.cpp | 3 |
6 files changed, 45 insertions, 6 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index ca76b40f..059ba4e8 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -26,6 +26,7 @@ #include "slider.h" #include "scrollarea.h" #include "listbox.h" +#include "../game.h" #include <sstream> @@ -140,9 +141,11 @@ void BuyDialog::action(const std::string& eventId) } } setVisible(false); + current_npc = 0; } else if (eventId == "cancel") { setVisible(false); + current_npc = 0; } } diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index d522e6f2..29010afc 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -23,8 +23,9 @@ #include "buysell.h" #include "button.h" +#include "../game.h" -BuySellDialog::BuySellDialog(gcn::ActionListener *al): +BuySellDialog::BuySellDialog(): Window("Shop") { buyButton = new Button("Buy"); @@ -43,9 +44,9 @@ BuySellDialog::BuySellDialog(gcn::ActionListener *al): sellButton->setEventId("sell"); cancelButton->setEventId("cancel"); - buyButton->addActionListener(al); - sellButton->addActionListener(al); - cancelButton->addActionListener(al); + buyButton->addActionListener(this); + sellButton->addActionListener(this); + cancelButton->addActionListener(this); add(buyButton); add(sellButton); @@ -61,3 +62,25 @@ BuySellDialog::~BuySellDialog() delete sellButton; delete cancelButton; } + +void BuySellDialog::action(const std::string& eventId) +{ + int actionId = -1; + + if (eventId == "buy") { + actionId = 0; + } + else if (eventId == "sell") { + actionId = 1; + } else if (eventId == "cancel") { + current_npc = 0; + } + if (actionId > -1) { + WFIFOW(0) = net_w_value(0x00c5); + WFIFOL(2) = net_l_value(current_npc); + WFIFOB(6) = net_b_value(actionId); + WFIFOSET(7); + } + + setVisible(false); +} diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 2d1d3c29..19c1e859 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -31,7 +31,8 @@ * * \ingroup GUI */ -class BuySellDialog : public Window { +class BuySellDialog : public Window, public gcn::ActionListener +{ public: /** * Constructor. The action listener passed will receive "sell", "buy" @@ -39,12 +40,17 @@ class BuySellDialog : public Window { * * @see Window::Window */ - BuySellDialog(gcn::ActionListener *al); + BuySellDialog(); /** * Destructor. */ ~BuySellDialog(); + + /** + * Called when receiving actions from the widgets. + */ + void action(const std::string& eventId); private: gcn::Button *buyButton; diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 4706112b..4049b061 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -108,7 +108,9 @@ void NpcListDialog::action(const std::string& eventId) WFIFOB(6) = net_b_value(selectedIndex + 1); WFIFOSET(7); setVisible(false); + current_npc = 0; reset(); + } } else if (eventId == "cancel") { @@ -119,5 +121,6 @@ void NpcListDialog::action(const std::string& eventId) WFIFOSET(7); setVisible(false); reset(); + current_npc = 0; } } diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 27c28512..e81d51a8 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -76,4 +76,5 @@ void NpcTextDialog::action(const std::string& eventId) WFIFOSET(6); setText(""); setVisible(false); + current_npc = 0; } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index b914d814..d8e6eb02 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -27,6 +27,7 @@ #include "scrollarea.h" #include "listbox.h" #include "../graphic/graphic.h" +#include "../game.h" #include <sstream> @@ -132,9 +133,11 @@ void SellDialog::action(const std::string& eventId) } } setVisible(false); + current_npc = 0; } else if (eventId == "cancel") { setVisible(false); + current_npc = 0; } } |