summaryrefslogtreecommitdiff
path: root/src/gui/buysell.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-23 23:46:23 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-23 23:46:23 +0000
commit5c1093ffa9fea3d979a720169e97ed31725e95c4 (patch)
tree3f40c4000c2f0317e12640eb818a781c3a892497 /src/gui/buysell.cpp
parent1fcefe616a39c2e572b8078c5c51c8e81a59c487 (diff)
downloadmana-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/buysell.cpp')
-rw-r--r--src/gui/buysell.cpp31
1 files changed, 27 insertions, 4 deletions
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);
+}