diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/gui/windows/mailviewwindow.cpp | 1 | ||||
-rw-r--r-- | src/itemcolormanager.cpp | 30 | ||||
-rw-r--r-- | src/itemcolormanager.h | 37 | ||||
-rw-r--r-- | src/net/eathena/auctionhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 8 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 27 | ||||
-rw-r--r-- | src/net/eathena/itemhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/eathena/searchstorehandler.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/tradehandler.cpp | 3 | ||||
-rw-r--r-- | src/net/eathena/vendinghandler.cpp | 6 |
14 files changed, 106 insertions, 21 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43a2e0c5f..0b21bd5c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -906,6 +906,8 @@ SET(SRCS inventory.h item.cpp item.h + itemcolormanager.cpp + itemcolormanager.h itemshortcut.cpp itemshortcut.h itemsoundmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 9ec08b226..054b7b634 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -660,6 +660,8 @@ manaplus_SOURCES += main.cpp \ textcommand.h \ item.cpp \ item.h \ + itemcolormanager.cpp \ + itemcolormanager.h \ itemshortcut.cpp \ itemshortcut.h \ itemsoundmanager.cpp \ diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp index ad7eb8a88..351a09112 100644 --- a/src/gui/windows/mailviewwindow.cpp +++ b/src/gui/windows/mailviewwindow.cpp @@ -109,6 +109,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) : { ResourceManager *const resman = ResourceManager::getInstance(); const ItemInfo &item = ItemDB::get(message->itemId); + // +++ need use message->cards and ItemColorManager for colors Image *const image = resman->getImage(combineDye2( paths.getStringValue("itemIcons").append( item.getDisplay().image), diff --git a/src/itemcolormanager.cpp b/src/itemcolormanager.cpp new file mode 100644 index 000000000..31f4c333c --- /dev/null +++ b/src/itemcolormanager.cpp @@ -0,0 +1,30 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "itemcolormanager.h" + +#include "resources/iteminfo.h" + +#include "debug.h" + +ItemColor ItemColorManager::getColorFromCards(const int *const cards) +{ + return ItemColor_one; +} diff --git a/src/itemcolormanager.h b/src/itemcolormanager.h new file mode 100644 index 000000000..6fc4eae5a --- /dev/null +++ b/src/itemcolormanager.h @@ -0,0 +1,37 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ITEMCOLORMANAGER_H +#define ITEMCOLORMANAGER_H + +#include "enums/simpletypes/itemcolor.h" + +#include "localconsts.h" + +class ItemColorManager final +{ + public: + A_DELETE_COPY(ItemColorManager) + + static ItemColor getColorFromCards(const int *const cards) + A_WARN_UNUSED; +}; + +#endif // ITEMCOLORMANAGER_H diff --git a/src/net/eathena/auctionhandler.cpp b/src/net/eathena/auctionhandler.cpp index 7522ec491..f75efd2ea 100644 --- a/src/net/eathena/auctionhandler.cpp +++ b/src/net/eathena/auctionhandler.cpp @@ -108,6 +108,7 @@ void AuctionHandler::processAuctionResults(Net::MessageIn &msg) msg.readInt32("buy now"); msg.readString(24, "buyer name"); msg.readInt32("timestamp"); + // +++ need use ItemColorManager for color } } diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 5c748915b..5c531e16a 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -25,6 +25,7 @@ #include "actormanager.h" #include "effectmanager.h" #include "game.h" +#include "itemcolormanager.h" #include "notifymanager.h" #include "party.h" @@ -525,7 +526,7 @@ void BeingHandler::processBeingChangeLook2(Net::MessageIn &msg) void BeingHandler::processBeingChangeLookCards(Net::MessageIn &msg) { Being *dstBeing = nullptr; - uint16_t cards[4]; + int cards[4]; if (!actorManager) { // here can be look from char server @@ -571,12 +572,13 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg, const uint8_t type, const int id, const int id2, - const uint16_t *cards + const int *cards A_UNUSED) { if (dstBeing->getType() == ActorType::Player) dstBeing->setOtherTime(); + const ItemColor itemColor = ItemColorManager::getColorFromCards(cards); const std::string color; switch (type) { @@ -589,7 +591,7 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg, dstBeing->setSpriteID(SPRITE_HAIR_COLOR, id * -1); break; case 2: // LOOK_WEAPON Weapon ID in id, Shield ID in id2 - dstBeing->setSprite(SPRITE_BODY, id, "", ItemColor_one, true); + dstBeing->setSprite(SPRITE_BODY, id, "", itemColor, true); dstBeing->setSprite(SPRITE_FLOOR, id2); if (localPlayer) localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index bc77924b9..7dda4f2cb 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -89,7 +89,7 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler const uint8_t type, const int id, const int id2, - const uint16_t *cards) + const int *cards) A_NONNULL(2); static void processBeingSpecialEffect(Net::MessageIn &msg); diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index c2b01be22..30ec030cc 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -23,6 +23,7 @@ #include "net/eathena/inventoryhandler.h" #include "notifymanager.h" +#include "itemcolormanager.h" #include "being/localplayer.h" @@ -463,7 +464,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) itemType, 1, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), @@ -505,6 +506,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) msg.readInt32("hire expire date"); msg.readInt16("bind on equip"); + const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); const ItemInfo &itemInfo = ItemDB::get(itemId); BeingId floorId; if (mSentPickups.empty()) @@ -549,7 +551,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) { localPlayer->pickedUp(itemInfo, 0, - ItemColor_one, + color, floorId, pickup); } @@ -560,7 +562,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) { localPlayer->pickedUp(itemInfo, amount, - ItemColor_one, + color, floorId, Pickup::OKAY); } @@ -577,7 +579,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) itemType, amount, refine, - ItemColor_one, + color, fromBool(identified, Identified), fromBool(damaged, Damaged), Favorite_false, @@ -630,7 +632,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg) itemType, amount, 0, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), @@ -672,7 +674,7 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) cards, amount, 0, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), @@ -778,7 +780,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) cards, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), @@ -802,9 +804,10 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) for (int f = 0; f < 4; f++) cards[f] = msg.readInt16("card"); + const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); if (Item *const item = mStorage->getItem(index)) { - item->setId(itemId, ItemColor_one); + item->setId(itemId, color); item->increaseQuantity(amount); } else @@ -816,7 +819,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) itemType, amount, refine, - ItemColor_one, + color, fromBool(identified, Identified), Damaged_false, Favorite_false, @@ -1000,7 +1003,7 @@ void InventoryHandler::processPlayerCartAdd(Net::MessageIn &msg) itemType, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(identified, Identified), Damaged_false, Favorite_false, @@ -1040,7 +1043,7 @@ void InventoryHandler::processPlayerCartEquip(Net::MessageIn &msg) cards, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), @@ -1077,7 +1080,7 @@ void InventoryHandler::processPlayerCartItems(Net::MessageIn &msg) cards, amount, 0, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(flags.bits.isIdentified, Identified), fromBool(flags.bits.isDamaged, Damaged), fromBool(flags.bits.isFavorite, Favorite), diff --git a/src/net/eathena/itemhandler.cpp b/src/net/eathena/itemhandler.cpp index 909d6d312..6bb541649 100644 --- a/src/net/eathena/itemhandler.cpp +++ b/src/net/eathena/itemhandler.cpp @@ -23,6 +23,7 @@ #include "net/eathena/itemhandler.h" #include "actormanager.h" +#include "itemcolormanager.h" #include "logger.h" #include "net/eathena/protocol.h" @@ -141,7 +142,7 @@ void ItemHandler::processItemDropped2(Net::MessageIn &msg) itemType, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), identified, subX, subY, &cards[0]); @@ -226,7 +227,7 @@ void ItemHandler::processItemVisible2(Net::MessageIn &msg) itemType, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), identified, subX, subY, &cards[0]); diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index bbc2d0b48..15c1c4940 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -479,6 +479,7 @@ void PartyHandler::processPartyItemPickup(Net::MessageIn &msg) msg.readInt16("card"); msg.readInt16("equip location"); msg.readUInt8("item type"); + // for color can be used ItemColorManager } void PartyHandler::processPartyLeader(Net::MessageIn &msg) diff --git a/src/net/eathena/searchstorehandler.cpp b/src/net/eathena/searchstorehandler.cpp index c133ed184..6151a161c 100644 --- a/src/net/eathena/searchstorehandler.cpp +++ b/src/net/eathena/searchstorehandler.cpp @@ -129,6 +129,8 @@ void SearchStoreHandler::processSearchAck(Net::MessageIn &msg) msg.readUInt8("refine"); for (int d = 0; d < 4; d++) msg.readInt16("card"); + + // +++ need use ItemColorManager for colors } } diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index a76a08130..bc416cff6 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/tradehandler.cpp @@ -24,6 +24,7 @@ #include "inventory.h" #include "item.h" +#include "itemcolormanager.h" #include "notifymanager.h" #include "being/playerinfo.h" @@ -206,7 +207,7 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) false, amount, refine, - ItemColor_one, + ItemColorManager::getColorFromCards(&cards[0]), fromBool(identify, Identified), Damaged_false, Favorite_false, diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp index 584aa1f23..1db5cd5fc 100644 --- a/src/net/eathena/vendinghandler.cpp +++ b/src/net/eathena/vendinghandler.cpp @@ -21,6 +21,7 @@ #include "net/eathena/vendinghandler.h" #include "actormanager.h" +#include "itemcolormanager.h" #include "shopitem.h" #include "being/localplayer.h" @@ -142,6 +143,7 @@ void VendingHandler::processItemsList(Net::MessageIn &msg) Being *const being = actorManager->findBeing(id); if (!being) return; + int cards[4]; CREATEWIDGETV(mBuyDialog, BuyDialog, being->getName()); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); msg.readInt32("vender id"); @@ -156,9 +158,9 @@ void VendingHandler::processItemsList(Net::MessageIn &msg) msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int d = 0; d < 4; d ++) - msg.readInt16("card"); + cards[d] = msg.readInt16("card"); - const ItemColor color = ItemColor_one; + const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); ShopItem *const item = mBuyDialog->addItem(itemId, type, color, amount, value); if (item) |