summaryrefslogtreecommitdiff
path: root/src/gui/userpalette.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-16 14:54:36 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-16 15:02:24 +0300
commita469aa111546896ea73a32f247105eee507fd966 (patch)
tree7f67a891b63c569c7c30aaabfc4a5d094e0996b9 /src/gui/userpalette.cpp
parente9f59c64a46ad38fb47aac6313c869eaa02ed0e3 (diff)
downloadplus-a469aa111546896ea73a32f247105eee507fd966.tar.gz
plus-a469aa111546896ea73a32f247105eee507fd966.tar.bz2
plus-a469aa111546896ea73a32f247105eee507fd966.tar.xz
plus-a469aa111546896ea73a32f247105eee507fd966.zip
Add support for labels inside userpalette.
Add being colors label to userpalette.
Diffstat (limited to 'src/gui/userpalette.cpp')
-rw-r--r--src/gui/userpalette.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 7fe8074b0..c4ce7fae2 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -33,6 +33,7 @@ UserPalette *userPalette = nullptr;
const std::string ColorTypeNames[] =
{
+ "",
"ColorBeing",
"ColorFriend",
"ColorDisregarded",
@@ -113,6 +114,9 @@ UserPalette::UserPalette() :
mColors[static_cast<size_t>(UserColorId::NPC)] = ColorElem();
mColors[static_cast<size_t>(UserColorId::MONSTER)] = ColorElem();
+ addLabel(UserColorId::LABEL_BEING,
+ // TRANSLATORS: palette label
+ _("Being colors"));
addColor(UserColorId::BEING,
0xffffff,
GradientType::STATIC,
@@ -358,6 +362,8 @@ UserPalette::~UserPalette()
{
FOR_EACH (Colors::const_iterator, col, mColors)
{
+ if (col->grad == GradientType::LABEL)
+ continue;
const std::string &configName = ColorTypeNames[col->type];
config.setValue(configName + "Gradient",
static_cast<int>(col->committedGrad));
@@ -503,6 +509,24 @@ void UserPalette::addColor(const UserColorIdT type,
mGradVector.push_back(&mColors[static_cast<size_t>(type)]);
}
+void UserPalette::addLabel(const UserColorIdT type,
+ const std::string &text)
+{
+ const unsigned maxType = sizeof(ColorTypeNames)
+ / sizeof(ColorTypeNames[0]);
+
+ if (static_cast<unsigned>(type) >= maxType)
+ return;
+
+
+ mColors[static_cast<size_t>(type)] = ColorElem();
+ const std::string str(" \342\200\225\342\200\225\342\200\225"
+ "\342\200\225\342\200\225 ");
+ mColors[static_cast<size_t>(type)].grad = GradientTypeT::LABEL;
+ mColors[static_cast<size_t>(type)].text =
+ std::string(str).append(text).append(str);
+}
+
int UserPalette::getIdByChar(const signed char c, bool &valid) const
{
const CharColors::const_iterator it = mCharColors.find(c);