From f2105401aea25f663392e947ca618d48272ee489 Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Fri, 6 May 2005 03:01:40 +0000 Subject: Added item description for selected item in buy dialog. --- src/gui/buy.cpp | 33 +++++++++++++++++++++++++++++---- src/gui/buy.h | 7 +++++++ 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 296a45ad..e55866fb 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -43,15 +43,20 @@ BuyDialog::BuyDialog(): okButton = new Button("OK"); cancelButton = new Button("Cancel"); okButton->setEnabled(false); + itemNameLabel = new gcn::Label("Name:"); + itemDescLabel = new gcn::Label("Description:"); - setContentSize(260, 175); + setContentSize(260, 198); scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); itemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); slider->setDimension(gcn::Rectangle(5, 120, 200, 10)); quantityLabel->setPosition(215, 120); - moneyLabel->setPosition(5, 135); - okButton->setPosition(180, 145); - cancelButton->setPosition(208, 145); + moneyLabel->setPosition(5, 133); + okButton->setPosition(180, 174); + cancelButton->setPosition(208, 174); + + itemNameLabel->setDimension(gcn::Rectangle(5, 145, 240, 14)); + itemDescLabel->setDimension(gcn::Rectangle(5, 157, 240, 14)); itemList->setEventId("item"); slider->setEventId("slider"); @@ -63,12 +68,15 @@ BuyDialog::BuyDialog(): okButton->addActionListener(this); cancelButton->addActionListener(this); + add(scrollArea); add(slider); add(quantityLabel); add(moneyLabel); add(okButton); add(cancelButton); + add(itemNameLabel); + add(itemDescLabel); setLocationRelativeTo(getParent()); } @@ -81,6 +89,8 @@ BuyDialog::~BuyDialog() delete slider; delete itemList; delete scrollArea; + delete itemNameLabel; + delete itemDescLabel; } void BuyDialog::setMoney(int amount) @@ -154,6 +164,21 @@ void BuyDialog::action(const std::string& eventId) } } +void BuyDialog::mouseClick(int x, int y, int button, int count) +{ + Window::mouseClick(x, y, button, count); + +// shopInventory[selectedItem]; + int selectedItem = itemList->getSelected(); + if (selectedItem > -1) + { + itemNameLabel->setCaption("Name: " + + itemDb.getItemInfo(shopInventory[selectedItem].id)->getName()); + itemDescLabel->setCaption("Description: " + + itemDb.getItemInfo(shopInventory[selectedItem].id)->getDescription()); + } +} + int BuyDialog::getNumberOfElements() { return shopInventory.size(); diff --git a/src/gui/buy.h b/src/gui/buy.h index b6265c6e..ecdb0cb8 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -75,6 +75,11 @@ class BuyDialog : public Window, public gcn::ActionListener, */ int getNumberOfElements(); + /** + * Mouse callback + */ + void mouseClick(int x, int y, int buton, int count); + /** * Returns the name of item number i in the shop inventory. */ @@ -85,6 +90,8 @@ class BuyDialog : public Window, public gcn::ActionListener, gcn::Button *cancelButton; gcn::ListBox *itemList; gcn::ScrollArea *scrollArea; + gcn::Label *itemNameLabel; + gcn::Label *itemDescLabel; gcn::Label *moneyLabel; gcn::Label *quantityLabel; gcn::Slider *slider; -- cgit v1.2.3-70-g09d2