From efbf5fa72206086a7563ccfeddd601d324c7912f Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Tue, 31 Jan 2006 03:07:31 +0000 Subject: Created a ListModel for ShopItems. --- src/gui/sell.h | 25 ++++++++----------------- src/gui/shop.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gui/sell.h b/src/gui/sell.h index 1a5fabf5..86caff55 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -24,10 +24,7 @@ #ifndef _TMW_SELL_H #define _TMW_SELL_H -#include - #include -#include #include "window.h" @@ -35,16 +32,15 @@ class Item; class Network; +class ShopItems; -struct ITEM_SHOP; /** * The sell dialog. * * \ingroup Interface */ -class SellDialog : public Window, public gcn::ActionListener, - public gcn::ListModel +class SellDialog : public Window, public gcn::ActionListener { public: /** @@ -54,6 +50,11 @@ class SellDialog : public Window, public gcn::ActionListener, */ SellDialog(Network *network); + /** + * Destructor + */ + virtual ~SellDialog(); + /** * Resets the dialog, clearing inventory. */ @@ -69,21 +70,11 @@ class SellDialog : public Window, public gcn::ActionListener, */ void action(const std::string& eventId); - /** - * Returns the number of items in the inventory. - */ - int getNumberOfElements(); - /** * Mouse callback */ void mouseClick(int x, int y, int buton, int count); - /** - * Returns the name of item number i in the inventory. - */ - std::string getElementAt(int i); - private: Network *mNetwork; gcn::Button *sellButton; @@ -98,7 +89,7 @@ class SellDialog : public Window, public gcn::ActionListener, gcn::Label *quantityLabel; gcn::Slider *slider; - std::vector shopInventory; + ShopItems *mShopItems; int m_maxItems; int m_amountItems; diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index 1dd498a8..3706cdf8 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -23,3 +23,12 @@ #include "shop.h" +int ShopItems::getNumberOfElements() +{ + return size(); +} + +std::string ShopItems::getElementAt(int i) +{ + return at(i).name; +} -- cgit v1.2.3-70-g09d2