summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-04 19:06:32 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-04 19:06:32 +0200
commitfcf12d937c55e115e80325f8fbd6069f27a667a3 (patch)
tree26203cd700697f30f9fb8b149b3658deae7db559 /src/gui
parentd6ef8f92a7abe1e4a635e86f1bcf2675ffbc6658 (diff)
downloadmanaplus-fcf12d937c55e115e80325f8fbd6069f27a667a3.tar.gz
manaplus-fcf12d937c55e115e80325f8fbd6069f27a667a3.tar.bz2
manaplus-fcf12d937c55e115e80325f8fbd6069f27a667a3.tar.xz
manaplus-fcf12d937c55e115e80325f8fbd6069f27a667a3.zip
Update item amount in sell dialog.
Diffstat (limited to 'src/gui')
-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)