summaryrefslogtreecommitdiff
path: root/src/gui/windows/buydialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-02 00:05:22 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-02 22:48:09 +0300
commit45ba0e489cf85d957c26f1e5895399953c203cd9 (patch)
treee478f24809c3e50ce04082f23d812db7f37197cf /src/gui/windows/buydialog.cpp
parent6dc1f5e0b68cf390f7938329b50a9b28bd187862 (diff)
downloadplus-45ba0e489cf85d957c26f1e5895399953c203cd9.tar.gz
plus-45ba0e489cf85d957c26f1e5895399953c203cd9.tar.bz2
plus-45ba0e489cf85d957c26f1e5895399953c203cd9.tar.xz
plus-45ba0e489cf85d957c26f1e5895399953c203cd9.zip
update items amount in shop dialog after buy from vending shop.
Diffstat (limited to 'src/gui/windows/buydialog.cpp')
-rw-r--r--src/gui/windows/buydialog.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 068440c65..a71759840 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -471,16 +471,7 @@ void BuyDialog::action(const ActionEvent &event)
mAmountItems);
}
- // Update money and adjust the max number of items
- // that can be bought
- mMaxItems -= mAmountItems;
- setMoney(mMoney -
- mAmountItems * mShopItems->at(selectedItem)->getPrice());
-
- // Reset selection
- mAmountItems = 1;
- mSlider->setScale(1, mMaxItems);
- mSlider->setValue(1);
+ updateSlider(selectedItem);
}
else if (mNpcId == Nick)
{
@@ -492,6 +483,9 @@ void BuyDialog::action(const ActionEvent &event)
vendingHandler->buy(being,
item->getInvIndex(),
mAmountItems);
+ item->increaseQuantity(-mAmountItems);
+ item->update();
+ updateSlider(selectedItem);
}
}
else if (tradeWindow)
@@ -508,6 +502,19 @@ void BuyDialog::action(const ActionEvent &event)
}
}
+void BuyDialog::updateSlider(const int selectedItem)
+{
+ // Update money and adjust the max number of items
+ // that can be bought
+ mMaxItems -= mAmountItems;
+ setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem)->getPrice());
+
+ // Reset selection
+ mAmountItems = 1;
+ mSlider->setScale(1, mMaxItems);
+ mSlider->setValue(1);
+}
+
void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels