diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-03 01:25:21 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-03 01:25:21 +0200 |
commit | 22f79fd0d623c8e11994905534f53da267e22935 (patch) | |
tree | 04403929ca80f47253f8dd523a29489c0fd30162 /src/utils/stringutils.cpp | |
parent | 582428edf9e40db0d1ed7b78222562a7a5031fe4 (diff) | |
download | mv-22f79fd0d623c8e11994905534f53da267e22935.tar.gz mv-22f79fd0d623c8e11994905534f53da267e22935.tar.bz2 mv-22f79fd0d623c8e11994905534f53da267e22935.tar.xz mv-22f79fd0d623c8e11994905534f53da267e22935.zip |
Dehardcode item colors. Now reading all from configs.
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 835f9ce00..63924eb78 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -388,6 +388,19 @@ std::list<int> splitToIntList(const std::string &text, char separator) return tokens; } + +std::list<std::string> splitToStringList(const std::string &text, + char separator) +{ + std::list<std::string> tokens; + std::stringstream ss(text); + std::string item; + while(std::getline(ss, item, separator)) + tokens.push_back(item); + + return tokens; +} + std::string combineDye(std::string file, std::string dye) { if (dye.empty()) @@ -397,3 +410,31 @@ std::string combineDye(std::string file, std::string dye) return file.substr(0, pos) + "|" + dye; return file + "|" + dye; } + +std::string combineDye2(std::string file, std::string dye) +{ + if (dye.empty()) + return file; + + size_t pos = file.find_last_of("|"); + if (pos != std::string::npos) + { + std::string dye1 = file.substr(pos + 1); + std::string str = ""; + file = file.substr(0, pos); + std::list<std::string> list1 = splitToStringList(dye1, ';'); + std::list<std::string> list2 = splitToStringList(dye, ';'); + std::list<std::string>::iterator it1, it1_end = list1.end(); + std::list<std::string>::iterator it2, it2_end = list2.end(); + for (it1 = list1.begin(), it2 = list2.begin(); + it1 != it1_end && it2 != it2_end; ++it1, ++it2) + { + str += (*it1) + ":" + (*it2) + ";"; + } + return file + "|" + str; + } + else + { + return file; + } +} |