From 9437d4943a8b299b057020ee114b230399965abd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 3 Mar 2011 23:13:07 +0200 Subject: Add colors to buy/sell dialogs. --- src/gui/widgets/shopitems.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/gui/widgets/shopitems.cpp') diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 3e46f51a4..c0b93508e 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -49,23 +49,24 @@ std::string ShopItems::getElementAt(int i) return mShopItems.at(i)->getDisplayName(); } -void ShopItems::addItem(int id, int amount, int price) +void ShopItems::addItem(int id, unsigned char color, int amount, int price) { - mShopItems.push_back(new ShopItem(-1, id, amount, price)); + mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); } -void ShopItems::addItemNoDup(int id, int amount, int price) +void ShopItems::addItemNoDup(int id, unsigned char color, int amount, int price) { - ShopItem *item = findItem(id); + ShopItem *item = findItem(id, color); if (!item) - mShopItems.push_back(new ShopItem(-1, id, amount, price)); + mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); } -void ShopItems::addItem2(int inventoryIndex, int id, int quantity, int price) +void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color, + int quantity, int price) { ShopItem *item = 0; if (mMergeDuplicates) - item = findItem(id); + item = findItem(id, color); if (item) { @@ -73,7 +74,7 @@ void ShopItems::addItem2(int inventoryIndex, int id, int quantity, int price) } else { - item = new ShopItem(inventoryIndex, id, quantity, price); + item = new ShopItem(inventoryIndex, id, color, quantity, price); mShopItems.push_back(item); } } @@ -100,7 +101,7 @@ void ShopItems::clear() mShopItems.clear(); } -ShopItem *ShopItems::findItem(int id) +ShopItem *ShopItems::findItem(int id, unsigned char color) { ShopItem *item; @@ -109,7 +110,7 @@ ShopItem *ShopItems::findItem(int id) while (it != e) { item = *(it); - if (item->getId() == id) + if (item->getId() == id && item->getColor() == color) return item; ++it; -- cgit v1.2.3-70-g09d2