summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-03 23:13:07 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-03 23:13:07 +0200
commit9437d4943a8b299b057020ee114b230399965abd (patch)
tree54e8d1bca3c2f5457db8402fcdfe1b9e04df54f7 /src/gui
parentbb73cadd0afdc9fa55ea66ecedd8be53a6f3198e (diff)
downloadplus-9437d4943a8b299b057020ee114b230399965abd.tar.gz
plus-9437d4943a8b299b057020ee114b230399965abd.tar.bz2
plus-9437d4943a8b299b057020ee114b230399965abd.tar.xz
plus-9437d4943a8b299b057020ee114b230399965abd.zip
Add colors to buy/sell dialogs.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp9
-rw-r--r--src/gui/buy.h2
-rw-r--r--src/gui/sell.cpp6
-rw-r--r--src/gui/sell.h2
-rw-r--r--src/gui/shopwindow.cpp19
-rw-r--r--src/gui/widgets/shopitems.cpp21
-rw-r--r--src/gui/widgets/shopitems.h9
7 files changed, 37 insertions, 31 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 45bc051fb..c413fdffc 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -159,9 +159,9 @@ void BuyDialog::reset()
setMoney(0);
}
-void BuyDialog::addItem(int id, int amount, int price)
+void BuyDialog::addItem(int id, unsigned char color, int amount, int price)
{
- mShopItems->addItem(id, amount, price);
+ mShopItems->addItem(id, color, amount, price);
mShopItemList->adjustSize();
}
@@ -213,8 +213,9 @@ void BuyDialog::action(const gcn::ActionEvent &event)
{
if (mNpcId != -1)
{
- Net::getNpcHandler()->buyItem(mNpcId,
- mShopItems->at(selectedItem)->getId(), mAmountItems);
+ ShopItem *item = mShopItems->at(selectedItem);
+ Net::getNpcHandler()->buyItem(mNpcId, item->getId(),
+ item->getColor(), mAmountItems);
// Update money and adjust the max number of items that can be bought
mMaxItems -= mAmountItems;
diff --git a/src/gui/buy.h b/src/gui/buy.h
index edbe1bf98..c9d412645 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -81,7 +81,7 @@ class BuyDialog : public Window, public gcn::ActionListener,
/**
* Adds an item to the shop inventory.
*/
- void addItem(int id, int amount, int price);
+ void addItem(int id, unsigned char color, int amount, int price);
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 5b05c6865..de1da395c 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -152,14 +152,14 @@ void SellDialog::addItem(const Item *item, int price)
return;
mShopItems->addItem2(item->getInvIndex(), item->getId(),
- item->getQuantity(), price);
+ item->getColor(), item->getQuantity(), price);
mShopItemList->adjustSize();
}
-void SellDialog::addItem(int id, int amount, int price)
+void SellDialog::addItem(int id, unsigned char color, int amount, int price)
{
- mShopItems->addItem(id, amount, price);
+ mShopItems->addItem(id, color, amount, price);
mShopItemList->adjustSize();
}
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 7ab454630..86343a953 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -99,7 +99,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
*/
void setVisible(bool visible);
- void addItem(int id, int amount, int price);
+ void addItem(int id, unsigned char color, int amount, int price);
/**
* Returns true if any instances exist.
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 99a9a6a61..43e05aa70 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -278,7 +278,7 @@ void ShopWindow::addBuyItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
- mBuyShopItems->addItemNoDup(item->getId(), amount, price);
+ mBuyShopItems->addItemNoDup(item->getId(), item->getColor(), amount, price);
updateButtonsAndLabels();
}
@@ -286,7 +286,7 @@ void ShopWindow::addSellItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
- mSellShopItems->addItemNoDup(item->getId(), amount, price);
+ mSellShopItems->addItemNoDup(item->getId(), item->getColor(), amount, price);
updateButtonsAndLabels();
}
@@ -323,15 +323,16 @@ void ShopWindow::loadList()
if (tokens.size() == 5 && tokens[0])
{
+ //+++ need impliment colors?
if (tokens[1] && tokens[2] && mBuyShopItems)
{
mBuyShopItems->addItem(
- tokens[0], tokens[1], tokens[2]);
+ tokens[0], 1, tokens[1], tokens[2]);
}
if (tokens[3] && tokens[4] && mSellShopItems)
{
mSellShopItems->addItem(
- tokens[0], tokens[3], tokens[4]);
+ tokens[0], 1, tokens[3], tokens[4]);
}
}
}
@@ -599,8 +600,9 @@ void ShopWindow::showList(const std::string &nick, std::string data)
int id = decodeStr(data.substr(f, 2));
int price = decodeStr(data.substr(f + 2, 4));
int amount = decodeStr(data.substr(f + 6, 3));
+ //+++ need impliment colors?
if (buyDialog && amount > 0)
- buyDialog->addItem(id, amount, price);
+ buyDialog->addItem(id, 1, amount, price);
if (sellDialog)
{
Item *item = inv->findItem(id);
@@ -609,9 +611,9 @@ void ShopWindow::showList(const std::string &nick, std::string data)
if (item->getQuantity() < amount)
amount = item->getQuantity();
if (amount > 0)
- sellDialog->addItem(id, amount, price);
+ sellDialog->addItem(id, 1, amount, price);
else
- sellDialog->addItem(id, -1, price);
+ sellDialog->addItem(id, 1, -1, price);
}
}
}
@@ -670,7 +672,8 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
amount = atoi(part3.c_str());
delete mTradeItem;
- mTradeItem = new ShopItem(-1, id, amount, price);
+ //+++ need impliment colors?
+ mTradeItem = new ShopItem(-1, id, 1, amount, price);
if (mode == BUY)
{
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;
diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h
index 949dcfc78..2b2dcc5eb 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/widgets/shopitems.h
@@ -55,7 +55,7 @@ class ShopItems : public gcn::ListModel
/**
* Adds an item to the list.
*/
- void addItem(int id, int amount, int price);
+ void addItem(int id, unsigned char color, int amount, int price);
/**
* Adds an item to the list (used by sell dialog). Looks for
@@ -66,9 +66,10 @@ class ShopItems : public gcn::ListModel
* @param quantity number of available copies of the item
* @param price price of the item
*/
- void addItem2(int inventoryIndex, int id, int amount, int price);
+ void addItem2(int inventoryIndex, int id, unsigned char color,
+ int amount, int price);
- void addItemNoDup(int id, int amount, int price);
+ void addItemNoDup(int id, unsigned char color, int amount, int price);
/**
* Returns the number of items in the shop.
@@ -109,7 +110,7 @@ class ShopItems : public gcn::ListModel
*
* @return the item found or 0
*/
- ShopItem *findItem(int id);
+ ShopItem *findItem(int id, unsigned char color);
/** The list of items in the shop. */
std::vector<ShopItem*> mShopItems;