diff options
author | Jan-Fabian Humann <malastare@gmx.net> | 2005-05-11 22:59:27 +0000 |
---|---|---|
committer | Jan-Fabian Humann <malastare@gmx.net> | 2005-05-11 22:59:27 +0000 |
commit | a95de401e0a8b443865f2d25ecc70fe138ef7957 (patch) | |
tree | 72f1e6ead74adc39c3b0d048ca8ab4ea5be96d79 | |
parent | 732f50f7408a76e108d0af14aa3aaaa81391b1a9 (diff) | |
download | mana-client-a95de401e0a8b443865f2d25ecc70fe138ef7957.tar.gz mana-client-a95de401e0a8b443865f2d25ecc70fe138ef7957.tar.bz2 mana-client-a95de401e0a8b443865f2d25ecc70fe138ef7957.tar.xz mana-client-a95de401e0a8b443865f2d25ecc70fe138ef7957.zip |
another trade update: selecting items is more logical now, name and desc. are being displayed
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | src/game.cpp | 6 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 5 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 7 | ||||
-rw-r--r-- | src/gui/trade.cpp | 50 | ||||
-rw-r--r-- | src/gui/trade.h | 5 |
6 files changed, 68 insertions, 7 deletions
@@ -13,7 +13,7 @@ The Mana World Dev Team Shura (configuration, sound, misc. ports) zenogais (resource manager) Usiu (several GUI parts) - + Mra (some GUI parts) == Artists == Clef (tiles, concepts) 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); |