summaryrefslogtreecommitdiff
path: root/src/gui/sell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/sell.cpp')
-rw-r--r--src/gui/sell.cpp27
1 files changed, 21 insertions, 6 deletions
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)