diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-03 21:25:02 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-03 21:25:02 +0000 |
commit | 22aca668b53786dc00ff43764e61980e6499ec30 (patch) | |
tree | 9deb46fb98db77b556d579ce9eeaf4baa80a75e5 /src/gui/sell.cpp | |
parent | fe3ecae6936b41045b405fb5055a9ad754ddec3b (diff) | |
download | mana-22aca668b53786dc00ff43764e61980e6499ec30.tar.gz mana-22aca668b53786dc00ff43764e61980e6499ec30.tar.bz2 mana-22aca668b53786dc00ff43764e61980e6499ec30.tar.xz mana-22aca668b53786dc00ff43764e61980e6499ec30.zip |
Fixed updating of labels in buy and sell dialogs. Also made our listbox respond
to mouse dragging to change the selection.
Diffstat (limited to 'src/gui/sell.cpp')
-rw-r--r-- | src/gui/sell.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 44fa8e41..cc43d36c 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -95,6 +95,7 @@ SellDialog::SellDialog(Network *network): mSlider->setEventId("mSlider"); mItemList->addActionListener(this); + mItemList->addSelectionListener(this); mSlider->addActionListener(this); add(scrollArea); @@ -156,7 +157,8 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget) { int selectedItem = mItemList->getSelected(); - if (eventId == "item") { + if (eventId == "item") + { mAmountItems = 0; mSlider->setValue(0); mDecreaseButton->setEnabled(false); @@ -189,19 +191,22 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget) bool updateButtonsAndLabels = false; - if (eventId == "mSlider") { + if (eventId == "mSlider") + { mAmountItems = (int)(mSlider->getValue() * mMaxItems); updateButtonsAndLabels = true; } - else if (eventId == "+") { + else if (eventId == "+") + { assert(mAmountItems < mMaxItems); mAmountItems++; mSlider->setValue(double(mAmountItems)/double(mMaxItems)); updateButtonsAndLabels = true; } - else if (eventId == "-") { + else if (eventId == "-") + { assert(mAmountItems > 0); mAmountItems--; @@ -209,7 +214,8 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget) updateButtonsAndLabels = true; } - else if (eventId == "sell") { + else if (eventId == "sell") + { // Attempt sell assert(mAmountItems > 0 && mAmountItems <= mMaxItems); @@ -236,7 +242,8 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget) } // If anything changed, we need to update the buttons and labels - if (updateButtonsAndLabels) { + if (updateButtonsAndLabels) + { // Update labels mQuantityLabel->setCaption(toString(mAmountItems)); mQuantityLabel->adjustSize(); @@ -252,11 +259,10 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget) } } -void SellDialog::mouseClick(int x, int y, int button, int count) +void SellDialog::selectionChanged(const SelectionEvent &event) { - Window::mouseClick(x, y, button, count); - int selectedItem = mItemList->getSelected(); + if (selectedItem > -1) { const ItemInfo &info = @@ -265,4 +271,9 @@ void SellDialog::mouseClick(int x, int y, int button, int count) mItemDescLabel->setCaption("Description: " + info.getDescription()); mItemEffectLabel->setCaption("Effect: " + info.getEffect()); } + else + { + mItemDescLabel->setCaption("Description"); + mItemEffectLabel->setCaption("Effect"); + } } |