summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/theme.cpp121
-rw-r--r--src/gui/theme.h15
-rw-r--r--src/gui/themecolorsidoperators.cpp28
-rw-r--r--src/gui/themecolorsidoperators.h28
-rw-r--r--src/gui/widgets/widget2.h18
-rw-r--r--src/gui/windows/ministatuswindow.cpp2
-rw-r--r--src/gui/windows/ministatuswindow.h2
-rw-r--r--src/gui/windows/tradewindow.cpp24
8 files changed, 154 insertions, 84 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index c0a4e7bf7..9735fc05b 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -70,7 +70,7 @@ static void initDefaultThemePath()
}
Theme::Theme() :
- Palette(ThemeColorId::THEME_COLORS_END * THEME_PALETTES),
+ Palette(static_cast<int>(ThemeColorId::THEME_COLORS_END) * THEME_PALETTES),
mSkins(),
mMinimumOpacity(-1.0F),
mProgressColors(ProgressColors(static_cast<size_t>(
@@ -80,56 +80,62 @@ Theme::Theme() :
config.addListener("guialpha", this);
- mColors[ThemeColorId::HIGHLIGHT].ch = 'H';
- mColors[ThemeColorId::CHAT].ch = 'C';
- mColors[ThemeColorId::GM].ch = 'G';
- mColors[ThemeColorId::GLOBAL].ch = 'g';
- mColors[ThemeColorId::PLAYER].ch = 'Y';
- mColors[ThemeColorId::WHISPER_TAB].ch = 'W';
- mColors[ThemeColorId::WHISPER_TAB_OFFLINE].ch = 'w';
- mColors[ThemeColorId::IS].ch = 'I';
- mColors[ThemeColorId::PARTY_CHAT_TAB].ch = 'P';
- mColors[ThemeColorId::GUILD_CHAT_TAB].ch = 'U';
- mColors[ThemeColorId::SERVER].ch = 'S';
- mColors[ThemeColorId::LOGGER].ch = 'L';
- mColors[ThemeColorId::HYPERLINK].ch = '<';
- mColors[ThemeColorId::SELFNICK].ch = 's';
- mColors[ThemeColorId::OLDCHAT].ch = 'o';
- mColors[ThemeColorId::AWAYCHAT].ch = 'a';
- mCharColors['H'] = ThemeColorId::HIGHLIGHT;
- mCharColors['C'] = ThemeColorId::CHAT;
- mCharColors['G'] = ThemeColorId::GM;
- mCharColors['g'] = ThemeColorId::GLOBAL;
- mCharColors['Y'] = ThemeColorId::PLAYER;
- mCharColors['W'] = ThemeColorId::WHISPER_TAB;
- mCharColors['w'] = ThemeColorId::WHISPER_TAB_OFFLINE;
- mCharColors['I'] = ThemeColorId::IS;
- mCharColors['P'] = ThemeColorId::PARTY_CHAT_TAB;
- mCharColors['U'] = ThemeColorId::GUILD_CHAT_TAB;
- mCharColors['S'] = ThemeColorId::SERVER;
- mCharColors['L'] = ThemeColorId::LOGGER;
- mCharColors['<'] = ThemeColorId::HYPERLINK;
- mCharColors['s'] = ThemeColorId::SELFNICK;
- mCharColors['o'] = ThemeColorId::OLDCHAT;
- mCharColors['a'] = ThemeColorId::AWAYCHAT;
+ mColors[static_cast<size_t>(ThemeColorId::HIGHLIGHT)].ch = 'H';
+ mColors[static_cast<size_t>(ThemeColorId::CHAT)].ch = 'C';
+ mColors[static_cast<size_t>(ThemeColorId::GM)].ch = 'G';
+ mColors[static_cast<size_t>(ThemeColorId::GLOBAL)].ch = 'g';
+ mColors[static_cast<size_t>(ThemeColorId::PLAYER)].ch = 'Y';
+ mColors[static_cast<size_t>(ThemeColorId::WHISPER_TAB)].ch = 'W';
+ mColors[static_cast<size_t>(ThemeColorId::WHISPER_TAB_OFFLINE)].ch = 'w';
+ mColors[static_cast<size_t>(ThemeColorId::IS)].ch = 'I';
+ mColors[static_cast<size_t>(ThemeColorId::PARTY_CHAT_TAB)].ch = 'P';
+ mColors[static_cast<size_t>(ThemeColorId::GUILD_CHAT_TAB)].ch = 'U';
+ mColors[static_cast<size_t>(ThemeColorId::SERVER)].ch = 'S';
+ mColors[static_cast<size_t>(ThemeColorId::LOGGER)].ch = 'L';
+ mColors[static_cast<size_t>(ThemeColorId::HYPERLINK)].ch = '<';
+ mColors[static_cast<size_t>(ThemeColorId::SELFNICK)].ch = 's';
+ mColors[static_cast<size_t>(ThemeColorId::OLDCHAT)].ch = 'o';
+ mColors[static_cast<size_t>(ThemeColorId::AWAYCHAT)].ch = 'a';
+ mCharColors['H'] = static_cast<int>(ThemeColorId::HIGHLIGHT);
+ mCharColors['C'] = static_cast<int>(ThemeColorId::CHAT);
+ mCharColors['G'] = static_cast<int>(ThemeColorId::GM);
+ mCharColors['g'] = static_cast<int>(ThemeColorId::GLOBAL);
+ mCharColors['Y'] = static_cast<int>(ThemeColorId::PLAYER);
+ mCharColors['W'] = static_cast<int>(ThemeColorId::WHISPER_TAB);
+ mCharColors['w'] = static_cast<int>(ThemeColorId::WHISPER_TAB_OFFLINE);
+ mCharColors['I'] = static_cast<int>(ThemeColorId::IS);
+ mCharColors['P'] = static_cast<int>(ThemeColorId::PARTY_CHAT_TAB);
+ mCharColors['U'] = static_cast<int>(ThemeColorId::GUILD_CHAT_TAB);
+ mCharColors['S'] = static_cast<int>(ThemeColorId::SERVER);
+ mCharColors['L'] = static_cast<int>(ThemeColorId::LOGGER);
+ mCharColors['<'] = static_cast<int>(ThemeColorId::HYPERLINK);
+ mCharColors['s'] = static_cast<int>(ThemeColorId::SELFNICK);
+ mCharColors['o'] = static_cast<int>(ThemeColorId::OLDCHAT);
+ mCharColors['a'] = static_cast<int>(ThemeColorId::AWAYCHAT);
// here need use outlined colors
- mCharColors['H' | 0x80] = ThemeColorId::HIGHLIGHT_OUTLINE;
- mCharColors['C' | 0x80] = ThemeColorId::CHAT_OUTLINE;
- mCharColors['G' | 0x80] = ThemeColorId::GM_OUTLINE;
- mCharColors['g' | 0x80] = ThemeColorId::GLOBAL_OUTLINE;
- mCharColors['Y' | 0x80] = ThemeColorId::PLAYER_OUTLINE;
- mCharColors['W' | 0x80] = ThemeColorId::WHISPER_TAB_OUTLINE;
- mCharColors['w' | 0x80] = ThemeColorId::WHISPER_TAB_OFFLINE_OUTLINE;
- mCharColors['I' | 0x80] = ThemeColorId::IS_OUTLINE;
- mCharColors['P' | 0x80] = ThemeColorId::PARTY_CHAT_TAB_OUTLINE;
- mCharColors['U' | 0x80] = ThemeColorId::GUILD_CHAT_TAB_OUTLINE;
- mCharColors['S' | 0x80] = ThemeColorId::SERVER_OUTLINE;
- mCharColors['L' | 0x80] = ThemeColorId::LOGGER_OUTLINE;
- mCharColors['<' | 0x80] = ThemeColorId::HYPERLINK_OUTLINE;
- mCharColors['s' | 0x80] = ThemeColorId::SELFNICK_OUTLINE;
- mCharColors['o' | 0x80] = ThemeColorId::OLDCHAT_OUTLINE;
- mCharColors['a' | 0x80] = ThemeColorId::AWAYCHAT_OUTLINE;
+ mCharColors['H' | 0x80]
+ = static_cast<int>(ThemeColorId::HIGHLIGHT_OUTLINE);
+ mCharColors['C' | 0x80] = static_cast<int>(ThemeColorId::CHAT_OUTLINE);
+ mCharColors['G' | 0x80] = static_cast<int>(ThemeColorId::GM_OUTLINE);
+ mCharColors['g' | 0x80] = static_cast<int>(ThemeColorId::GLOBAL_OUTLINE);
+ mCharColors['Y' | 0x80] = static_cast<int>(ThemeColorId::PLAYER_OUTLINE);
+ mCharColors['W' | 0x80]
+ = static_cast<int>(ThemeColorId::WHISPER_TAB_OUTLINE);
+ mCharColors['w' | 0x80]
+ = static_cast<int>(ThemeColorId::WHISPER_TAB_OFFLINE_OUTLINE);
+ mCharColors['I' | 0x80] = static_cast<int>(ThemeColorId::IS_OUTLINE);
+ mCharColors['P' | 0x80]
+ = static_cast<int>(ThemeColorId::PARTY_CHAT_TAB_OUTLINE);
+ mCharColors['U' | 0x80]
+ = static_cast<int>(ThemeColorId::GUILD_CHAT_TAB_OUTLINE);
+ mCharColors['S' | 0x80] = static_cast<int>(ThemeColorId::SERVER_OUTLINE);
+ mCharColors['L' | 0x80] = static_cast<int>(ThemeColorId::LOGGER_OUTLINE);
+ mCharColors['<' | 0x80]
+ = static_cast<int>(ThemeColorId::HYPERLINK_OUTLINE);
+ mCharColors['s' | 0x80] = static_cast<int>(ThemeColorId::SELFNICK_OUTLINE);
+ mCharColors['o' | 0x80] = static_cast<int>(ThemeColorId::OLDCHAT_OUTLINE);
+ mCharColors['a' | 0x80] = static_cast<int>(ThemeColorId::AWAYCHAT_OUTLINE);
}
Theme::~Theme()
@@ -644,7 +650,8 @@ ImageSet *Theme::getImageSetFromTheme(const std::string &path,
static int readColorType(const std::string &type)
{
- static const std::string colors[ThemeColorId::THEME_COLORS_END] =
+ static const std::string colors[static_cast<size_t>(
+ ThemeColorId::THEME_COLORS_END)] =
{
"BROWSERBOX",
"BROWSERBOX_OUTLINE",
@@ -871,7 +878,7 @@ static int readColorType(const std::string &type)
if (type.empty())
return -1;
- for (int i = 0; i < ThemeColorId::THEME_COLORS_END; i++)
+ for (int i = 0; i < static_cast<int>(ThemeColorId::THEME_COLORS_END); i++)
{
if (compareStrI(type, colors[i]) == 0)
return i;
@@ -1029,7 +1036,8 @@ void Theme::loadColors(std::string file)
const Color color = readColor(temp);
const GradientTypeT grad = readColorGradient(
XML::getProperty(node, "effect", ""));
- mColors[paletteId * ThemeColorId::THEME_COLORS_END + type].set(
+ mColors[paletteId * static_cast<size_t>(
+ ThemeColorId::THEME_COLORS_END) + type].set(
type, color, grad, 10);
if (!findLast(id, "_OUTLINE"))
@@ -1037,7 +1045,8 @@ void Theme::loadColors(std::string file)
const int type2 = readColorType(id + "_OUTLINE");
if (type2 < 0)
continue;
- const int idx = paletteId * ThemeColorId::THEME_COLORS_END;
+ const int idx = paletteId
+ * static_cast<int>(ThemeColorId::THEME_COLORS_END);
mColors[idx + type2] = mColors[idx + type];
}
}
@@ -1216,15 +1225,15 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName)
return info;
}
-int Theme::getIdByChar(const signed char c, bool &valid) const
+ThemeColorIdT Theme::getIdByChar(const signed char c, bool &valid) const
{
const CharColors::const_iterator it = mCharColors.find(c);
if (it != mCharColors.end())
{
valid = true;
- return (*it).second;
+ return static_cast<ThemeColorIdT>((*it).second);
}
valid = false;
- return 0;
+ return ThemeColorId::BROWSERBOX;
}
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 5a9a75bb0..2b6e45812 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -26,6 +26,7 @@
#define GUI_THEME_H
#include "enums/gui/progresscolorid.h"
+#include "enums/gui/themecolorid.h"
#include "listeners/configlistener.h"
@@ -133,21 +134,23 @@ class Theme final : public Palette,
*
* @return the requested color
*/
- inline const Color &getColor(int type,
+ inline const Color &getColor(ThemeColorIdT type,
const int alpha = 255) A_WARN_UNUSED
{
- if (type >= static_cast<signed>(mColors.size()) || type < 0)
+ if (static_cast<size_t>(type) >= mColors.size())
{
logger->log("incorrect color request type: %d from %u",
- type, static_cast<unsigned int>(mColors.size()));
- type = 0;
+ static_cast<int>(type),
+ static_cast<unsigned int>(mColors.size()));
+ type = ThemeColorIdT::BROWSERBOX;
}
- Color* col = &mColors[type].color;
+ Color* col = &mColors[static_cast<size_t>(type)].color;
col->a = alpha;
return *col;
}
- int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED;
+ ThemeColorIdT getIdByChar(const signed char c,
+ bool &valid) const A_WARN_UNUSED;
/**
* Set the minimum opacity allowed to skins.
diff --git a/src/gui/themecolorsidoperators.cpp b/src/gui/themecolorsidoperators.cpp
new file mode 100644
index 000000000..559981d67
--- /dev/null
+++ b/src/gui/themecolorsidoperators.cpp
@@ -0,0 +1,28 @@
+/*
+ * 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 "gui/themecolorsidoperators.h"
+
+#include "debug.h"
+
+ThemeColorIdT operator+(const ThemeColorIdT &id, const int& i)
+{
+ return static_cast<ThemeColorIdT>(static_cast<int>(id) + i);
+}
diff --git a/src/gui/themecolorsidoperators.h b/src/gui/themecolorsidoperators.h
new file mode 100644
index 000000000..b4781ed2d
--- /dev/null
+++ b/src/gui/themecolorsidoperators.h
@@ -0,0 +1,28 @@
+/*
+ * 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 GUI_THEMECOLORIDOPERATOR_H
+#define GUI_THEMECOLORIDOPERATOR_H
+
+#include "enums/gui/themecolorid.h"
+
+ThemeColorIdT operator+(const ThemeColorIdT &id, const int& i);
+
+#endif // GUI_THEMECOLORIDOPERATOR_H
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index 9fad6a882..5955397fc 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -21,7 +21,7 @@
#ifndef GUI_WIDGETS_WIDGET2_H
#define GUI_WIDGETS_WIDGET2_H
-#include "enums/gui/themecolorid.h"
+#include "gui/themecolorsidoperators.h"
#include "gui/theme.h"
@@ -34,11 +34,11 @@ class Widget2 notfinal
{
}
- inline const Color &getThemeColor(const int type,
+ inline const Color &getThemeColor(const ThemeColorIdT type,
const int alpha = 255)
const A_WARN_UNUSED
{
- return theme->getColor(mPaletteOffset + type, alpha);
+ return theme->getColor(type + mPaletteOffset, alpha);
}
inline const Color &getThemeCharColor(const signed char c,
@@ -47,9 +47,9 @@ class Widget2 notfinal
{
if (!theme)
return Palette::BLACK;
- const int colorId = theme->getIdByChar(c, valid);
+ const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
if (valid)
- return theme->getColor(mPaletteOffset + colorId, 255);
+ return theme->getColor(colorId + mPaletteOffset, 255);
else
return Palette::BLACK;
}
@@ -61,15 +61,17 @@ class Widget2 notfinal
void setPalette(int palette)
{
- mPaletteOffset = palette * ThemeColorId::THEME_COLORS_END;
+ mPaletteOffset = palette * static_cast<int>(
+ ThemeColorId::THEME_COLORS_END);
checkPalette();
setWidget2(this);
}
void checkPalette()
{
- if (mPaletteOffset < 0 || mPaletteOffset
- >= THEME_PALETTES * ThemeColorId::THEME_COLORS_END)
+ if (mPaletteOffset < 0 ||
+ mPaletteOffset >= THEME_PALETTES * static_cast<int>(
+ ThemeColorId::THEME_COLORS_END))
{
mPaletteOffset = 0;
}
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 7d0e030b3..73663c3a7 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -175,7 +175,7 @@ MiniStatusWindow::~MiniStatusWindow()
ProgressBar *MiniStatusWindow::createBar(const float progress,
const int width,
const int height,
- const int textColor,
+ const ThemeColorId textColor,
const ProgressColorIdT backColor,
const std::string &restrict skin,
const std::string &restrict skinFill,
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index 2edb8e66e..dbe2b76e8 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -112,7 +112,7 @@ class MiniStatusWindow final : public Window,
ProgressBar *createBar(const float progress,
const int width,
const int height,
- const int textColor,
+ const ThemeColorId textColor,
const ProgressColorIdT backColor,
const std::string &restrict skin,
const std::string &restrict skinFill,
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index 11d150f30..c5951a7a5 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -173,16 +173,16 @@ void TradeWindow::setMoney(const int amount)
}
else
{
- mMoneyLabel->setForegroundColorAll(getThemeColor(
- static_cast<int>(ThemeColorId::WARNING)), getThemeColor(
- static_cast<int>(ThemeColorId::WARNING_OUTLINE)));
+ mMoneyLabel->setForegroundColorAll(
+ getThemeColor(ThemeColorId::WARNING),
+ getThemeColor(ThemeColorId::WARNING_OUTLINE));
}
}
else
{
- mMoneyLabel->setForegroundColorAll(getThemeColor(
- static_cast<int>(ThemeColorId::LABEL)), getThemeColor(
- static_cast<int>(ThemeColorId::LABEL_OUTLINE)));
+ mMoneyLabel->setForegroundColorAll(
+ getThemeColor(ThemeColorId::LABEL),
+ getThemeColor(ThemeColorId::LABEL_OUTLINE));
mGotMaxMoney = amount;
}
@@ -277,9 +277,9 @@ void TradeWindow::reset()
setMoney(0);
mMoneyField->setEnabled(true);
mMoneyField->setText("");
- mMoneyLabel->setForegroundColorAll(getThemeColor(
- static_cast<int>(ThemeColorId::LABEL)), getThemeColor(
- static_cast<int>(ThemeColorId::LABEL_OUTLINE)));
+ mMoneyLabel->setForegroundColorAll(
+ getThemeColor(ThemeColorId::LABEL),
+ getThemeColor(ThemeColorId::LABEL_OUTLINE));
mAddButton->setEnabled(true);
mMoneyChangeButton->setEnabled(true);
mGotMoney = 0;
@@ -448,9 +448,9 @@ void TradeWindow::clear()
mAutoAddAmount = 0;
mGotMoney = 0;
mGotMaxMoney = 0;
- mMoneyLabel->setForegroundColorAll(getThemeColor(
- static_cast<int>(ThemeColorId::LABEL)), getThemeColor(
- static_cast<int>(ThemeColorId::LABEL_OUTLINE)));
+ mMoneyLabel->setForegroundColorAll(
+ getThemeColor(ThemeColorId::LABEL),
+ getThemeColor(ThemeColorId::LABEL_OUTLINE));
}
void TradeWindow::addAutoItem(const std::string &nick, Item* const item,