summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJan-Fabian Humann <malastare@gmx.net>2005-05-22 02:06:58 +0000
committerJan-Fabian Humann <malastare@gmx.net>2005-05-22 02:06:58 +0000
commitfc6207f21a7beaeef968e032917181809f822a67 (patch)
tree8e392e7965855663513430299c8f486f4167528b /src/gui
parenta64c5b01e683e76def759e6e871ceee330c9ae09 (diff)
downloadmana-client-fc6207f21a7beaeef968e032917181809f822a67.tar.gz
mana-client-fc6207f21a7beaeef968e032917181809f822a67.tar.bz2
mana-client-fc6207f21a7beaeef968e032917181809f822a67.tar.xz
mana-client-fc6207f21a7beaeef968e032917181809f822a67.zip
another trade update: trading money is possible now, left box is for money you send, the right label shows the money you receive. Due to stupid RO protocol money value will only be submitted when you press Ok.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/trade.cpp60
-rw-r--r--src/gui/trade.h9
2 files changed, 62 insertions, 7 deletions
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index ff68c402..494032cf 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -29,6 +29,7 @@
#include "../resources/image.h"
#include "button.h"
#include "scrollarea.h"
+#include "textfield.h"
#include "../being.h"
#include "../engine.h"
#include <sstream>
@@ -54,12 +55,20 @@ TradeWindow::TradeWindow():
partnerScroll = new ScrollArea(partnerItems);
partnerScroll->setPosition(8, 64);
-
+
+ moneyLabel = new gcn::Label("You get: 0z");
+ moneyField = new TextField();
+
addButton->setEventId("add");
okButton->setEventId("ok");
cancelButton->setEventId("cancel");
tradeButton->setEventId("trade");
+ addButton->adjustSize();
+ okButton->adjustSize();
+ cancelButton->adjustSize();
+ tradeButton->adjustSize();
+
addButton->addActionListener(this);
okButton->addActionListener(this);
cancelButton->addActionListener(this);
@@ -78,11 +87,21 @@ TradeWindow::TradeWindow():
add(tradeButton);
add(itemNameLabel);
add(itemDescriptionLabel);
-
- addButton->setPosition(8, getHeight() - 24);
- okButton->setPosition(48 + 16, getHeight() - 24);
- tradeButton->setPosition(getWidth() - 92, getHeight() - 24);
- cancelButton->setPosition(getWidth() - 52, getHeight() - 24);
+ add(moneyField);
+ add(moneyLabel);
+
+ moneyField->setPosition(8, getHeight() - 20);
+ moneyField->setWidth(50);
+
+ moneyLabel->setPosition(8+ 50 + 6, getHeight() - 20);
+
+ cancelButton->setPosition(getWidth() - 48, getHeight() - 24);
+ tradeButton->setPosition(cancelButton->getX() - 40
+ , getHeight() - 24);
+ okButton->setPosition(tradeButton->getX() - 24,
+ getHeight() - 24);
+ addButton->setPosition(okButton->getX() - 32,
+ getHeight() - 24);
myItems->setSize(getWidth() - 24 - 12 - 1,
(INVENTORY_SIZE * 24) / (getWidth() / 24) - 1);
@@ -112,6 +131,16 @@ TradeWindow::~TradeWindow()
delete partnerScroll;
delete itemNameLabel;
delete itemDescriptionLabel;
+ delete moneyField;
+ delete moneyLabel;
+}
+
+void TradeWindow::addMoney(int amount)
+{
+ std::stringstream tempMoney;
+ tempMoney << "You get: " << amount << "z";
+ moneyLabel->setCaption(tempMoney.str());
+ moneyLabel->adjustSize();
}
void TradeWindow::addItem(int index, int id, bool own, int quantity,
@@ -159,6 +188,8 @@ void TradeWindow::reset()
okButton->setEnabled(true);
ok_other = false;
ok_me = false;
+ moneyLabel->setCaption("You get: 0z");
+ moneyField->setText("");
}
void TradeWindow::setTradeButton(bool enabled)
@@ -279,6 +310,23 @@ void TradeWindow::action(const std::string &eventId)
}
else if (eventId == "ok")
{
+ std::stringstream tempMoney[2];
+ tempMoney[0] << moneyField->getText();
+ int tempInt;
+ if (tempMoney[0] >> tempInt)
+ {
+ tempMoney[1] << tempInt;
+ moneyField->setText(tempMoney[1].str());
+
+ WFIFOW(0) = net_w_value(0x00e8);
+ WFIFOW(2) = net_w_value(0);
+ WFIFOL(4) = net_l_value(tempInt);
+ WFIFOSET(8);
+ while ((out_size > 0)) flush();
+ } else {
+ moneyField->setText("");
+ }
+
WFIFOW(0) = net_w_value(0x00eb);
WFIFOSET(2);
while ((out_size > 0)) flush();
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 90c688c3..5d82f875 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -51,7 +51,12 @@ class TradeWindow : public Window, gcn::ActionListener
~TradeWindow();
/**
- * Add an item the trade window.
+ * Add money to the trade window.
+ */
+ void addMoney(int quantity);
+
+ /**
+ * Add an item to the trade window.
*/
void addItem(int index, int id, bool own, int quantity, bool equipment);
@@ -106,8 +111,10 @@ class TradeWindow : public Window, gcn::ActionListener
private:
gcn::Label *itemNameLabel;
gcn::Label *itemDescriptionLabel;
+ gcn::Label *moneyLabel;
gcn::Button *addButton, *okButton, *cancelButton, *tradeButton;
ScrollArea *myScroll, *partnerScroll;
+ gcn::TextField *moneyField;
bool ok_other, ok_me;
};