From 8167471e438210f4a81fca8d2c70f52bb736983f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 20 Jun 2017 19:47:54 +0300 Subject: Move itemcolordata into separate file. --- src/resources/beinginfo.cpp | 2 +- src/resources/beinginfo.h | 7 ++---- src/resources/db/colordb.cpp | 2 +- src/resources/db/colordb.h | 29 ++-------------------- src/resources/itemcolordata.h | 56 +++++++++++++++++++++++++++++++++++++++++++ src/resources/iteminfo.cpp | 14 +++++------ src/resources/iteminfo.h | 10 +++----- 7 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 src/resources/itemcolordata.h (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index e4fe5c851..5c10d5ae3 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -227,7 +227,7 @@ std::string BeingInfo::getColor(const ItemColor idx) const if (mColors == nullptr) return std::string(); - const std::map ::const_iterator + const std::map ::const_iterator it = mColors->find(idx); if (it == mColors->end()) return std::string(); diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 6b359cec1..531392e99 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -38,10 +38,7 @@ struct Attack; -namespace ColorDB -{ - class ItemColorData; -} // namespace ColorDB +class ItemColorData; typedef std::map Attacks; @@ -361,7 +358,7 @@ class BeingInfo final std::string mCurrency; unsigned char mBlockWalkMask; BlockTypeT mBlockType; - const std::map *mColors; + const std::map *mColors; int mTargetOffsetX; int mTargetOffsetY; int mNameOffsetX; diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp index 088bb8832..f4cd0921b 100644 --- a/src/resources/db/colordb.cpp +++ b/src/resources/db/colordb.cpp @@ -214,7 +214,7 @@ int ColorDB::getHairSize() return mHairColorsSize; } -const std::map +const std::map *ColorDB::getColorsList(const std::string &name) { const ColorListsIterator it = mColorLists.find(name); diff --git a/src/resources/db/colordb.h b/src/resources/db/colordb.h index d4e0ecb29..5189d7c85 100644 --- a/src/resources/db/colordb.h +++ b/src/resources/db/colordb.h @@ -22,11 +22,11 @@ #ifndef RESOURCES_DB_COLORDB_H #define RESOURCES_DB_COLORDB_H -#include "enums/simpletypes/itemcolor.h" #include "enums/simpletypes/skiperror.h" +#include "resources/itemcolordata.h" + #include -#include #include "localconsts.h" @@ -35,31 +35,6 @@ */ namespace ColorDB { - class ItemColorData final - { - public: - ItemColorData() : - id(ItemColor_zero), - name(), - color() - { } - - ItemColorData(const ItemColor id0, - const std::string &name0, - const std::string &color0) : - id(id0), - name(name0), - color(color0) - { - } - - A_DEFAULT_COPY(ItemColorData) - - ItemColor id; - std::string name; - std::string color; - }; - /** * Loads the color data from colors.xml. */ diff --git a/src/resources/itemcolordata.h b/src/resources/itemcolordata.h new file mode 100644 index 000000000..60eb247ff --- /dev/null +++ b/src/resources/itemcolordata.h @@ -0,0 +1,56 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008 Aethyra Development Team + * Copyright (C) 2011-2017 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 . + */ + +#ifndef RESOURCES_ITEMCOLORDATA_H +#define RESOURCES_ITEMCOLORDATA_H + +#include "enums/simpletypes/itemcolor.h" + +#include + +#include "localconsts.h" + +class ItemColorData final +{ + public: + ItemColorData() : + id(ItemColor_zero), + name(), + color() + { } + + ItemColorData(const ItemColor id0, + const std::string &name0, + const std::string &color0) : + id(id0), + name(name0), + color(color0) + { + } + + A_DEFAULT_COPY(ItemColorData) + + ItemColor id; + std::string name; + std::string color; +}; + +#endif // RESOURCES_ITEMCOLORDATA_H diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 7a88a63ca..7218f2cc8 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -227,7 +227,7 @@ std::string ItemInfo::getDyeColorsString(const ItemColor color) const if ((mColorsList == nullptr) || mColorsListName.empty()) return ""; - const std::map ::const_iterator + const std::map ::const_iterator it = mColorsList->find(color); if (it == mColorsList->end()) return ""; @@ -240,7 +240,7 @@ std::string ItemInfo::getDyeIconColorsString(const ItemColor color) const if ((mIconColorsList == nullptr) || mIconColorsListName.empty()) return ""; - const std::map ::const_iterator + const std::map ::const_iterator it = mIconColorsList->find(color); if (it == mIconColorsList->end()) return ""; @@ -269,7 +269,7 @@ const std::string ItemInfo::replaceColors(std::string str, std::string name; if ((mColorsList != nullptr) && !mColorsListName.empty()) { - const std::map ::const_iterator + const std::map ::const_iterator it = mColorsList->find(color); if (it == mColorsList->end()) name = "unknown"; @@ -413,7 +413,7 @@ std::string ItemInfo::getColorName(const ItemColor idx) const if (mColorsList == nullptr) return std::string(); - const std::map ::const_iterator + const std::map ::const_iterator it = mColorsList->find(idx); if (it == mColorsList->end()) { @@ -430,7 +430,7 @@ std::string ItemInfo::getColor(const ItemColor idx) const if (mColorsList == nullptr) return std::string(); - const std::map ::const_iterator + const std::map ::const_iterator it = mColorsList->find(idx); if (it == mColorsList->end()) { @@ -447,7 +447,7 @@ std::string ItemInfo::getIconColorName(const ItemColor idx) const if (mIconColorsList == nullptr) return std::string(); - const std::map ::const_iterator + const std::map ::const_iterator it = mIconColorsList->find(idx); if (it == mIconColorsList->end()) { @@ -464,7 +464,7 @@ std::string ItemInfo::getIconColor(const ItemColor idx) const if (mIconColorsList == nullptr) return std::string(); - const std::map ::const_iterator + const std::map ::const_iterator it = mIconColorsList->find(idx); if (it == mIconColorsList->end()) { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 3df93e978..5d06a89e8 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -31,17 +31,13 @@ #include "enums/simpletypes/itemcolor.h" #include "resources/cursors.h" +#include "resources/itemcolordata.h" #include "resources/soundinfo.h" #include "resources/sprite/spritedisplay.h" #include "utils/intmap.h" -namespace ColorDB -{ - class ItemColorData; -} // namespace ColorDB - // sprite, typedef std::map SpriteToItemMap; typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter; @@ -364,8 +360,8 @@ class ItemInfo final /** Stores the names of sounds to be played at certain event. */ std::map mSounds; std::map mTags; - const std::map *mColorsList; - const std::map *mIconColorsList; + const std::map *mColorsList; + const std::map *mIconColorsList; std::string mColorsListName; std::string mIconColorsListName; ItemColor mCardColor; -- cgit v1.2.3-60-g2f50