From 4e97da8e138b21a5f5bea75e6a8d3211e4f28594 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 24 Mar 2016 23:29:04 +0300 Subject: Add enum for item types. --- src/gui/windows/buydialog.cpp | 8 ++++++-- src/gui/windows/buydialog.h | 4 +++- src/gui/windows/inventorywindow.cpp | 3 +-- src/gui/windows/itemamountwindow.cpp | 5 ++++- src/gui/windows/shopwindow.cpp | 29 ++++++++++++++++++++++++----- src/gui/windows/tradewindow.cpp | 4 ++-- src/gui/windows/tradewindow.h | 9 ++++++--- 7 files changed, 46 insertions(+), 16 deletions(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index b0cf5bc8c..fa7297bdd 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -390,12 +390,16 @@ void BuyDialog::reset() } ShopItem *BuyDialog::addItem(const int id, - const int type, + const ItemTypeT type, const ItemColor color, const int amount, const int price) { - ShopItem *const item = mShopItems->addItem(id, type, color, amount, price); + ShopItem *const item = mShopItems->addItem(id, + type, + color, + amount, + price); mShopItemList->adjustSize(); return item; } diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 3249eae2a..77d5c357f 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_BUYDIALOG_H #define GUI_WINDOWS_BUYDIALOG_H +#include "enums/resources/itemtype.h" + #include "enums/simpletypes/beingid.h" #include "enums/simpletypes/itemcolor.h" @@ -105,7 +107,7 @@ class BuyDialog final : public Window, * Adds an item to the shop inventory. */ ShopItem *addItem(const int id, - const int type, + const ItemTypeT type, const ItemColor color, const int amount, const int price); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 5485bd98a..db256b4a1 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -1047,8 +1047,7 @@ void InventoryWindow::combineItems(const int index1, if (!item2) return; - // IT_CARD - if (item1->getType() != 6) + if (item1->getType() != ItemType::Card) { const Item *tmpItem = item1; item1 = item2; diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 8ad79ecab..02c94931e 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -388,7 +388,10 @@ void ItemAmountWindow::action(const ActionEvent &event) const int id = ItemDB::get(mItemsModal->getElementAt( mItemDropDown->getSelected())).getId(); - mItem = new Item(id, 0, 10000, 0, + mItem = new Item(id, + ItemType::Unknown, + 10000, + 0, ItemColor_one, Identified_true, Damaged_true, diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 679bbc47f..eb07c90dc 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -562,12 +562,20 @@ void ShopWindow::loadList() if (tokens[1] && tokens[2]) { mBuyShopItems->addItem( - tokens[0], 0, ItemColor_one, tokens[1], tokens[2]); + tokens[0], + ItemType::Unknown, + ItemColor_one, + tokens[1], + tokens[2]); } if (tokens[3] && tokens[4]) { mSellShopItems->addItem( - tokens[0], 0, ItemColor_one, tokens[3], tokens[4]); + tokens[0], + ItemType::Unknown, + ItemColor_one, + tokens[3], + tokens[4]); } } } @@ -855,7 +863,13 @@ 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, 0, ItemColor_one, amount, price); + { + buyDialog->addItem(id, + ItemType::Unknown, + ItemColor_one, + amount, + price); + } if (sellDialog) { // +++ need support for colors @@ -870,7 +884,7 @@ void ShopWindow::showList(const std::string &nick, std::string data) amount = 0; } ShopItem *const shopItem = sellDialog->addItem(id, - 0, + ItemType::Unknown, ItemColor_one, amount, price); @@ -940,7 +954,12 @@ void ShopWindow::processRequest(const std::string &nick, std::string data, delete mTradeItem; // +++ need impliment colors? - mTradeItem = new ShopItem(-1, id, 0, ItemColor_one, amount, price); + mTradeItem = new ShopItem(-1, + id, + ItemType::Unknown, + ItemColor_one, + amount, + price); if (mode == BUY) { diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index fe0ca85f1..e251b0bd9 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -195,7 +195,7 @@ void TradeWindow::setMoney(const int amount) } void TradeWindow::addItem(const int id, - const int type, + const ItemTypeT type, const bool own, const int quantity, const uint8_t refine, @@ -218,7 +218,7 @@ void TradeWindow::addItem(const int id, } void TradeWindow::addItem2(const int id, - const int type, + const ItemTypeT type, const int *const cards, const int sz, const bool own, diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 98b18ba7e..f8a280a20 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -25,6 +25,8 @@ #include "gui/widgets/window.h" +#include "enums/resources/itemtype.h" + #include "enums/simpletypes/damaged.h" #include "enums/simpletypes/equipm.h" #include "enums/simpletypes/favorite.h" @@ -72,7 +74,7 @@ class TradeWindow final : public Window, * Add an item to the trade window. */ void addItem(const int id, - const int type, + const ItemTypeT type, const bool own, const int quantity, const uint8_t refine, @@ -90,7 +92,7 @@ class TradeWindow final : public Window, * Add an item to the trade window. */ void addItem2(const int id, - const int type, + const ItemTypeT type, const int *const cards, const int sz, const bool own, @@ -122,7 +124,8 @@ class TradeWindow final : public Window, /** * Send trade packet. */ - void tradeItem(const Item *const item, const int quantity, + void tradeItem(const Item *const item, + const int quantity, const bool check = false) const; /** -- cgit v1.2.3-60-g2f50