diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-31 18:46:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-31 18:46:22 +0300 |
commit | 34cb5e4b16c1b1f5d3263dd01848b24ab0b9b354 (patch) | |
tree | d8219b2bb206f5d97f4f76599577fdb15d4ac2cc | |
parent | 6683d42b636619e02e2bcf98923a2fdbf44bd95b (diff) | |
download | mv-34cb5e4b16c1b1f5d3263dd01848b24ab0b9b354.tar.gz mv-34cb5e4b16c1b1f5d3263dd01848b24ab0b9b354.tar.bz2 mv-34cb5e4b16c1b1f5d3263dd01848b24ab0b9b354.tar.xz mv-34cb5e4b16c1b1f5d3263dd01848b24ab0b9b354.zip |
Convert ThemeColorId enum into strong typed enum.
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/enums/gui/themecolorid.h | 452 | ||||
-rw-r--r-- | src/gui/theme.cpp | 121 | ||||
-rw-r--r-- | src/gui/theme.h | 15 | ||||
-rw-r--r-- | src/gui/themecolorsidoperators.cpp | 28 | ||||
-rw-r--r-- | src/gui/themecolorsidoperators.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/widget2.h | 18 | ||||
-rw-r--r-- | src/gui/windows/ministatuswindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/ministatuswindow.h | 2 | ||||
-rw-r--r-- | src/gui/windows/tradewindow.cpp | 24 | ||||
-rw-r--r-- | src/input/inputactionoperators.h | 4 |
12 files changed, 385 insertions, 313 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8723cd3c4..bcd345a2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -499,6 +499,8 @@ SET(SRCS gui/skin.h gui/theme.cpp gui/theme.h + gui/themecolorsidoperators.cpp + gui/themecolorsidoperators.h gui/themeinfo.h gui/touchactiondata.cpp gui/touchactiondata.h diff --git a/src/Makefile.am b/src/Makefile.am index 3786cdc52..8a42a48d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -641,6 +641,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/skin.h \ gui/theme.cpp \ gui/theme.h \ + gui/themecolorsidoperators.cpp \ + gui/themecolorsidoperators.h \ gui/themeinfo.h \ gui/touchactiondata.cpp \ gui/touchactiondata.h \ diff --git a/src/enums/gui/themecolorid.h b/src/enums/gui/themecolorid.h index 3c4724c05..fe735c29d 100644 --- a/src/enums/gui/themecolorid.h +++ b/src/enums/gui/themecolorid.h @@ -25,232 +25,232 @@ #ifndef GUI_THEMECOLORID_H #define GUI_THEMECOLORID_H -namespace ThemeColorId +#include "enums/simpletypes/enumdefines.h" + +enumStart(ThemeColorId) { - enum T - { - BROWSERBOX = 0, - BROWSERBOX_OUTLINE, - SELFNICK, - SELFNICK_OUTLINE, - TEXT, - TEXT_OUTLINE, - CARET, - SHADOW, - OUTLINE, - BORDER, - PROGRESS_BAR, - PROGRESS_BAR_OUTLINE, - BUTTON, - BUTTON_OUTLINE, - BUTTON_DISABLED, - BUTTON_DISABLED_OUTLINE, - BUTTON_HIGHLIGHTED, - BUTTON_HIGHLIGHTED_OUTLINE, - BUTTON_PRESSED, - BUTTON_PRESSED_OUTLINE, - CHECKBOX, - CHECKBOX_OUTLINE, - DROPDOWN, - DROPDOWN_OUTLINE, - LABEL, - LABEL_OUTLINE, - LISTBOX, - LISTBOX_OUTLINE, - LISTBOX_SELECTED, - LISTBOX_SELECTED_OUTLINE, - RADIOBUTTON, - RADIOBUTTON_OUTLINE, - POPUP, - POPUP_OUTLINE, - TAB, - TAB_OUTLINE, - TAB_HIGHLIGHTED, - TAB_HIGHLIGHTED_OUTLINE, - TAB_SELECTED, - TAB_SELECTED_OUTLINE, - TEXTBOX, - TEXTFIELD, - TEXTFIELD_OUTLINE, - WINDOW, - WINDOW_OUTLINE, - BATTLE_CHAT_TAB, - BATTLE_CHAT_TAB_OUTLINE, - CHANNEL_CHAT_TAB, - CHANNEL_CHAT_TAB_OUTLINE, - PARTY_CHAT_TAB, - PARTY_CHAT_TAB_OUTLINE, - PARTY_SOCIAL_TAB, - PARTY_SOCIAL_TAB_OUTLINE, - GUILD_CHAT_TAB, - GUILD_CHAT_TAB_OUTLINE, - GUILD_SOCIAL_TAB, - GUILD_SOCIAL_TAB_OUTLINE, - GM_CHAT_TAB, - GM_CHAT_TAB_OUTLINE, - BATTLE_CHAT_TAB_HIGHLIGHTED, - BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE, - CHANNEL_CHAT_TAB_HIGHLIGHTED, - CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE, - PARTY_CHAT_TAB_HIGHLIGHTED, - PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE, - PARTY_SOCIAL_TAB_HIGHLIGHTED, - PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, - GUILD_CHAT_TAB_HIGHLIGHTED, - GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE, - GUILD_SOCIAL_TAB_HIGHLIGHTED, - GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, - GM_CHAT_TAB_HIGHLIGHTED, - GM_CHAT_TAB_HIGHLIGHTED_OUTLINE, - BATTLE_CHAT_TAB_SELECTED, - BATTLE_CHAT_TAB_SELECTED_OUTLINE, - CHANNEL_CHAT_TAB_SELECTED, - CHANNEL_CHAT_TAB_SELECTED_OUTLINE, - PARTY_CHAT_TAB_SELECTED, - PARTY_CHAT_TAB_SELECTED_OUTLINE, - PARTY_SOCIAL_TAB_SELECTED, - PARTY_SOCIAL_TAB_SELECTED_OUTLINE, - GUILD_CHAT_TAB_SELECTED, - GUILD_CHAT_TAB_SELECTED_OUTLINE, - GUILD_SOCIAL_TAB_SELECTED, - GUILD_SOCIAL_TAB_SELECTED_OUTLINE, - GM_CHAT_TAB_SELECTED, - GM_CHAT_TAB_SELECTED_OUTLINE, - BACKGROUND, - BACKGROUND_GRAY, - SCROLLBAR_GRAY, - DROPDOWN_SHADOW, - HIGHLIGHT, - HIGHLIGHT_OUTLINE, - TAB_FLASH, - TAB_FLASH_OUTLINE, - TAB_PLAYER_FLASH, - TAB_PLAYER_FLASH_OUTLINE, - SHOP_WARNING, - ITEM_EQUIPPED, - ITEM_EQUIPPED_OUTLINE, - ITEM_NOT_EQUIPPED, - ITEM_NOT_EQUIPPED_OUTLINE, - CHAT, - CHAT_OUTLINE, - GM, - GM_OUTLINE, - GLOBAL, - GLOBAL_OUTLINE, - PLAYER, - PLAYER_OUTLINE, - WHISPER_TAB, - WHISPER_TAB_OUTLINE, - WHISPER_TAB_OFFLINE, - WHISPER_TAB_OFFLINE_OUTLINE, - WHISPER_TAB_HIGHLIGHTED, - WHISPER_TAB_HIGHLIGHTED_OUTLINE, - WHISPER_TAB_OFFLINE_HIGHLIGHTED, - WHISPER_TAB_OFFLINE_HIGHLIGHTED_OUTLINE, - WHISPER_TAB_SELECTED, - WHISPER_TAB_SELECTED_OUTLINE, - WHISPER_TAB_OFFLINE_SELECTED, - WHISPER_TAB_OFFLINE_SELECTED_OUTLINE, - IS, - IS_OUTLINE, - SERVER, - SERVER_OUTLINE, - LOGGER, - LOGGER_OUTLINE, - HYPERLINK, - HYPERLINK_OUTLINE, - UNKNOWN_ITEM, - UNKNOWN_ITEM_OUTLINE, - GENERIC, - GENERIC_OUTLINE, - HEAD, - HEAD_OUTLINE, - USABLE, - USABLE_OUTLINE, - TORSO, - TORSO_OUTLINE, - ONEHAND, - ONEHAND_OUTLINE, - LEGS, - LEGS_OUTLINE, - FEET, - FEET_OUTLINE, - TWOHAND, - TWOHAND_OUTLINE, - SHIELD, - SHIELD_OUTLINE, - RING, - RING_OUTLINE, - NECKLACE, - NECKLACE_OUTLINE, - ARMS, - ARMS_OUTLINE, - AMMO, - AMMO_OUTLINE, - SERVER_VERSION_NOT_SUPPORTED, - SERVER_VERSION_NOT_SUPPORTED_OUTLINE, - WARNING, - WARNING_OUTLINE, - CHARM, - CHARM_OUTLINE, - PLAYER_ADVANCED, - PLAYER_ADVANCED_OUTLINE, - BUBBLE_NAME, - BUBBLE_NAME_OUTLINE, - BUBBLE_TEXT, - BUBBLE_TEXT_OUTLINE, - BLACK, - BLACK_OUTLINE, - RED, - RED_OUTLINE, - GREEN, - GREEN_OUTLINE, - BLUE, - BLUE_OUTLINE, - ORANGE, - ORANGE_OUTLINE, - YELLOW, - YELLOW_OUTLINE, - PINK, - PINK_OUTLINE, - PURPLE, - PURPLE_OUTLINE, - GRAY, - GRAY_OUTLINE, - BROWN, - BROWN_OUTLINE, - STATUSBAR_ON, - STATUSBAR_OFF, - TABLE_BACKGROUND, - SLOTS_BAR, - SLOTS_BAR_OUTLINE, - HP_BAR, - HP_BAR_OUTLINE, - MP_BAR, - MP_BAR_OUTLINE, - NO_MP_BAR, - NO_MP_BAR_OUTLINE, - XP_BAR, - XP_BAR_OUTLINE, - WEIGHT_BAR, - WEIGHT_BAR_OUTLINE, - MONEY_BAR, - MONEY_BAR_OUTLINE, - ARROWS_BAR, - ARROWS_BAR_OUTLINE, - STATUS_BAR, - STATUS_BAR_OUTLINE, - JOB_BAR, - JOB_BAR_OUTLINE, - OLDCHAT, - OLDCHAT_OUTLINE, - AWAYCHAT, - AWAYCHAT_OUTLINE, - SKILL_COOLDOWN, - TEXT_DISABLED, - TEXT_DISABLED_OUTLINE, - THEME_COLORS_END - }; -} // namespace ThemeColorId + BROWSERBOX = 0, + BROWSERBOX_OUTLINE, + SELFNICK, + SELFNICK_OUTLINE, + TEXT, + TEXT_OUTLINE, + CARET, + SHADOW, + OUTLINE, + BORDER, + PROGRESS_BAR, + PROGRESS_BAR_OUTLINE, + BUTTON, + BUTTON_OUTLINE, + BUTTON_DISABLED, + BUTTON_DISABLED_OUTLINE, + BUTTON_HIGHLIGHTED, + BUTTON_HIGHLIGHTED_OUTLINE, + BUTTON_PRESSED, + BUTTON_PRESSED_OUTLINE, + CHECKBOX, + CHECKBOX_OUTLINE, + DROPDOWN, + DROPDOWN_OUTLINE, + LABEL, + LABEL_OUTLINE, + LISTBOX, + LISTBOX_OUTLINE, + LISTBOX_SELECTED, + LISTBOX_SELECTED_OUTLINE, + RADIOBUTTON, + RADIOBUTTON_OUTLINE, + POPUP, + POPUP_OUTLINE, + TAB, + TAB_OUTLINE, + TAB_HIGHLIGHTED, + TAB_HIGHLIGHTED_OUTLINE, + TAB_SELECTED, + TAB_SELECTED_OUTLINE, + TEXTBOX, + TEXTFIELD, + TEXTFIELD_OUTLINE, + WINDOW, + WINDOW_OUTLINE, + BATTLE_CHAT_TAB, + BATTLE_CHAT_TAB_OUTLINE, + CHANNEL_CHAT_TAB, + CHANNEL_CHAT_TAB_OUTLINE, + PARTY_CHAT_TAB, + PARTY_CHAT_TAB_OUTLINE, + PARTY_SOCIAL_TAB, + PARTY_SOCIAL_TAB_OUTLINE, + GUILD_CHAT_TAB, + GUILD_CHAT_TAB_OUTLINE, + GUILD_SOCIAL_TAB, + GUILD_SOCIAL_TAB_OUTLINE, + GM_CHAT_TAB, + GM_CHAT_TAB_OUTLINE, + BATTLE_CHAT_TAB_HIGHLIGHTED, + BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE, + CHANNEL_CHAT_TAB_HIGHLIGHTED, + CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE, + PARTY_CHAT_TAB_HIGHLIGHTED, + PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE, + PARTY_SOCIAL_TAB_HIGHLIGHTED, + PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, + GUILD_CHAT_TAB_HIGHLIGHTED, + GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE, + GUILD_SOCIAL_TAB_HIGHLIGHTED, + GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, + GM_CHAT_TAB_HIGHLIGHTED, + GM_CHAT_TAB_HIGHLIGHTED_OUTLINE, + BATTLE_CHAT_TAB_SELECTED, + BATTLE_CHAT_TAB_SELECTED_OUTLINE, + CHANNEL_CHAT_TAB_SELECTED, + CHANNEL_CHAT_TAB_SELECTED_OUTLINE, + PARTY_CHAT_TAB_SELECTED, + PARTY_CHAT_TAB_SELECTED_OUTLINE, + PARTY_SOCIAL_TAB_SELECTED, + PARTY_SOCIAL_TAB_SELECTED_OUTLINE, + GUILD_CHAT_TAB_SELECTED, + GUILD_CHAT_TAB_SELECTED_OUTLINE, + GUILD_SOCIAL_TAB_SELECTED, + GUILD_SOCIAL_TAB_SELECTED_OUTLINE, + GM_CHAT_TAB_SELECTED, + GM_CHAT_TAB_SELECTED_OUTLINE, + BACKGROUND, + BACKGROUND_GRAY, + SCROLLBAR_GRAY, + DROPDOWN_SHADOW, + HIGHLIGHT, + HIGHLIGHT_OUTLINE, + TAB_FLASH, + TAB_FLASH_OUTLINE, + TAB_PLAYER_FLASH, + TAB_PLAYER_FLASH_OUTLINE, + SHOP_WARNING, + ITEM_EQUIPPED, + ITEM_EQUIPPED_OUTLINE, + ITEM_NOT_EQUIPPED, + ITEM_NOT_EQUIPPED_OUTLINE, + CHAT, + CHAT_OUTLINE, + GM, + GM_OUTLINE, + GLOBAL, + GLOBAL_OUTLINE, + PLAYER, + PLAYER_OUTLINE, + WHISPER_TAB, + WHISPER_TAB_OUTLINE, + WHISPER_TAB_OFFLINE, + WHISPER_TAB_OFFLINE_OUTLINE, + WHISPER_TAB_HIGHLIGHTED, + WHISPER_TAB_HIGHLIGHTED_OUTLINE, + WHISPER_TAB_OFFLINE_HIGHLIGHTED, + WHISPER_TAB_OFFLINE_HIGHLIGHTED_OUTLINE, + WHISPER_TAB_SELECTED, + WHISPER_TAB_SELECTED_OUTLINE, + WHISPER_TAB_OFFLINE_SELECTED, + WHISPER_TAB_OFFLINE_SELECTED_OUTLINE, + IS, + IS_OUTLINE, + SERVER, + SERVER_OUTLINE, + LOGGER, + LOGGER_OUTLINE, + HYPERLINK, + HYPERLINK_OUTLINE, + UNKNOWN_ITEM, + UNKNOWN_ITEM_OUTLINE, + GENERIC, + GENERIC_OUTLINE, + HEAD, + HEAD_OUTLINE, + USABLE, + USABLE_OUTLINE, + TORSO, + TORSO_OUTLINE, + ONEHAND, + ONEHAND_OUTLINE, + LEGS, + LEGS_OUTLINE, + FEET, + FEET_OUTLINE, + TWOHAND, + TWOHAND_OUTLINE, + SHIELD, + SHIELD_OUTLINE, + RING, + RING_OUTLINE, + NECKLACE, + NECKLACE_OUTLINE, + ARMS, + ARMS_OUTLINE, + AMMO, + AMMO_OUTLINE, + SERVER_VERSION_NOT_SUPPORTED, + SERVER_VERSION_NOT_SUPPORTED_OUTLINE, + WARNING, + WARNING_OUTLINE, + CHARM, + CHARM_OUTLINE, + PLAYER_ADVANCED, + PLAYER_ADVANCED_OUTLINE, + BUBBLE_NAME, + BUBBLE_NAME_OUTLINE, + BUBBLE_TEXT, + BUBBLE_TEXT_OUTLINE, + BLACK, + BLACK_OUTLINE, + RED, + RED_OUTLINE, + GREEN, + GREEN_OUTLINE, + BLUE, + BLUE_OUTLINE, + ORANGE, + ORANGE_OUTLINE, + YELLOW, + YELLOW_OUTLINE, + PINK, + PINK_OUTLINE, + PURPLE, + PURPLE_OUTLINE, + GRAY, + GRAY_OUTLINE, + BROWN, + BROWN_OUTLINE, + STATUSBAR_ON, + STATUSBAR_OFF, + TABLE_BACKGROUND, + SLOTS_BAR, + SLOTS_BAR_OUTLINE, + HP_BAR, + HP_BAR_OUTLINE, + MP_BAR, + MP_BAR_OUTLINE, + NO_MP_BAR, + NO_MP_BAR_OUTLINE, + XP_BAR, + XP_BAR_OUTLINE, + WEIGHT_BAR, + WEIGHT_BAR_OUTLINE, + MONEY_BAR, + MONEY_BAR_OUTLINE, + ARROWS_BAR, + ARROWS_BAR_OUTLINE, + STATUS_BAR, + STATUS_BAR_OUTLINE, + JOB_BAR, + JOB_BAR_OUTLINE, + OLDCHAT, + OLDCHAT_OUTLINE, + AWAYCHAT, + AWAYCHAT_OUTLINE, + SKILL_COOLDOWN, + TEXT_DISABLED, + TEXT_DISABLED_OUTLINE, + THEME_COLORS_END +} +enumEnd(ThemeColorId); #endif // GUI_THEMECOLORID_H 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, diff --git a/src/input/inputactionoperators.h b/src/input/inputactionoperators.h index a01c75bf8..88ed38629 100644 --- a/src/input/inputactionoperators.h +++ b/src/input/inputactionoperators.h @@ -1,8 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2015 The ManaPlus Developers + * Copyright (C) 2015 The ManaPlus Developers * * This file is part of The ManaPlus Client. * |