diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-03 16:47:48 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-03 16:47:48 +0000 |
commit | fe3ecae6936b41045b405fb5055a9ad754ddec3b (patch) | |
tree | adfcc1071e96fb26b08bb9d5d06fda70c03aeff9 /src/gui/trade.cpp | |
parent | 77efbb50066a030d1f44f8de8d06ace9f284e3a2 (diff) | |
download | mana-client-fe3ecae6936b41045b405fb5055a9ad754ddec3b.tar.gz mana-client-fe3ecae6936b41045b405fb5055a9ad754ddec3b.tar.bz2 mana-client-fe3ecae6936b41045b405fb5055a9ad754ddec3b.tar.xz mana-client-fe3ecae6936b41045b405fb5055a9ad754ddec3b.zip |
Fixed updating of labels in trade window.
Diffstat (limited to 'src/gui/trade.cpp')
-rw-r--r-- | src/gui/trade.cpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index babb5a87..cb839157 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -59,12 +59,14 @@ TradeWindow::TradeWindow(Network *network): mTradeButton = new Button("Trade", "trade", this); mMyItemContainer = new ItemContainer(mMyInventory.get()); + mMyItemContainer->addSelectionListener(this); mMyItemContainer->setPosition(2, 2); mMyScroll = new ScrollArea(mMyItemContainer); mMyScroll->setPosition(8, 8); mPartnerItemContainer = new ItemContainer(mPartnerInventory.get()); + mPartnerItemContainer->addSelectionListener(this); mPartnerItemContainer->setPosition(2, 58); mPartnerScroll = new ScrollArea(mPartnerItemContainer); @@ -221,53 +223,54 @@ void TradeWindow::tradeItem(Item *item, int quantity) outMsg.writeInt32(quantity); } -void TradeWindow::mouseClick(int x, int y, int button, int count) +void TradeWindow::selectionChanged(const SelectionEvent &event) { - Window::mouseClick(x, y, button, count); - Item *item; - // mMyItems selected - if (x >= mMyScroll->getX() + 3 - && x <= mMyScroll->getX() + mMyScroll->getWidth() - 10 - && y >= mMyScroll->getY() + 16 - && y <= mMyScroll->getY() + mMyScroll->getHeight() + 15 - && (item = mMyItemContainer->getItem())) + /* If an item is selected in one container, make sure no item is selected + * in the other container. + */ + if (event.getSource() == mMyItemContainer && + (item = mMyItemContainer->getItem())) { - mPartnerItemContainer->selectNone(); - // mPartnerItems selected + mPartnerItemContainer->selectNone(); } - else if (x >= mPartnerScroll->getX() + 3 - && x <= mPartnerScroll->getX() + mPartnerScroll->getWidth() - 20 - && y >= mPartnerScroll->getY() + 16 - && y <= mPartnerScroll->getY() + mPartnerScroll->getHeight() + 15 - && (item = mPartnerItemContainer->getItem())) + else if ((item = mPartnerItemContainer->getItem())) { - mMyItemContainer->selectNone(); - } else { - return; + mMyItemContainer->selectNone(); } - // Show Name and Description - std::string SomeText; - SomeText = "Name: " + item->getInfo().getName(); - mItemNameLabel->setCaption(SomeText); - mItemNameLabel->adjustSize(); - SomeText = "Description: " + item->getInfo().getDescription(); - mItemDescriptionLabel->setCaption(SomeText); - mItemDescriptionLabel->adjustSize(); + // Update name and description + if (!item) + { + mItemNameLabel->setCaption("Name:"); + mItemDescriptionLabel->setCaption("Description:"); + } + else + { + std::string SomeText; + SomeText = "Name: " + item->getInfo().getName(); + mItemNameLabel->setCaption(SomeText); + mItemNameLabel->adjustSize(); + SomeText = "Description: " + item->getInfo().getDescription(); + mItemDescriptionLabel->setCaption(SomeText); + mItemDescriptionLabel->adjustSize(); + } } void TradeWindow::action(const std::string& eventId, gcn::Widget* widget) { Item *item = inventoryWindow->getItem(); - if (eventId == "add") { - if (!item) { + if (eventId == "add") + { + if (!item) + { return; } - if (mMyInventory->getFreeSlot() < 1) { + if (mMyInventory->getFreeSlot() < 1) + { return; } |