summaryrefslogtreecommitdiff
path: root/src/gui/shop.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-15 23:44:01 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-15 23:44:01 +0000
commit0e925e97554aae573e895afa4e3d8450f01df342 (patch)
treebbc30319410aecb9fec7c005e667cd7fb628bb17 /src/gui/shop.cpp
parentffa0fae492d954c0aed35a0acbd7b856778d7328 (diff)
downloadmana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.gz
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.bz2
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.xz
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.zip
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.cpp35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index e2fd54f2..1731ae4c 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,45 +32,36 @@ 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(int id, int amount, int price)
{
- ITEM_SHOP item_shop;
- ItemInfo const &item = ItemDB::get(id);
-
- item_shop.name = item.getName()
- + " (" + toString(price) + " GP)";
- item_shop.price = price;
- item_shop.id = id;
- item_shop.quantity = amount;
- item_shop.image = item.getImage();
-
- mItemsShop.push_back(item_shop);
+ mShopItems.push_back(new ShopItem(id, amount, price));
}
-ITEM_SHOP ShopItems::at(int i)
+void ShopItems::addItem(ShopItem* shopItem)
{
- return mItemsShop.at(i);
+ mShopItems.push_back(shopItem);
}
-void ShopItems::push_back(ITEM_SHOP item_shop)
+ShopItem* ShopItems::at(int i)
{
- 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;
}