summaryrefslogtreecommitdiff
path: root/src/gui/buy.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-12 08:15:45 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-12 08:15:45 +0000
commit1afcf2608c0a466d2df21faea1530955cc8061fc (patch)
tree27f279ca5d012ddd3f805d531e093a2561c15abe /src/gui/buy.cpp
parente5038965dbea0dbc7269c4114cbdaddd6899c665 (diff)
downloadMana-1afcf2608c0a466d2df21faea1530955cc8061fc.tar.gz
Mana-1afcf2608c0a466d2df21faea1530955cc8061fc.tar.bz2
Mana-1afcf2608c0a466d2df21faea1530955cc8061fc.tar.xz
Mana-1afcf2608c0a466d2df21faea1530955cc8061fc.zip
Allowed selection of items that cannot be afforded, so that their descriptions
are still accessible. Also made sure the player's money value of ShopItemList gets updated.
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r--src/gui/buy.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 3c7cbd51..3516129b 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -28,6 +28,7 @@
#include "button.h"
#include "scrollarea.h"
#include "shop.h"
+#include "shoplistbox.h"
#include "slider.h"
#include "../npc.h"
@@ -111,13 +112,12 @@ void BuyDialog::reset()
{
mShopItems->clear();
mShopItemList->adjustSize();
- mMoney = 0;
- mSlider->setValue(0);
- // Reset Previous Selected Items to prevent failing asserts
+ // Reset previous selected items to prevent failing asserts
mShopItemList->setSelected(-1);
+ mSlider->setValue(0);
- updateButtonsAndLabels();
+ setMoney(0);
}
void BuyDialog::addItem(short id, int price)
@@ -173,16 +173,14 @@ void BuyDialog::action(const gcn::ActionEvent &event)
outMsg.writeInt16(mAmountItems);
outMsg.writeInt16(mShopItems->at(selectedItem).id);
- // Update money and adjust the max number of items that can be bought
- mMoney -= mAmountItems * mShopItems->at(selectedItem).price;
- mMaxItems -= mAmountItems;
-
// Reset selection
mAmountItems = 1;
mSlider->setValue(1);
mSlider->gcn::Slider::setScale(1, mMaxItems);
- updateButtonsAndLabels();
+ // Update money and adjust the max number of items that can be bought
+ mMaxItems -= mAmountItems;
+ setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem).price);
}
}