diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 16 | ||||
-rw-r--r-- | src/gui/buy.h | 2 | ||||
-rw-r--r-- | src/gui/shoplistbox.cpp | 20 |
3 files changed, 10 insertions, 28 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); } } diff --git a/src/gui/buy.h b/src/gui/buy.h index d8016216..5ee7ab95 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -28,12 +28,12 @@ #include "window.h" #include "selectionlistener.h" -#include "shoplistbox.h" #include "../guichanfwd.h" class Network; class ShopItems; +class ShopListBox; class ListBox; /** diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 946f518b..4efd6e64 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -129,24 +129,8 @@ void ShopListBox::mousePressed(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { - bool enoughMoney = false; - int y = event.getY(); - - if (mShopItems && mPriceCheck) - { - if (mPlayerMoney >= mShopItems->at(y / mRowHeight).price) - enoughMoney = true; - } - else // Old Behaviour - { - enoughMoney = true; - } - - if (enoughMoney) - { - setSelected(y / mRowHeight); - generateAction(); - } + setSelected(event.getY() / mRowHeight); + generateAction(); } } |