From 9be90b76adb1518c4ffe0e365a18c5afcc3158f2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 Dec 2014 01:27:45 +0300 Subject: Add item type to item object. --- src/gui/windows/buydialog.cpp | 9 ++++++--- src/gui/windows/buydialog.h | 7 +++++-- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/npcdialog.cpp | 3 ++- src/gui/windows/shopwindow.cpp | 22 ++++++++++++++-------- src/gui/windows/tradewindow.cpp | 6 ++++-- src/gui/windows/tradewindow.h | 2 ++ 7 files changed, 34 insertions(+), 17 deletions(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 61b5d7233..4340a671f 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -335,10 +335,13 @@ void BuyDialog::reset() setMoney(0); } -void BuyDialog::addItem(const int id, const unsigned char color, - const int amount, const int price) +void BuyDialog::addItem(const int id, + const int type, + const unsigned char color, + const int amount, + const int price) { - mShopItems->addItem(id, color, amount, price); + mShopItems->addItem(id, type, color, amount, price); mShopItemList->adjustSize(); } diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 02862187c..af63432f7 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -91,8 +91,11 @@ class BuyDialog final : public Window, /** * Adds an item to the shop inventory. */ - void addItem(const int id, const unsigned char color, - const int amount, const int price); + void addItem(const int id, + const int type, + const unsigned char color, + const int amount, + const int price); /** * Called when receiving actions from the widgets. diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 6eb51de98..548baa01d 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -319,7 +319,7 @@ void ItemAmountWindow::action(const ActionEvent &event) const int id = ItemDB::get(mItemsModal->getElementAt( mItemDropDown->getSelected())).getId(); - mItem = new Item(id, 10000, 0, 1, true, false, false, false, false); + mItem = new Item(id, 0, 10000, 0, 1, true, false, false, false, false); if (mUsage == ShopBuyAdd) mMax = 10000; diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 71290ef22..c99a4898d 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -468,7 +468,8 @@ void NpcDialog::action(const ActionEvent &event) const Item *const item = inventoryWindow->getSelectedItem(); if (item) { - mInventory->addItem(item->getId(), 1, 1, item->getColor(), + mInventory->addItem(item->getId(), item->getType(), + 1, 1, item->getColor(), item->getIdentified(), item->getDamaged(), item->getFavorite(), false, false); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index d72dab6b8..534218601 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -328,7 +328,10 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount, return; const bool emp = isShopEmpty(); mBuyShopItems->addItemNoDup(item->getId(), - item->getColor(), amount, price); + item->getType(), + item->getColor(), + amount, + price); if (emp && localPlayer) localPlayer->updateStatus(); @@ -342,7 +345,10 @@ void ShopWindow::addSellItem(const Item *const item, const int amount, return; const bool emp = isShopEmpty(); mSellShopItems->addItemNoDup(item->getId(), - item->getColor(), amount, price); + item->getType(), + item->getColor(), + amount, + price); if (emp && localPlayer) localPlayer->updateStatus(); @@ -390,12 +396,12 @@ void ShopWindow::loadList() if (tokens[1] && tokens[2] && mBuyShopItems) { mBuyShopItems->addItem( - tokens[0], 1, tokens[1], tokens[2]); + tokens[0], 0, 1, tokens[1], tokens[2]); } if (tokens[3] && tokens[4] && mSellShopItems) { mSellShopItems->addItem( - tokens[0], 1, tokens[3], tokens[4]); + tokens[0], 0, 1, tokens[3], tokens[4]); } } } @@ -663,7 +669,7 @@ void ShopWindow::showList(const std::string &nick, std::string data) int amount = decodeStr(data.substr(f + 6, 3)); // +++ need impliment colors? if (buyDialog && amount > 0) - buyDialog->addItem(id, 1, amount, price); + buyDialog->addItem(id, 0, 1, amount, price); if (sellDialog) { // +++ need support for colors @@ -673,9 +679,9 @@ void ShopWindow::showList(const std::string &nick, std::string data) if (item->getQuantity() < amount) amount = item->getQuantity(); if (amount > 0) - sellDialog->addItem(id, 1, amount, price); + sellDialog->addItem(id, 0, 1, amount, price); else - sellDialog->addItem(id, 1, -1, price); + sellDialog->addItem(id, 0, 1, -1, price); } } } @@ -736,7 +742,7 @@ void ShopWindow::processRequest(const std::string &nick, std::string data, delete mTradeItem; // +++ need impliment colors? - mTradeItem = new ShopItem(-1, id, 1, amount, price); + mTradeItem = new ShopItem(-1, id, 0, 1, amount, price); if (mode == BUY) { diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index c7cd1712d..ba1285366 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -191,6 +191,7 @@ void TradeWindow::setMoney(const int amount) } void TradeWindow::addItem(const int id, + const int type, const bool own, const int quantity, const uint8_t refine, @@ -200,11 +201,12 @@ void TradeWindow::addItem(const int id, const bool favorite) const { Inventory *inv = own ? mMyInventory.get() : mPartnerInventory.get(); - inv->addItem(id, quantity, refine, color, + inv->addItem(id, type, quantity, refine, color, identified, damaged, favorite, false, false); } void TradeWindow::addItem2(const int id, + const int type, const int *const cards, const int sz, const bool own, @@ -217,7 +219,7 @@ void TradeWindow::addItem2(const int id, const bool equipment) const { Inventory *inv = own ? mMyInventory.get() : mPartnerInventory.get(); - const int slot = inv->addItem(id, quantity, refine, color, + const int slot = inv->addItem(id, type, quantity, refine, color, identified, damaged, favorite, equipment, false); if (slot >= 0) inv->setCards(slot, cards, sz); diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 5c782cf07..9dcfe91c1 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -68,6 +68,7 @@ class TradeWindow final : public Window, * Add an item to the trade window. */ void addItem(const int id, + const int type, const bool own, const int quantity, const uint8_t refine, @@ -85,6 +86,7 @@ class TradeWindow final : public Window, * Add an item to the trade window. */ void addItem2(const int id, + const int type, const int *const cards, const int sz, const bool own, -- cgit v1.2.3-70-g09d2