diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-05-06 03:01:40 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-05-06 03:01:40 +0000 |
commit | f2105401aea25f663392e947ca618d48272ee489 (patch) | |
tree | 672c31b6f1df9577056d9b7439f7d3bd1578eeb3 /src | |
parent | f2a70bcfbaab713145d4af9cabfc344b665d1c61 (diff) | |
download | mana-f2105401aea25f663392e947ca618d48272ee489.tar.gz mana-f2105401aea25f663392e947ca618d48272ee489.tar.bz2 mana-f2105401aea25f663392e947ca618d48272ee489.tar.xz mana-f2105401aea25f663392e947ca618d48272ee489.zip |
Added item description for selected item in buy dialog.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/buy.cpp | 33 | ||||
-rw-r--r-- | src/gui/buy.h | 7 |
2 files changed, 36 insertions, 4 deletions
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 @@ -76,6 +76,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. */ std::string getElementAt(int i); @@ -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; |