From fcf12d937c55e115e80325f8fbd6069f27a667a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 4 Feb 2011 19:06:32 +0200 Subject: Update item amount in sell dialog. --- src/gui/sell.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gui/sell.cpp') diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 1b149cd48..c918971ab 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -234,7 +234,11 @@ void SellDialog::action(const gcn::ActionEvent &event) mAmountItems = 1; mSlider->setValue(0); - if (!mMaxItems) + if (mMaxItems) + { + updateButtonsAndLabels(); + } + else { // All were sold mShopItemList->setSelected(-1); @@ -280,14 +284,23 @@ void SellDialog::updateButtonsAndLabels() { int selectedItem = mShopItemList->getSelected(); int income = 0; + ShopItem *item = 0; if (selectedItem > -1 && mShopItems->at(selectedItem)) { - mMaxItems = mShopItems->at(selectedItem)->getQuantity(); - if (mAmountItems > mMaxItems) - mAmountItems = mMaxItems; - - income = mAmountItems * mShopItems->at(selectedItem)->getPrice(); + item = mShopItems->at(selectedItem); + if (item) + { + mMaxItems = item->getQuantity(); + if (mAmountItems > mMaxItems) + mAmountItems = mMaxItems; + income = mAmountItems * mShopItems->at(selectedItem)->getPrice(); + } + else + { + mMaxItems = 0; + mAmountItems = 0; + } } else { @@ -306,6 +319,8 @@ void SellDialog::updateButtonsAndLabels() mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"), Units::formatCurrency(income).c_str(), Units::formatCurrency(mPlayerMoney + income).c_str())); + if (item) + item->update(); } void SellDialog::setVisible(bool visible) -- cgit v1.2.3-70-g09d2