summaryrefslogtreecommitdiff
path: root/src/resources/iteminfo.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-08 06:06:50 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-08 06:06:50 +0200
commit07c9e6360ac16c96b8624a4b0bf4557ae295699d (patch)
tree718cbc1e2cd21b13239d7bca4be9a04d811e4c48 /src/resources/iteminfo.cpp
parentc17acf93cb4ebe698b0af8a38a1fd6d49a6be3cc (diff)
downloadmanaverse-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.gz
manaverse-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.bz2
manaverse-07c9e6360ac16c96b8624a4b0bf4557ae295699d.tar.xz
manaverse-07c9e6360ac16c96b8624a4b0bf4557ae295699d.zip
Replace %color% and %Color% constants in item names/descriptions.
Diffstat (limited to 'src/resources/iteminfo.cpp')
-rw-r--r--src/resources/iteminfo.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 990c78f45..667037c58 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -106,4 +106,38 @@ std::string ItemInfo::getDyeColorsString(int color) const
return "";
return it->second.color;
-} \ No newline at end of file
+}
+
+const std::string ItemInfo::getDescription(unsigned char color) const
+{
+ return replaceColors(mDescription, color);
+}
+
+const std::string ItemInfo::getName(unsigned char color) const
+{
+ return replaceColors(mName, color);
+}
+
+const std::string ItemInfo::replaceColors(std::string str,
+ unsigned char color) const
+{
+ std::string name;
+ if (mColors && !mColorList.empty())
+ {
+ std::map <int, ColorDB::ItemColor>::iterator it = mColors->find(color);
+ if (it == mColors->end())
+ name = "unknown";
+ else
+ name = it->second.name;
+ }
+ else
+ {
+ name = "unknown";
+ }
+
+ str = replaceAll(str, "%color%", name);
+ if (name.size() > 0)
+ name[0] = toupper(name[0]);
+
+ return replaceAll(str, "%Color%", name);
+}