From 0875a6ddfda9ece1af4a818e38be1f99e578c59a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Oct 2014 14:40:14 +0300 Subject: Add to item field favorite. --- src/beingequipbackend.cpp | 3 ++- src/gui/widgets/itemcontainer.cpp | 4 +++- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/npcdialog.cpp | 4 +++- src/gui/windows/tradewindow.cpp | 12 +++++++----- src/gui/windows/tradewindow.h | 4 +++- src/inventory.cpp | 7 +++++-- src/inventory.h | 2 ++ src/item.cpp | 3 ++- src/item.h | 7 +++++++ src/net/ea/inventoryhandler.cpp | 1 + src/net/ea/inventoryitem.h | 3 +++ src/net/eathena/inventoryhandler.cpp | 16 ++++++++++------ src/net/eathena/tradehandler.cpp | 2 +- src/net/tmwa/inventoryhandler.cpp | 26 ++++++++++++++------------ src/net/tmwa/tradehandler.cpp | 6 +++--- src/shopitem.cpp | 4 ++-- 17 files changed, 69 insertions(+), 37 deletions(-) diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp index 280159b99..344b36856 100644 --- a/src/beingequipbackend.cpp +++ b/src/beingequipbackend.cpp @@ -43,7 +43,8 @@ BeingEquipBackend::BeingEquipBackend(Being *const being) if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE) { mEquipment[idx] = new Item(id, 1, 0, - being->mSpriteColorsIds[f], true, false, true, true); + being->mSpriteColorsIds[f], + true, false, false, true, true); } } } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 87c599fb6..732e9e738 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -553,7 +553,9 @@ void ItemContainer::mouseReleased(MouseEvent &event) if (item && !PlayerInfo::isItemProtected(item->getId())) { mInventory->addItem(item->getId(), 1, 1, item->getColor(), - item->getIdentified(), item->getDamaged(), false, false); + item->getIdentified(), item->getDamaged(), + item->getFavorite(), + false, false); } return; } diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index c301e14ee..6eb51de98 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); + mItem = new Item(id, 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 5360489cb..e547e9abd 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -468,7 +468,9 @@ void NpcDialog::action(const ActionEvent &event) if (item) { mInventory->addItem(item->getId(), 1, 1, item->getColor(), - item->getIdentified(), item->getDamaged(), false, false); + item->getIdentified(), item->getDamaged(), + item->getFavorite(), + false, false); } } } diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 0ffbcd34a..6bf091625 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -196,17 +196,18 @@ void TradeWindow::addItem(const int id, const uint8_t refine, const unsigned char color, const bool identified, - const bool damaged) const + const bool damaged, + const bool favorite) const { if (own) { mMyInventory->addItem(id, quantity, refine, color, - identified, damaged, false, false); + identified, damaged, favorite, false, false); } else { mPartnerInventory->addItem(id, quantity, refine, color, - identified, damaged, false, false); + identified, damaged, favorite, false, false); } } @@ -217,17 +218,18 @@ void TradeWindow::addItem2(const int id, const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment) const { if (own) { mMyInventory->addItem(id, quantity, refine, color, - identified, damaged, equipment, false); + identified, damaged, favorite, equipment, false); } else { mPartnerInventory->addItem(id, quantity, refine, color, - identified, damaged, equipment, false); + identified, damaged, favorite, equipment, false); } } diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 2efe5cde7..8f8067902 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -73,7 +73,8 @@ class TradeWindow final : public Window, const uint8_t refine, const unsigned char color, const bool identified, - const bool damaged) const; + const bool damaged, + const bool favorite) const; /** * Reset both item containers @@ -90,6 +91,7 @@ class TradeWindow final : public Window, const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment) const; /** diff --git a/src/inventory.cpp b/src/inventory.cpp index 91a3a9b29..dfa201cdf 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -109,11 +109,12 @@ void Inventory::addItem(const int id, const uint8_t color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped) { setItem(getFreeSlot(), id, quantity, refine, color, - identified, damaged, equipment, equipped); + identified, damaged, favorite, equipment, equipped); } void Inventory::setItem(const int index, @@ -123,6 +124,7 @@ void Inventory::setItem(const int index, const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped) { @@ -136,7 +138,7 @@ void Inventory::setItem(const int index, if (!item1 && id > 0) { Item *const item = new Item(id, quantity, refine, color, - identified, damaged, equipment, equipped); + identified, damaged, favorite, equipment, equipped); item->setInvIndex(index); mItems[index] = item; mUsed++; @@ -150,6 +152,7 @@ void Inventory::setItem(const int index, item1->setEquipment(equipment); item1->setIdentified(identified); item1->setDamaged(damaged); + item1->setFavorite(favorite); } else if (item1) { diff --git a/src/inventory.h b/src/inventory.h index f4ee38324..be0f0aca9 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -93,6 +93,7 @@ class Inventory final const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped); @@ -106,6 +107,7 @@ class Inventory final const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped); diff --git a/src/item.cpp b/src/item.cpp index 2d4183a8b..1dcd2bbcc 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -43,6 +43,7 @@ Item::Item(const int id, const unsigned char color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped) : mId(0), @@ -58,7 +59,7 @@ Item::Item(const int id, mInEquipment(false), mIdentified(identified), mDamaged(damaged), - mFavorite(false) + mFavorite(favorite) { setId(id, color); } diff --git a/src/item.h b/src/item.h index b7ef7534b..842e0d79b 100644 --- a/src/item.h +++ b/src/item.h @@ -46,6 +46,7 @@ class Item notfinal const uint8_t color, const bool identified, const bool damaged, + const bool favorite, const bool equipment, const bool equipped); @@ -182,6 +183,12 @@ class Item notfinal bool getDamaged() const A_WARN_UNUSED { return mDamaged; } + void setFavorite(const bool b) + { mFavorite = b; } + + bool getFavorite() const A_WARN_UNUSED + { return mFavorite; } + int mId; /**< Item type id. */ unsigned char mColor; int mQuantity; /**< Number of items. */ diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index e43e0de9c..8bf795deb 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -285,6 +285,7 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg) (*it).color, (*it).identified, (*it).damaged, + (*it).favorite, (*it).equip, false); } diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h index 19d9135f9..c0f5e15a1 100644 --- a/src/net/ea/inventoryitem.h +++ b/src/net/ea/inventoryitem.h @@ -47,6 +47,7 @@ class InventoryItem final unsigned char color; bool identified; bool damaged; + bool favorite; bool equip; InventoryItem(const int slot0, @@ -56,6 +57,7 @@ class InventoryItem final const unsigned char color0, const bool identified0, const bool damaged0, + const bool favorite0, const bool equip0) : slot(slot0), id(id0), @@ -64,6 +66,7 @@ class InventoryItem final color(color0), identified(identified0), damaged(damaged0), + favorite(favorite0), equip(equip0) { } diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 4189dde81..fcdeb68c3 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -326,7 +326,9 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) if (inventory) { inventory->setItem(index, itemId, 1, refine, - 1, flags.bits.isIdentified, flags.bits.isDamaged, true, false); + 1, flags.bits.isIdentified, flags.bits.isDamaged, + flags.bits.isFavorite, + true, false); } if (equipType) @@ -422,7 +424,8 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) amount += item->getQuantity(); inventory->setItem(index, itemId, amount, refine, - 1, identified != 0, damaged != 0, equipType != 0, false); + 1, identified != 0, damaged != 0, false, + equipType != 0, false); } ArrowsListener::distributeEvent(); } @@ -467,7 +470,8 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) { inventory->setItem(index, itemId, amount, 0, 1, flags.bits.isIdentified, - flags.bits.isDamaged, false, false); + flags.bits.isDamaged, flags.bits.isFavorite, + false, false); } } BLOCK_END("InventoryHandler::processPlayerInventory") @@ -500,7 +504,7 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) mInventoryItems.push_back(Ea::InventoryItem(index, itemId, amount, 0, 1, flags.bits.isIdentified, - flags.bits.isDamaged, false)); + flags.bits.isDamaged, flags.bits.isFavorite, false)); } BLOCK_END("InventoryHandler::processPlayerInventory") } @@ -599,7 +603,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) mInventoryItems.push_back(Ea::InventoryItem(index, itemId, amount, refine, 1, flags.bits.isIdentified, - flags.bits.isDamaged, false)); + flags.bits.isDamaged, flags.bits.isFavorite, false)); } BLOCK_END("InventoryHandler::processPlayerStorageEquip") } @@ -630,7 +634,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) if (mStorage) { mStorage->setItem(index, itemId, amount, - refine, 1, identified != 0, false, false, false); + refine, 1, identified != 0, false, false, false, false); } } BLOCK_END("InventoryHandler::processPlayerStorageAdd") diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index e992ee497..45310761f 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/tradehandler.cpp @@ -201,7 +201,7 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) else { tradeWindow->addItem2(type, false, amount, - refine, 1, identify != 0, false, false); + refine, 1, identify != 0, false, false, false); } } } diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 6685efd7c..645da2da7 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -271,12 +271,12 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { inventory->setItem(index, itemId, 1, refine, - identified, true, false, true, false); + identified, true, false, false, true, false); } else { inventory->setItem(index, itemId, 1, refine, - 1, identified != 0, false, true, false); + 1, identified != 0, false, false, true, false); } } @@ -371,12 +371,12 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { inventory->setItem(index, itemId, amount, refine, - identified, true, false, equipType != 0, false); + identified, true, false, false, equipType != 0, false); } else { inventory->setItem(index, itemId, amount, refine, - 1, identified != 0, false, equipType != 0, false); + 1, identified != 0, false, false, equipType != 0, false); } } ArrowsListener::distributeEvent(); @@ -431,12 +431,12 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { inventory->setItem(index, itemId, amount, - 0, identified, true, false, isEquipment, false); + 0, identified, true, false, false, isEquipment, false); } else { inventory->setItem(index, itemId, amount, - 0, 1, identified != 0, false, isEquipment, false); + 0, 1, identified != 0, false, false, isEquipment, false); } } } @@ -474,12 +474,12 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { mInventoryItems.push_back(Ea::InventoryItem(index, itemId, - amount, 0, identified, true, false, false)); + amount, 0, identified, true, false, false, false)); } else { mInventoryItems.push_back(Ea::InventoryItem(index, itemId, - amount, 0, 1, identified != 0, false, false)); + amount, 0, 1, identified != 0, false, false, false)); } } BLOCK_END("InventoryHandler::processPlayerInventory") @@ -547,12 +547,14 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { mInventoryItems.push_back(Ea::InventoryItem(index, - itemId, amount, refine, identified, true, false, false)); + itemId, amount, refine, identified, true, + false, false, false)); } else { mInventoryItems.push_back(Ea::InventoryItem(index, - itemId, amount, refine, 1, identified != 0, false, false)); + itemId, amount, refine, 1, identified != 0, + false, false, false)); } } BLOCK_END("InventoryHandler::processPlayerStorageEquip") @@ -583,12 +585,12 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { mStorage->setItem(index, itemId, amount, - refine, identified, true, false, false, false); + refine, identified, true, false, false, false, false); } else { mStorage->setItem(index, itemId, amount, - refine, 1, identified != 0, false, false, false); + refine, 1, identified != 0, false, false, false, false); } } } diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index c0ced4c42..30b432d2f 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -183,12 +183,12 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) if (serverFeatures->haveItemColors()) { tradeWindow->addItem2(type, false, amount, - refine, identify, true, false, false); + refine, identify, true, false, false, false); } else { tradeWindow->addItem2(type, false, amount, - refine, 1, identify != 0, false, false); + refine, 1, identify != 0, false, false, false); } } } @@ -220,7 +220,7 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) tradeWindow->addItem2(item->getId(), true, quantity, item->getRefine(), item->getColor(), item->getIdentified(), item->getDamaged(), - item->isEquipment()); + item->getFavorite(), item->isEquipment()); } item->increaseQuantity(-quantity); break; diff --git a/src/shopitem.cpp b/src/shopitem.cpp index b3122d762..2dc82f010 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -37,7 +37,7 @@ ShopItem::ShopItem(const int inventoryIndex, const unsigned char color, const int quantity, const int price) : - Item(id, 0, 0, color, true, false, false, false), + Item(id, 0, 0, color, true, false, false, false, false), mDisplayName(), mDuplicates(), mPrice(price), @@ -49,7 +49,7 @@ ShopItem::ShopItem(const int inventoryIndex, } ShopItem::ShopItem(const int id, const unsigned char color, const int price) : - Item(id, 0, 0, color, true, false, false, false), + Item(id, 0, 0, color, true, false, false, false, false), mDisplayName(), mDuplicates(), mPrice(price), -- cgit v1.2.3-60-g2f50