summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/itemcontainer.cpp5
-rw-r--r--src/gui/itemcontainer.h7
-rw-r--r--src/gui/trade.cpp50
-rw-r--r--src/gui/trade.h5
5 files changed, 67 insertions, 6 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 55dc3b5c..18ef46a0 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -815,10 +815,10 @@ void do_parse()
break;
// Trade: Item added on trade partner's side
case 0x00e9:
- // Should do:
- // Maybe also handle indentified, etc
- // later also de-clicked the ok button
+ // todo:
+ // Maybe also handle identified, etc
// handle zeny as well
+
tradeWindow->addItem(
tradeWindow->partnerItems->getFreeSlot(), RFIFOW(6),
false, RFIFOL(2), false);
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 05a1f4de..a5c70632 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -169,6 +169,11 @@ void ItemContainer::resetItems()
}
}
+void ItemContainer::selectNone()
+{
+ selectedItem = -1;
+}
+
void ItemContainer::removeItem(int id)
{
for (int i = 0; i < INVENTORY_SIZE; i++) {
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 849bd252..0e84f0af 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -117,7 +117,12 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
* Adds a new item.
*/
void addItem(int index, int id, int quantity, bool equipment);
-
+
+ /**
+ * Set selected item to -1.
+ */
+ void selectNone();
+
/**
* Reset all item slots.
*/
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 1ca05ac0..859731a3 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -21,6 +21,7 @@
* $Id $
*/
+#include "../main.h"
#include "../graphics.h"
#include "trade.h"
#include "../resources/resourcemanager.h"
@@ -84,6 +85,7 @@ TradeWindow::TradeWindow():
myItems->setSize(getWidth() - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1);
myScroll->setSize(getWidth() - 16, (getHeight() - 76) / 2);
+
partnerItems->setSize(getWidth() - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1);
partnerScroll->setSize(getWidth() - 16, (getHeight() - 76) / 2);
@@ -178,12 +180,56 @@ void TradeWindow::receivedOk(bool own) {
}
}
+void TradeWindow::mouseClick(int x, int y, int button, int count)
+{
+
+ Window::mouseClick(x, y, button, count);
+
+ // myItems selected
+ if (x >= myScroll->getX() + 3
+ && x <= myScroll->getX() + myScroll->getWidth() - 10
+ && y >= myScroll->getY() + 16
+ && y <= myScroll->getY() + myScroll->getHeight() + 15)
+ {
+ if (myItems->getIndex() != -1)
+ {
+ partnerItems->selectNone();
+
+ // Show Name and Description
+ std::string SomeText;
+ SomeText = "Name: " + itemDb->getItemInfo(myItems->getId())->getName();
+ itemNameLabel->setCaption(SomeText);
+ itemNameLabel->adjustSize();
+ SomeText = "Description: " + itemDb->getItemInfo(myItems->getId())->getDescription();
+ itemDescriptionLabel->setCaption(SomeText);
+ itemDescriptionLabel->adjustSize();
+ }
+ // partnerItems selected
+ } else if (x >= partnerScroll->getX() + 3
+ && x <= partnerScroll->getX() + partnerScroll->getWidth() - 20
+ && y >= partnerScroll->getY() + 16
+ && y <= partnerScroll->getY() + partnerScroll->getHeight() + 15)
+ {
+ if (partnerItems->getIndex() != -1)
+ {
+ myItems->selectNone();
+
+ // Show Name and Description
+ std::string SomeText;
+ SomeText = "Name: " + itemDb->getItemInfo(partnerItems->getId())->getName();
+ itemNameLabel->setCaption(SomeText);
+ itemNameLabel->adjustSize();
+ SomeText = "Description: " + itemDb->getItemInfo(partnerItems->getId())->getDescription();
+ itemDescriptionLabel->setCaption(SomeText);
+ itemDescriptionLabel->adjustSize();
+ }
+ }
+}
+
void TradeWindow::action(const std::string &eventId)
{
if (eventId == "add") {
- // This is still kinda buggy, when ok is clicked, will need to play
- // RO a bit to review its trade behaviour
if (inventoryWindow->items->getIndex() >= 0 &&
inventoryWindow->items->getIndex() <= INVENTORY_SIZE) {
if (tradeWindow->myItems->getFreeSlot() >= 0) {
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 47865d6c..d977efb4 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -90,6 +90,11 @@ class TradeWindow : public Window, gcn::ActionListener {
void receivedOk(bool own);
/**
+ * Called on mouse click.
+ */
+ void mouseClick(int x, int y, int button, int count);
+
+ /**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);