summaryrefslogtreecommitdiff
path: root/src/gui/buysell.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
commitcc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch)
treeedd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/buysell.cpp
parentb0df784f1be44a657ca8092069488602270629b7 (diff)
parent99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff)
downloadmana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip
Merge branch 'eathena/master'
Conflicts: A lot of files.
Diffstat (limited to 'src/gui/buysell.cpp')
-rw-r--r--src/gui/buysell.cpp62
1 files changed, 51 insertions, 11 deletions
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index 2d39eac7..c56f6435 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -24,11 +24,17 @@
#include "../npc.h"
+#include "../net/messageout.h"
+#ifdef EATHENA_SUPPORT
+#include "../net/ea/protocol.h"
+#endif
+
#include "../utils/gettext.h"
-BuySellDialog::BuySellDialog():
- Window(_("Shop"))
+BuySellDialog::BuySellDialog(Network *network):
+ Window(_("Shop")), mNetwork(network)
{
+ setWindowName("BuySell");
Button *buyButton = 0;
static const char *buttonNames[] = {
N_("Buy"), N_("Sell"), N_("Cancel"), 0
@@ -46,19 +52,53 @@ BuySellDialog::BuySellDialog():
buyButton->requestFocus();
setContentSize(x, 2 * y + buyButton->getHeight());
- setLocationRelativeTo(getParent());
- requestFocus();
+ center();
+ setDefaultSize();
+ loadWindowState();
+}
+
+void BuySellDialog::logic()
+{
+ Window::logic();
+
+ if (isVisible() && !current_npc)
+ setVisible(false);
+}
+
+void BuySellDialog::setVisible(bool visible)
+{
+ Window::setVisible(visible);
+
+ if (visible)
+ requestFocus();
}
void BuySellDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "Buy") {
- current_npc->buy();
- } else if (event.getId() == "Sell") {
- current_npc->sell();
- } else if (event.getId() == "Cancel") {
- if (current_npc) current_npc->handleDeath();
- }
setVisible(false);
+ int action = 0;
+
+ NPC::isTalking = false;
+
+ if (event.getId() == "Buy")
+ {
+ action = 0;
+ }
+ else if (event.getId() == "Sell")
+ {
+ action = 1;
+ }
+ else if (event.getId() == "Cancel")
+ {
+ current_npc = 0;
+ return;
+ }
+
+#ifdef EATHENA_SUPPORT
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);
+ outMsg.writeInt32(current_npc);
+ outMsg.writeInt8(action);
+#endif
}