diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-05-20 14:28:48 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-05-20 14:28:48 +0000 |
commit | 8b41ae72ae2733fc8bf33627698c75d9a79e1d7b (patch) | |
tree | ffcdb0a1f2d4faea1ed974fad6f0cf6f3f19d13b /src/gui | |
parent | c25caff529473e933d7a2a795d5ed520a52961b0 (diff) | |
download | mana-8b41ae72ae2733fc8bf33627698c75d9a79e1d7b.tar.gz mana-8b41ae72ae2733fc8bf33627698c75d9a79e1d7b.tar.bz2 mana-8b41ae72ae2733fc8bf33627698c75d9a79e1d7b.tar.xz mana-8b41ae72ae2733fc8bf33627698c75d9a79e1d7b.zip |
Fixed the amount-not-reset-when-using-scrollwheel bug in sell dialog.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 39 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a8a1ea7e..8b9e8d8e 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -230,7 +230,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) int price = mAmountItems * mShopItems->at(selectedItem).price; mMoneyLabel->setCaption("Price: " + toString(price) + " GP / " - + toString(mMoney) + " GP" ); + + toString(mMoney - price) + " GP" ); mMoneyLabel->adjustSize(); } } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index c9ac84c3..5de2a9e6 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -202,7 +202,6 @@ void SellDialog::action(const gcn::ActionEvent &event) if (event.getId() == "mSlider") { mAmountItems = (int)(mSlider->getValue() * mMaxItems); - updateButtonsAndLabels = true; } else if (event.getId() == "+") @@ -255,39 +254,57 @@ void SellDialog::action(const gcn::ActionEvent &event) // If anything changed, we need to update the buttons and labels if (updateButtonsAndLabels) { + // Update Buttons + mSellButton->setEnabled(mAmountItems > 0); + mDecreaseButton->setEnabled(mAmountItems > 0); + mIncreaseButton->setEnabled(mAmountItems < mMaxItems); + // Update labels mQuantityLabel->setCaption(toString(mAmountItems) + " / " + toString(mMaxItems)); mQuantityLabel->adjustSize(); - int price = mAmountItems * mShopItems->at(selectedItem).price; - mMoneyLabel->setCaption("Money: " + toString(price) + " GP / Total: " - + toString(price + mPlayerMoney) + " GP"); + int sellSum = mAmountItems * mShopItems->at(selectedItem).price; + mMoneyLabel->setCaption("Money: " + toString(sellSum) + " GP / Total: " + + toString(mPlayerMoney + sellSum) + " GP"); mMoneyLabel->adjustSize(); - - // Update Buttons - mSellButton->setEnabled(mAmountItems > 0); - mDecreaseButton->setEnabled(mAmountItems > 0); - mIncreaseButton->setEnabled(mAmountItems < mMaxItems); } } void SellDialog::selectionChanged(const SelectionEvent &event) { + // Reset amount of items and update labels + mAmountItems = 0; + mSlider->setValue(0); + mSlider->setEnabled(true); + mMoneyLabel->setCaption("Money: 0 GP / Total: " + + toString(mPlayerMoney) + " GP"); + mMoneyLabel->adjustSize(); + + // Disable buttons for selling and decreasing, enable button for increasing + mIncreaseButton->setEnabled(true); + mSellButton->setEnabled(false); + mDecreaseButton->setEnabled(false); + int selectedItem = mShopItemList->getSelected(); if (selectedItem > -1) { - const ItemInfo &info = - ItemDB::get(mShopItems->at(selectedItem).id); + mMaxItems = mShopItems->at(selectedItem).quantity; + + const ItemInfo &info = ItemDB::get(mShopItems->at(selectedItem).id); mItemDescLabel->setCaption("Description: " + info.getDescription()); mItemEffectLabel->setCaption("Effect: " + info.getEffect()); } else { + mMaxItems = 0; mItemDescLabel->setCaption("Description"); mItemEffectLabel->setCaption("Effect"); } + + mQuantityLabel->setCaption("0 / " + toString(mMaxItems)); + mQuantityLabel->adjustSize(); } void SellDialog::setMoney(int amount) |