diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2006-11-05 00:28:55 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2006-11-05 00:28:55 +0000 |
commit | 502af71c74d0b1d5b123d424bc023fcce49916ec (patch) | |
tree | 43e6ec1fb1ab283b8cdd7f1c394bcfb7939c1861 /src/gui/buy.cpp | |
parent | 0c85783de45e334f9e116360fec0ae19dccab085 (diff) | |
download | mana-502af71c74d0b1d5b123d424bc023fcce49916ec.tar.gz mana-502af71c74d0b1d5b123d424bc023fcce49916ec.tar.bz2 mana-502af71c74d0b1d5b123d424bc023fcce49916ec.tar.xz mana-502af71c74d0b1d5b123d424bc023fcce49916ec.zip |
Added pictures to items in buy dialogs. Also too expensive items are highlighted in gray and can't be selected.
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index cad2e06f..0bf4c56d 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -26,14 +26,12 @@ #include <guichan/widgets/label.hpp> #include "button.h" -#include "listbox.h" #include "scrollarea.h" #include "shop.h" #include "slider.h" #include "../npc.h" -#include "../resources/iteminfo.h" #include "../resources/itemmanager.h" #include "../net/messageout.h" @@ -48,8 +46,8 @@ BuyDialog::BuyDialog(Network *network): { mShopItems = new ShopItems; - mItemList = new ListBox(mShopItems); - mScrollArea = new ScrollArea(mItemList); + mShopItemList = new ShopListBox(mShopItems, mShopItems); + mScrollArea = new ScrollArea(mShopItemList); mSlider = new Slider(1.0); mQuantityLabel = new gcn::Label("0"); mMoneyLabel = new gcn::Label("Price : 0 GP / 0 GP"); @@ -63,7 +61,7 @@ BuyDialog::BuyDialog(Network *network): setContentSize(260, 210); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); - mItemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); + mShopItemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); mSlider->setDimension(gcn::Rectangle(5, 120, 200, 10)); mSlider->setEnabled(false); @@ -87,11 +85,11 @@ BuyDialog::BuyDialog(Network *network): mItemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14)); mItemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14)); - mItemList->setEventId("item"); + mShopItemList->setEventId("item"); mSlider->setEventId("slider"); - mItemList->addActionListener(this); - mItemList->addSelectionListener(this); + mShopItemList->addActionListener(this); + mShopItemList->addSelectionListener(this); mSlider->addActionListener(this); add(mScrollArea); @@ -116,6 +114,7 @@ BuyDialog::~BuyDialog() void BuyDialog::setMoney(int amount) { mMoney = amount; + mShopItemList->setPlayersMoney(amount); mMoneyLabel->setCaption("Price : 0 GP / " + toString(mMoney) + " GP"); mMoneyLabel->adjustSize(); } @@ -128,7 +127,7 @@ void BuyDialog::reset() mAmountItems = 0; // Reset Previous Selected Items to prevent failing asserts - mItemList->setSelected(-1); + mShopItemList->setSelected(-1); mIncreaseButton->setEnabled(false); mDecreaseButton->setEnabled(false); mQuantityLabel->setCaption("0"); @@ -141,20 +140,13 @@ void BuyDialog::reset() void BuyDialog::addItem(short id, int price) { - ITEM_SHOP item_shop; - - item_shop.name = itemDb->getItemInfo(id).getName() + " " - + toString(price) + " GP"; - item_shop.price = price; - item_shop.id = id; - - mShopItems->push_back(item_shop); - mItemList->adjustSize(); + mShopItems->addItem(id, price); + mShopItemList->adjustSize(); } void BuyDialog::action(const std::string& eventId, gcn::Widget* widget) { - int selectedItem = mItemList->getSelected(); + int selectedItem = mShopItemList->getSelected(); if (eventId == "item") { @@ -172,7 +164,7 @@ void BuyDialog::action(const std::string& eventId, gcn::Widget* widget) // If no item was selected, none can be bought, otherwise // calculate how many the player can afford - mMaxItems = (mItemList->getSelected() == -1) ? 0 : + mMaxItems = (mShopItemList->getSelected() == -1) ? 0 : mMoney / mShopItems->at(selectedItem).price; // When at least one item can be bought, enable the slider and the @@ -187,7 +179,7 @@ void BuyDialog::action(const std::string& eventId, gcn::Widget* widget) } // The following actions require a valid selection - if (selectedItem < 0 || selectedItem >= int(mShopItems->size())) + if (selectedItem < 0 || selectedItem >= int(mShopItems->getNumberOfElements())) { return; } @@ -270,7 +262,7 @@ void BuyDialog::action(const std::string& eventId, gcn::Widget* widget) void BuyDialog::selectionChanged(const SelectionEvent &event) { - int selectedItem = mItemList->getSelected(); + int selectedItem = mShopItemList->getSelected(); if (selectedItem > -1) { |