diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-06-12 09:06:01 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-06-12 09:06:01 +0000 |
commit | 2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258 (patch) | |
tree | 8d256ac1a38932aaf0db7b55ed178e4212616555 /src/gui/shop.cpp | |
parent | eb019ab915998a3ec247b33dad4b23f763d7a29a (diff) | |
download | mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.gz mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.bz2 mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.xz mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.zip |
Merged revisions 3738 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk
........
r3738 | b_lindeijer | 2007-11-16 00:44:01 +0100 (Fri, 16 Nov 2007) | 3 lines
Moved item icon from ItemInfo class to the Item class, so that it can be loaded
on demand. Results in faster startup time and reduced memory usage.
........
Diffstat (limited to 'src/gui/shop.cpp')
-rw-r--r-- | src/gui/shop.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index 3d972bc2..ff6e3d68 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -22,8 +22,8 @@ */ #include "shop.h" -#include "../utils/tostring.h" -#include "../resources/itemdb.h" + +#include "../utils/dtor.h" ShopItems::~ShopItems() { @@ -32,43 +32,38 @@ ShopItems::~ShopItems() int ShopItems::getNumberOfElements() { - return mItemsShop.size(); + return mShopItems.size(); } std::string ShopItems::getElementAt(int i) { - return mItemsShop.at(i).name; + return mShopItems.at(i)->getDisplayName(); } -void ShopItems::addItem(short id, int price) +void ShopItems::addItem(int inventoryIndex, short id, int amount, int price) { - ITEM_SHOP item_shop; - - item_shop.name = ItemDB::get(id).getName() - + " (" + toString(price) + " GP)"; - item_shop.price = price; - item_shop.id = id; - item_shop.image = ItemDB::get(id).getImage(); - - mItemsShop.push_back(item_shop); + ShopItem *item = new ShopItem(id, amount, price); + item->setInvIndex(inventoryIndex); + mShopItems.push_back(item); } -ITEM_SHOP ShopItems::at(int i) +void ShopItems::addItem(short id, int price) { - return mItemsShop.at(i); + mShopItems.push_back(new ShopItem(id, 0, price)); } -void ShopItems::push_back(ITEM_SHOP item_shop) +ShopItem* ShopItems::at(int i) const { - mItemsShop.push_back(item_shop); + return mShopItems.at(i); } void ShopItems::clear() { - mItemsShop.clear(); + std::for_each(mShopItems.begin(), mShopItems.end(), make_dtor(mShopItems)); + mShopItems.clear(); } -std::vector<ITEM_SHOP>* ShopItems::getShop() +std::vector<ShopItem*>* ShopItems::getShop() { - return &mItemsShop; + return &mShopItems; } |