summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-04-22 22:17:50 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-04-25 21:20:38 +0200
commit53e22afe92e7f360ce0de5cbb013f3257081bdb8 (patch)
treebe8fb3425d4ec99392a96611ed8c57831141bb55
parent243b6c163cd91b874265d5acee57e754dec2e979 (diff)
downloadmana-53e22afe92e7f360ce0de5cbb013f3257081bdb8.tar.gz
mana-53e22afe92e7f360ce0de5cbb013f3257081bdb8.tar.bz2
mana-53e22afe92e7f360ce0de5cbb013f3257081bdb8.tar.xz
mana-53e22afe92e7f360ce0de5cbb013f3257081bdb8.zip
GUI: Added support for multiple color palettes to Theme
Each Skin can point to a different palette, which can be used to tweak text colors where necessary. For now there is no generic solution for this, instead a number of locations have been adjusted to take the palette into account: * ChatWindow sets its palette on the BrowserBox used in its tabs. * Popup sets its palette on child widgets when they are added (covering BrowserBox, Label and TextBox). * ItemPopup now uses its palette when looking up colors. The BrowserBox now retrieves its numbered text colors from the theme. Also added OLDCHAT, AWAYCHAT and GLOBAL theme colors, with ##g, ##o and ##a to choose these colors respectively. Fixed ImageRect move constructor. TextPreview class was cleaned up from unused functionality. Being name colors are no longer different between the name shown on the being and the name shown in the SpeechDialog.
-rw-r--r--data/graphics/gui/jewelry/theme.xml493
-rw-r--r--data/graphics/gui/theme.xml88
-rw-r--r--src/being.cpp42
-rw-r--r--src/being.h1
-rw-r--r--src/graphics.cpp10
-rw-r--r--src/gui/chatwindow.cpp2
-rw-r--r--src/gui/itempopup.cpp40
-rw-r--r--src/gui/palette.cpp32
-rw-r--r--src/gui/palette.h50
-rw-r--r--src/gui/serverdialog.cpp15
-rw-r--r--src/gui/setup_colors.cpp35
-rw-r--r--src/gui/skilldialog.cpp6
-rw-r--r--src/gui/widgets/avatarlistbox.cpp8
-rw-r--r--src/gui/widgets/browserbox.cpp78
-rw-r--r--src/gui/widgets/browserbox.h26
-rw-r--r--src/gui/widgets/chattab.cpp2
-rw-r--r--src/gui/widgets/container.h2
-rw-r--r--src/gui/widgets/dropdown.cpp7
-rw-r--r--src/gui/widgets/label.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp8
-rw-r--r--src/gui/widgets/popup.cpp43
-rw-r--r--src/gui/widgets/popup.h11
-rw-r--r--src/gui/widgets/shoplistbox.cpp18
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/tabbedarea.h6
-rw-r--r--src/gui/widgets/table.cpp25
-rw-r--r--src/gui/widgets/table.h34
-rw-r--r--src/gui/widgets/textpreview.cpp42
-rw-r--r--src/gui/widgets/textpreview.h50
-rw-r--r--src/gui/widgets/window.cpp18
-rw-r--r--src/gui/widgets/window.h5
-rw-r--r--src/resources/theme.cpp125
-rw-r--r--src/resources/theme.h47
-rw-r--r--src/textrenderer.h16
-rw-r--r--src/utils/xml.h8
35 files changed, 875 insertions, 522 deletions
diff --git a/data/graphics/gui/jewelry/theme.xml b/data/graphics/gui/jewelry/theme.xml
index 0d11f61a..a20ba2d3 100644
--- a/data/graphics/gui/jewelry/theme.xml
+++ b/data/graphics/gui/jewelry/theme.xml
@@ -1,103 +1,394 @@
<theme name="Jewelry">
- <color id="BROWSERBOX" color="#000000" />
- <color id="SELFNICK" color="#402600" />
- <color id="TEXT" color="#402600" />
- <color id="TEXT_DISABLED" color="#402600" />
- <color id="CARET" color="#80561f" />
- <color id="SHADOW" color="#000000" />
- <color id="OUTLINE" color="#000000" />
- <color id="BORDER" color="#000000" />
- <color id="CHECKBOX" color="#000000" />
- <color id="DROPDOWN" color="#000000" />
- <color id="LISTBOX" color="#000000" />
- <color id="LISTBOX_SELECTED" color="#000000" />
- <color id="RADIOBUTTON" color="#000000" />
- <color id="POPUP" color="#f9eabc" />
- <color id="BATTLE_CHAT_TAB" color="#efd7a7" />
- <color id="BATTLE_CHAT_TAB_OUTLINE" color="#473005" />
- <color id="BATTLE_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
- <color id="BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
- <color id="BATTLE_CHAT_TAB_SELECTED" color="#f8eacf" />
- <color id="BATTLE_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
- <color id="CHANNEL_CHAT_TAB" color="#efd7a7" />
- <color id="CHANNEL_CHAT_TAB_OUTLINE" color="#473005" />
- <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
- <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
- <color id="CHANNEL_CHAT_TAB_SELECTED" color="#f8eacf" />
- <color id="CHANNEL_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
- <color id="BACKGROUND" color="#ffffff" />
- <color id="BACKGROUND_GRAY" color="#404040" />
- <color id="DROPDOWN_SHADOW" color="#c0c0c0" />
- <color id="HIGHLIGHT" color="#ebc873" />
- <color id="TAB_FLASH" color="#fec4ff" effect="pulse" />
- <color id="TAB_PLAYER_FLASH" color="#00ff00" effect="pulse" />
- <color id="SHOP_WARNING" color="#e07a7a" />
- <color id="ITEM_EQUIPPED" color="#000091" />
- <color id="ITEM_NOT_EQUIPPED" color="#000000" />
- <color id="CHAT" color="#f1d9a9" />
- <color id="GM" color="#fec4ff" />
- <color id="GLOBAL" color="#fec4ff" />
- <color id="PLAYER" color="#eeeeee" />
- <color id="IS" color="#edbedb" />
- <color id="SERVER" color="#edbedb" />
- <color id="LOGGER" color="#919191" />
- <color id="HYPERLINK" color="#ab15bd" />
- <color id="UNKNOWN_ITEM" color="#ffffff" />
- <color id="CHARM" color="#ffffff" />
- <color id="GENERIC" color="#eeeeee" />
- <color id="CARD" color="#eeeeee" />
- <color id="HEAD" color="#b4d7ec" />
- <color id="USABLE" color="#ece9b4" />
- <color id="TORSO" color="#b4d7ec" />
- <color id="ONEHAND" color="#b4d7ec" />
- <color id="LEGS" color="#b4d7ec" />
- <color id="FEET" color="#b4d7ec" />
- <color id="TWOHAND" color="#b4d7ec" />
- <color id="SHIELD" color="#b4d7ec" />
- <color id="RING" color="#b4d7ec" />
- <color id="NECKLACE" color="#b4d7ec" />
- <color id="ARMS" color="#b4d7ec" />
- <color id="AMMO" color="#b4d7ec" />
- <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
- <color id="WARNING" color="#FF0000" />
- <color id="PLAYER_ADVANCED" color="#005000" />
- <color id="BUBBLE_NAME" color="#cccccc" />
- <color id="BUBBLE_TEXT" color="#ffffff" />
- <color id="BLACK" color="#000000" />
- <color id="RED" color="#ff0000" />
- <color id="GREEN" color="#009000" />
- <color id="BLUE" color="#0000ff" />
- <color id="ORANGE" color="#e0980e" />
- <color id="YELLOW" color="#f1dc27" />
- <color id="PINK" color="#ff00d8" />
- <color id="PURPLE" color="#8415e2" />
- <color id="GRAY" color="#919191" />
- <color id="BROWN" color="#774217" />
- <color id="OLDCHAT" color="#774217" />
- <color id="STATUSBAR_ON" color="#646464" />
- <color id="STATUSBAR_OFF" color="#ffff00" />
- <color id="TABLE_BACKGROUND" color="#bfbfbf" />
- <color id="SLOTS_BAR" color="#ffffff" />
- <color id="SLOTS_BAR_OUTLINE" color="#000000" />
- <color id="HP_BAR" color="#ffffff" />
- <color id="HP_BAR_OUTLINE" color="#000000" />
- <color id="MP_BAR" color="#ffffff" />
- <color id="MP_BAR_OUTLINE" color="#000000" />
- <color id="NO_MP_BAR" color="#ffffff" />
- <color id="NO_MP_BAR_OUTLINE" color="#000000" />
- <color id="XP_BAR" color="#ffffff" />
- <color id="XP_BAR_OUTLINE" color="#000000" />
- <color id="WEIGHT_BAR" color="#ffffff" />
- <color id="WEIGHT_BAR_OUTLINE" color="#000000" />
- <color id="MONEY_BAR" color="#ffffff" />
- <color id="MONEY_BAR_OUTLINE" color="#000000" />
- <color id="ARROWS_BAR" color="#ffffff" />
- <color id="ARROWS_BAR_OUTLINE" color="#000000" />
- <color id="STATUS_BAR" color="#ffffff" />
- <color id="STATUS_BAR_OUTLINE" color="#000000" />
- <color id="JOB_BAR" color="#ffffff" />
- <color id="JOB_BAR_OUTLINE" color="#000000" />
- <color id="SKILL_COOLDOWN" color="#5090ff" />
+ <palette id="0">
+ <color id="BROWSERBOX" color="#000000" />
+ <color id="SELFNICK" color="#402600" />
+ <color id="TEXT" color="#402600" />
+ <color id="TEXT_DISABLED" color="#402600" />
+ <color id="CARET" color="#80561f" />
+ <color id="SHADOW" color="#000000" />
+ <color id="OUTLINE" color="#000000" />
+ <color id="BORDER" color="#000000" />
+ <color id="CHECKBOX" color="#000000" />
+ <color id="DROPDOWN" color="#000000" />
+ <color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
+ <color id="RADIOBUTTON" color="#000000" />
+ <color id="POPUP" color="#f9eabc" />
+ <color id="BATTLE_CHAT_TAB" color="#efd7a7" />
+ <color id="BATTLE_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="BATTLE_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="CHANNEL_CHAT_TAB" color="#efd7a7" />
+ <color id="CHANNEL_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="BACKGROUND" color="#ffffff" />
+ <color id="BACKGROUND_GRAY" color="#404040" />
+ <color id="DROPDOWN_SHADOW" color="#c0c0c0" />
+ <color id="HIGHLIGHT" color="#ebc873" />
+ <color id="TAB_FLASH" color="#fec4ff" effect="pulse" />
+ <color id="TAB_PLAYER_FLASH" color="#00ff00" effect="pulse" />
+ <color id="SHOP_WARNING" color="#e07a7a" />
+ <color id="ITEM_EQUIPPED" color="#000091" />
+ <color id="ITEM_NOT_EQUIPPED" color="#000000" />
+ <color id="CHAT" color="#f1d9a9" />
+ <color id="GM" color="#fec4ff" />
+ <color id="GLOBAL" color="#fec4ff" />
+ <color id="PLAYER" color="#eeeeee" />
+ <color id="IS" color="#edbedb" />
+ <color id="SERVER" color="#edbedb" />
+ <color id="LOGGER" color="#919191" />
+ <color id="HYPERLINK" color="#ab15bd" />
+ <color id="UNKNOWN_ITEM" color="#ffffff" />
+ <color id="CHARM" color="#ffffff" />
+ <color id="GENERIC" color="#eeeeee" />
+ <color id="CARD" color="#eeeeee" />
+ <color id="HEAD" color="#b4d7ec" />
+ <color id="USABLE" color="#ece9b4" />
+ <color id="TORSO" color="#b4d7ec" />
+ <color id="ONEHAND" color="#b4d7ec" />
+ <color id="LEGS" color="#b4d7ec" />
+ <color id="FEET" color="#b4d7ec" />
+ <color id="TWOHAND" color="#b4d7ec" />
+ <color id="SHIELD" color="#b4d7ec" />
+ <color id="RING" color="#b4d7ec" />
+ <color id="NECKLACE" color="#b4d7ec" />
+ <color id="ARMS" color="#b4d7ec" />
+ <color id="AMMO" color="#b4d7ec" />
+ <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
+ <color id="WARNING" color="#FF0000" />
+ <color id="PLAYER_ADVANCED" color="#005000" />
+ <color id="BUBBLE_NAME" color="#cccccc" />
+ <color id="BUBBLE_TEXT" color="#ffffff" />
+ <color id="BLACK" color="#000000" />
+ <color id="RED" color="#ff0000" />
+ <color id="GREEN" color="#009000" />
+ <color id="BLUE" color="#0000ff" />
+ <color id="ORANGE" color="#e0980e" />
+ <color id="YELLOW" color="#f1dc27" />
+ <color id="PINK" color="#ff00d8" />
+ <color id="PURPLE" color="#8415e2" />
+ <color id="GRAY" color="#919191" />
+ <color id="BROWN" color="#774217" />
+ <color id="OLDCHAT" color="#774217" />
+ <color id="STATUSBAR_ON" color="#646464" />
+ <color id="STATUSBAR_OFF" color="#ffff00" />
+ <color id="TABLE_BACKGROUND" color="#bfbfbf" />
+ <color id="SLOTS_BAR" color="#ffffff" />
+ <color id="SLOTS_BAR_OUTLINE" color="#000000" />
+ <color id="HP_BAR" color="#ffffff" />
+ <color id="HP_BAR_OUTLINE" color="#000000" />
+ <color id="MP_BAR" color="#ffffff" />
+ <color id="MP_BAR_OUTLINE" color="#000000" />
+ <color id="NO_MP_BAR" color="#ffffff" />
+ <color id="NO_MP_BAR_OUTLINE" color="#000000" />
+ <color id="XP_BAR" color="#ffffff" />
+ <color id="XP_BAR_OUTLINE" color="#000000" />
+ <color id="WEIGHT_BAR" color="#ffffff" />
+ <color id="WEIGHT_BAR_OUTLINE" color="#000000" />
+ <color id="MONEY_BAR" color="#ffffff" />
+ <color id="MONEY_BAR_OUTLINE" color="#000000" />
+ <color id="ARROWS_BAR" color="#ffffff" />
+ <color id="ARROWS_BAR_OUTLINE" color="#000000" />
+ <color id="STATUS_BAR" color="#ffffff" />
+ <color id="STATUS_BAR_OUTLINE" color="#000000" />
+ <color id="JOB_BAR" color="#ffffff" />
+ <color id="JOB_BAR_OUTLINE" color="#000000" />
+ <color id="SKILL_COOLDOWN" color="#5090ff" />
+ </palette>
+
+ <palette id="1">
+ <color id="SELFNICK" color="#402600" />
+ <color id="TEXT" color="#f9eabc" />
+ <color id="TEXT_DISABLED" color="#f9eabc" />
+ <color id="CARET" color="#80561f" />
+ <color id="SHADOW" color="#000000" />
+ <color id="OUTLINE" color="#000000" />
+ <color id="BORDER" color="#000000" />
+ <color id="CHECKBOX" color="#000000" />
+ <color id="DROPDOWN" color="#000000" />
+ <color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
+ <color id="RADIOBUTTON" color="#000000" />
+ <color id="POPUP" color="#fbf4c4" />
+ <color id="POPUP_OUTLINE" color="#42403a" />
+ <color id="BATTLE_CHAT_TAB" color="#efd7a7" />
+ <color id="BATTLE_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="BATTLE_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="CHANNEL_CHAT_TAB" color="#efd7a7" />
+ <color id="CHANNEL_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="TAB_FLASH" color="#a7ff2a" />
+ <color id="TAB_FLASH_OUTLINE" color="#142200" />
+ <color id="TAB_PLAYER_FLASH" color="#ff96f6" />
+ <color id="PARTY_CHAT_TAB" color="#efd7a7" />
+ <color id="PARTY_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="PARTY_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="PARTY_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="PARTY_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="PARTY_SOCIAL_TAB" color="#efd7a7" />
+ <color id="PARTY_SOCIAL_TAB_OUTLINE" color="#473005" />
+ <color id="PARTY_SOCIAL_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="PARTY_SOCIAL_TAB_SELECTED" color="#f8eacf" />
+ <color id="PARTY_SOCIAL_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="GUILD_CHAT_TAB" color="#efd7a7" />
+ <color id="GUILD_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="GUILD_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="GUILD_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="GUILD_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="GUILD_SOCIAL_TAB" color="#efd7a7" />
+ <color id="GUILD_SOCIAL_TAB_OUTLINE" color="#473005" />
+ <color id="GUILD_SOCIAL_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="GUILD_SOCIAL_TAB_SELECTED" color="#f8eacf" />
+ <color id="GUILD_SOCIAL_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="CLAN_CHAT_TAB" color="#efd7a7" />
+ <color id="CLAN_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="CLAN_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="CLAN_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="CLAN_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="CLAN_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="GM_CHAT_TAB" color="#efd7a7" />
+ <color id="GM_CHAT_TAB_OUTLINE" color="#473005" />
+ <color id="GM_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="GM_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="GM_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="GM_CHAT_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="WHISPER_TAB" color="#efd7a7" />
+ <color id="WHISPER_TAB_OUTLINE" color="#473005" />
+ <color id="WHISPER_TAB_OFFLINE" color="#444444" />
+ <color id="WHISPER_TAB_OFFLINE_OUTLINE" color="#000000" />
+ <color id="WHISPER_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="WHISPER_TAB_HIGHLIGHTED_OUTLINE" color="#63450a" />
+ <color id="WHISPER_TAB_OFFLINE_HIGHLIGHTED" color="#fffbed" />
+ <color id="WHISPER_TAB_OFFLINE_HIGHLIGHTED_OUTLINE" color="#000000" />
+ <color id="WHISPER_TAB_SELECTED" color="#f8eacf" />
+ <color id="WHISPER_TAB_SELECTED_OUTLINE" color="#63450a" />
+ <color id="WHISPER_TAB_OFFLINE_SELECTED" color="#444444" />
+ <color id="WHISPER_TAB_OFFLINE_SELECTED_OUTLINE" color="#000000" />
+ <color id="BACKGROUND" color="#ffffff" />
+ <color id="BACKGROUND_GRAY" color="#404040" />
+ <color id="DROPDOWN_SHADOW" color="#c0c0c0" />
+ <color id="HIGHLIGHT" color="#ebc873" />
+ <color id="SHOP_WARNING" color="#e07a7a" />
+ <color id="ITEM_EQUIPPED" color="#000091" />
+ <color id="ITEM_NOT_EQUIPPED" color="#000000" />
+ <color id="BUBBLE_NAME" color="#cccccc" />
+ <color id="BUBBLE_TEXT" color="#ffffff" />
+ <color id="LOGGER" color="#919191" />
+ <color id="HYPERLINK" color="#bcdff4" />
+ <color id="HYPERLINK_OUTLINE" color="#052f47" />
+ <color id="UNKNOWN_ITEM" color="#ffffff" />
+ <color id="CHARM" color="#ffffff" />
+ <color id="GENERIC" color="#dbdbdb" />
+ <color id="GENERIC_OUTLINE" color="#333333" />
+ <color id="CARD" color="#dbdbdb" />
+ <color id="CARD_OUTLINE" color="#333333" />
+ <color id="HEAD" color="#f8eb7c" />
+ <color id="HEAD_OUTLINE" color="#382a01" />
+ <color id="USABLE" color="#b4d7ec" />
+ <color id="USABLE_OUTLINE" color="#052f47" />
+ <color id="TORSO" color="#f8eb7c" />
+ <color id="TORSO_OUTLINE" color="#382a01" />
+ <color id="ONEHAND" color="#f8eb7c" />
+ <color id="ONEHAND_OUTLINE" color="#382a01" />
+ <color id="LEGS" color="#f8eb7c" />
+ <color id="LEGS_OUTLINE" color="#382a01" />
+ <color id="FEET" color="#f8eb7c" />
+ <color id="FEET_OUTLINE" color="#382a01" />
+ <color id="TWOHAND" color="#f8eb7c" />
+ <color id="TWOHAND_OUTLINE" color="#382a01" />
+ <color id="SHIELD" color="#f8eb7c" />
+ <color id="SHIELD_OUTLINE" color="#382a01" />
+ <color id="RING" color="#f8eb7c" />
+ <color id="RING_OUTLINE" color="#382a01" />
+ <color id="NECKLACE" color="#f8eb7c" />
+ <color id="NECKLACE_OUTLINE" color="#382a01" />
+ <color id="ARMS" color="#f8eb7c" />
+ <color id="ARMS_OUTLINE" color="#382a01" />
+ <color id="AMMO" color="#f8eb7c" />
+ <color id="AMMO_OUTLINE" color="#382a01" />
+ <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
+ <color id="WARNING" color="#FF0000" />
+ <color id="CHAT" color="#ffffff" />
+ <color id="CHAT_OUTLINE" color="#3f3f3f" />
+ <color id="GM" color="#ff45fd" />
+ <color id="GM_OUTLINE" color="#44033a" />
+ <color id="GLOBAL" color="#ff45fd" />
+ <color id="GLOBAL_OUTLINE" color="#44033a" />
+ <color id="PLAYER" color="#bcdff4" />
+ <color id="PLAYER_OUTLINE" color="#052f47" />
+ <color id="PLAYER_ADVANCED" color="#f9eabc" />
+ <color id="PLAYER_ADVANCED_OUTLINE" color="#3b2b04" />
+ <color id="IS" color="#77deff" />
+ <color id="IS_OUTLINE" color="#02232e" />
+ <color id="SERVER" color="#a7ff2a" />
+ <color id="SERVER_OUTLINE" color="#142200" />
+ <color id="BROWSERBOX" color="#999999" />
+ <color id="BROWSERBOX_OUTLINE" color="#000000" />
+ <color id="BLACK" color="#999999" />
+ <color id="BLACK_OUTLINE" color="#000000" />
+ <color id="RED" color="#ff6565" />
+ <color id="RED_OUTLINE" color="#470303" />
+ <color id="GREEN" color="#57cb21" />
+ <color id="GREEN_OUTLINE" color="#0b3102" />
+ <color id="BLUE" color="#8080ff" />
+ <color id="BLUE_OUTLINE" color="#060646" />
+ <color id="ORANGE" color="#f1c777" />
+ <color id="ORANGE_OUTLINE" color="#3d2201" />
+ <color id="YELLOW" color="#f8eb7c" />
+ <color id="YELLOW_OUTLINE" color="#382a01" />
+ <color id="PINK" color="#ff90ee" />
+ <color id="PINK_OUTLINE" color="#44033a" />
+ <color id="PURPLE" color="#cd8cff" />
+ <color id="PURPLE_OUTLINE" color="#260341" />
+ <color id="GRAY" color="#dbdbdb" />
+ <color id="GRAY_OUTLINE" color="#333333" />
+ <color id="BROWN" color="#cb884c" />
+ <color id="BROWN_OUTLINE" color="#271802" />
+ <color id="OLDCHAT" color="#cb884c" />
+ <color id="OLDCHAT_OUTLINE" color="#271802" />
+ <color id="AWAYCHAT" color="#cb884c" />
+ <color id="AWAYCHAT_OUTLINE" color="#271802" />
+ <color id="STATUSBAR_ON" color="#646464" />
+ <color id="STATUSBAR_OFF" color="#ffff00" />
+ <color id="TABLE_BACKGROUND" color="#bfbfbf" />
+ <color id="SLOTS_BAR" color="#ffffff" />
+ <color id="SLOTS_BAR_OUTLINE" color="#000000" />
+ <color id="HP_BAR" color="#ffffff" />
+ <color id="HP_BAR_OUTLINE" color="#000000" />
+ <color id="MP_BAR" color="#ffffff" />
+ <color id="MP_BAR_OUTLINE" color="#000000" />
+ <color id="NO_MP_BAR" color="#ffffff" />
+ <color id="NO_MP_BAR_OUTLINE" color="#000000" />
+ <color id="XP_BAR" color="#ffffff" />
+ <color id="XP_BAR_OUTLINE" color="#000000" />
+ <color id="WEIGHT_BAR" color="#ffffff" />
+ <color id="WEIGHT_BAR_OUTLINE" color="#000000" />
+ <color id="MONEY_BAR" color="#ffffff" />
+ <color id="MONEY_BAR_OUTLINE" color="#000000" />
+ <color id="ARROWS_BAR" color="#ffffff" />
+ <color id="ARROWS_BAR_OUTLINE" color="#000000" />
+ <color id="STATUS_BAR" color="#ffffff" />
+ <color id="STATUS_BAR_OUTLINE" color="#000000" />
+ <color id="JOB_BAR" color="#ffffff" />
+ <color id="JOB_BAR_OUTLINE" color="#000000" />
+ </palette>
+
+ <palette id="2">
+ <color id="SELFNICK" color="#402600" />
+ <color id="TEXT" color="#402600" />
+ <color id="TEXT_DISABLED" color="#402600" />
+ <color id="CARET" color="#80561f" />
+ <color id="SHADOW" color="#000000" />
+ <color id="OUTLINE" color="#000000" />
+ <color id="BORDER" color="#000000" />
+ <color id="CHECKBOX" color="#000000" />
+ <color id="DROPDOWN" color="#000000" />
+ <color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
+ <color id="RADIOBUTTON" color="#000000" />
+ <color id="POPUP" color="#f9eabc" />
+ <color id="BATTLE_CHAT_TAB" color="#efd7a7" />
+ <color id="BATTLE_CHAT_TAB_OUTLINE" color="#000000" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#000000" />
+ <color id="BATTLE_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="BATTLE_CHAT_TAB_SELECTED_OUTLINE" color="#000000" />
+ <color id="CHANNEL_CHAT_TAB" color="#efd7a7" />
+ <color id="CHANNEL_CHAT_TAB_OUTLINE" color="#000000" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE" color="#000000" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED" color="#f8eacf" />
+ <color id="CHANNEL_CHAT_TAB_SELECTED_OUTLINE" color="#000000" />
+ <color id="BACKGROUND" color="#ffffff" />
+ <color id="BACKGROUND_GRAY" color="#404040" />
+ <color id="DROPDOWN_SHADOW" color="#c0c0c0" />
+ <color id="HIGHLIGHT" color="#ebc873" />
+ <color id="TAB_FLASH" color="#fec4ff" effect="pulse" />
+ <color id="TAB_PLAYER_FLASH" color="#00ff00" effect="pulse" />
+ <color id="SHOP_WARNING" color="#e07a7a" />
+ <color id="ITEM_EQUIPPED" color="#000091" />
+ <color id="ITEM_NOT_EQUIPPED" color="#000000" />
+ <color id="CHAT" color="#f1d9a9" />
+ <color id="GM" color="#fec4ff" />
+ <color id="GLOBAL" color="#fec4ff" />
+ <color id="PLAYER" color="#eeeeee" />
+ <color id="IS" color="#edbedb" />
+ <color id="SERVER" color="#edbedb" />
+ <color id="LOGGER" color="#919191" />
+ <color id="HYPERLINK" color="#9e1904" />
+ <color id="UNKNOWN_ITEM" color="#ffffff" />
+ <color id="CHARM" color="#ffffff" />
+ <color id="GENERIC" color="#eeeeee" />
+ <color id="CARD" color="#eeeeee" />
+ <color id="HEAD" color="#b4d7ec" />
+ <color id="USABLE" color="#ece9b4" />
+ <color id="TORSO" color="#b4d7ec" />
+ <color id="ONEHAND" color="#b4d7ec" />
+ <color id="LEGS" color="#b4d7ec" />
+ <color id="FEET" color="#b4d7ec" />
+ <color id="TWOHAND" color="#b4d7ec" />
+ <color id="SHIELD" color="#b4d7ec" />
+ <color id="RING" color="#b4d7ec" />
+ <color id="NECKLACE" color="#b4d7ec" />
+ <color id="ARMS" color="#b4d7ec" />
+ <color id="AMMO" color="#b4d7ec" />
+ <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
+ <color id="WARNING" color="#FF0000" />
+ <color id="PLAYER_ADVANCED" color="#005000" />
+ <color id="BUBBLE_NAME" color="#cccccc" />
+ <color id="BUBBLE_TEXT" color="#ffffff" />
+ <color id="BROWSERBOX" color="#000000" />
+ <color id="BLACK" color="#000000" />
+ <color id="RED" color="#b71313" />
+ <color id="GREEN" color="#307200" />
+ <color id="BLUE" color="#174b96" />
+ <color id="ORANGE" color="#f1c777" />
+ <color id="YELLOW" color="#f8eb7c" />
+ <color id="PINK" color="#91105f" />
+ <color id="PURPLE" color="#5e1298" />
+ <color id="GRAY" color="#dbdbdb" />
+ <color id="BROWN" color="#8e4c17" />
+ <color id="OLDCHAT" color="#8e4c17" />
+ <color id="AWAYCHAT" color="#8e4c17" />
+ <color id="STATUSBAR_ON" color="#646464" />
+ <color id="STATUSBAR_OFF" color="#ffff00" />
+ <color id="TABLE_BACKGROUND" color="#bfbfbf" />
+ <color id="SLOTS_BAR" color="#ffffff" />
+ <color id="SLOTS_BAR_OUTLINE" color="#000000" />
+ <color id="HP_BAR" color="#ffffff" />
+ <color id="HP_BAR_OUTLINE" color="#000000" />
+ <color id="MP_BAR" color="#ffffff" />
+ <color id="MP_BAR_OUTLINE" color="#000000" />
+ <color id="NO_MP_BAR" color="#ffffff" />
+ <color id="NO_MP_BAR_OUTLINE" color="#000000" />
+ <color id="XP_BAR" color="#ffffff" />
+ <color id="XP_BAR_OUTLINE" color="#000000" />
+ <color id="WEIGHT_BAR" color="#ffffff" />
+ <color id="WEIGHT_BAR_OUTLINE" color="#000000" />
+ <color id="MONEY_BAR" color="#ffffff" />
+ <color id="MONEY_BAR_OUTLINE" color="#000000" />
+ <color id="ARROWS_BAR" color="#ffffff" />
+ <color id="ARROWS_BAR_OUTLINE" color="#000000" />
+ <color id="STATUS_BAR" color="#ffffff" />
+ <color id="STATUS_BAR_OUTLINE" color="#000000" />
+ <color id="JOB_BAR" color="#ffffff" />
+ <color id="JOB_BAR_OUTLINE" color="#000000" />
+ </palette>
<progressbar id="DEFAULT" color="#969696" />
<progressbar id="HP" color="#b80000" />
@@ -131,14 +422,14 @@
</state>
</skin>
- <skin type="Popup" padding="9" titleBarHeight="26" titleOffsetX="8" titleOffsetY="8">
+ <skin type="Popup" padding="9" titleBarHeight="26" titleOffsetX="8" titleOffsetY="8" palette="1">
<state>
<text color="#f1d9a9" outlineColor="#000000"/>
<img src="window.png" x="220" y="107" width="107" height="41" left="9" right="9" top="9" bottom="9" />
</state>
</skin>
- <skin type="SpeechBubble" padding="4">
+ <skin type="SpeechBubble" padding="4" palette="1">
<state>
<img src="bubble.png|W:#000000" left="5" right="5" top="5" bottom="5" height="15" />
</state>
diff --git a/data/graphics/gui/theme.xml b/data/graphics/gui/theme.xml
index eb22fad8..e93ef855 100644
--- a/data/graphics/gui/theme.xml
+++ b/data/graphics/gui/theme.xml
@@ -1,41 +1,55 @@
<theme name="Mana">
- <color id="TEXT" color="#000000" />
- <color id="CARET" color="#000000" />
- <color id="SHADOW" color="#000000" />
- <color id="OUTLINE" color="#000000" />
- <color id="PARTY_CHAT_TAB" color="#f48055" />
- <color id="PARTY_SOCIAL_TAB" color="#ff00d8" />
- <color id="BACKGROUND" color="#ffffff" />
- <color id="HIGHLIGHT" color="#c0c0c0" />
- <color id="TAB_FLASH" color="#ff0000" effect="pulse" />
- <color id="SHOP_WARNING" color="#910000" />
- <color id="ITEM_EQUIPPED" color="#000091" />
- <color id="CHAT" color="#000000" />
- <color id="BUBBLE_TEXT" color="#ffffff" />
- <color id="GM" color="#ff0000" />
- <color id="PLAYER" color="#1fa052" />
- <color id="WHISPER" color="#0000ff" />
- <color id="IS" color="#a08527" />
- <color id="PARTY" color="#ff00d8" />
- <color id="GUILD" color="#ff00d8" />
- <color id="SERVER" color="#8415e2" />
- <color id="LOGGER" color="#919191" />
- <color id="HYPERLINK" color="#e50d0d" />
- <color id="UNKNOWN_ITEM" color="#000000" />
- <color id="GENERIC" color="#21a5b1" />
- <color id="HEAD" color="#527fa4" />
- <color id="USABLE" color="#268d24" />
- <color id="TORSO" color="#d12aa4" />
- <color id="ONEHAND" color="#f42a2a" />
- <color id="LEGS" color="#699900" />
- <color id="FEET" color="#aa1d48" />
- <color id="TWOHAND" color="#f46d0e" />
- <color id="SHIELD" color="#9c2424" />
- <color id="RING" color="#0000ff" />
- <color id="NECKLACE" color="#ff00ff" />
- <color id="ARMS" color="#9c24e8" />
- <color id="AMMO" color="#8b6311" />
- <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
+ <palette id="0">
+ <color id="TEXT" color="#000000" />
+ <color id="RED" color="#ff0000" />
+ <color id="GREEN" color="#009000" />
+ <color id="BLUE" color="#0000ff" />
+ <color id="ORANGE" color="#e0980e" />
+ <color id="YELLOW" color="#f1dc27" />
+ <color id="PINK" color="#ff00d8" />
+ <color id="PURPLE" color="#8415e2" />
+ <color id="GRAY" color="#919191" />
+ <color id="BROWN" color="#8e4c17" />
+ <color id="CARET" color="#000000" />
+ <color id="SHADOW" color="#000000" />
+ <color id="OUTLINE" color="#000000" />
+ <color id="PARTY_CHAT_TAB" color="#f48055" />
+ <color id="PARTY_SOCIAL_TAB" color="#ff00d8" />
+ <color id="BACKGROUND" color="#ffffff" />
+ <color id="HIGHLIGHT" color="#c0c0c0" />
+ <color id="TAB_FLASH" color="#ff0000" effect="pulse" />
+ <color id="SHOP_WARNING" color="#910000" />
+ <color id="ITEM_EQUIPPED" color="#000091" />
+ <color id="CHAT" color="#000000" />
+ <color id="OLDCHAT" color="#8e4c17" />
+ <color id="AWAYCHAT" color="#8e4c17" />
+ <color id="BUBBLE_TEXT" color="#ffffff" />
+ <color id="GM" color="#ff0000" />
+ <color id="GLOBAL" color="#ff0000" />
+ <color id="PLAYER" color="#1fa052" />
+ <color id="WHISPER" color="#0000ff" />
+ <color id="IS" color="#a08527" />
+ <color id="PARTY" color="#ff00d8" />
+ <color id="GUILD" color="#ff00d8" />
+ <color id="SERVER" color="#8415e2" />
+ <color id="LOGGER" color="#919191" />
+ <color id="HYPERLINK" color="#e50d0d" />
+ <color id="UNKNOWN_ITEM" color="#000000" />
+ <color id="GENERIC" color="#21a5b1" />
+ <color id="HEAD" color="#527fa4" />
+ <color id="USABLE" color="#268d24" />
+ <color id="TORSO" color="#d12aa4" />
+ <color id="ONEHAND" color="#f42a2a" />
+ <color id="LEGS" color="#699900" />
+ <color id="FEET" color="#aa1d48" />
+ <color id="TWOHAND" color="#f46d0e" />
+ <color id="SHIELD" color="#9c2424" />
+ <color id="RING" color="#0000ff" />
+ <color id="NECKLACE" color="#ff00ff" />
+ <color id="ARMS" color="#9c24e8" />
+ <color id="AMMO" color="#8b6311" />
+ <color id="SERVER_VERSION_NOT_SUPPORTED" color="#DC0000" />
+ </palette>
<progressbar id="DEFAULT" color="#969696" />
<progressbar id="HP" color="#ff0000,e28000,c38948,0f6a20" />
diff --git a/src/being.cpp b/src/being.cpp
index db9a9deb..85289fc7 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -980,7 +980,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
delete mText;
mText = nullptr;
- mSpeechBubble->setCaption(showName ? mName : "", mTextColor);
+ mSpeechBubble->setCaption(showName ? mName : std::string(), mNameColor);
mSpeechBubble->setText(mSpeech, showName);
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
@@ -1108,28 +1108,16 @@ void Being::restoreAllSpriteParticles()
void Being::updateColors()
{
- if (getType() == MONSTER)
- {
- mNameColor = &userPalette->getColor(UserPalette::MONSTER);
- mTextColor = &userPalette->getColor(UserPalette::MONSTER);
- }
- else if (getType() == NPC)
- {
- mNameColor = &userPalette->getColor(UserPalette::NPC);
- mTextColor = &userPalette->getColor(UserPalette::NPC);
- }
- else if (this == local_player)
- {
- mNameColor = &userPalette->getColor(UserPalette::SELF);
- mTextColor = &Theme::getThemeColor(Theme::PLAYER);
- }
- else
- {
- mTextColor = &userPalette->getColor(Theme::PLAYER);
-
- if (mIsGM)
+ switch (getType()) {
+ case ActorSprite::UNKNOWN:
+ return;
+ case ActorSprite::PLAYER:
+ if (this == local_player)
+ {
+ mNameColor = &userPalette->getColor(UserPalette::SELF);
+ }
+ else if (mIsGM)
{
- mTextColor = &userPalette->getColor(UserPalette::GM);
mNameColor = &userPalette->getColor(UserPalette::GM);
}
else if (mParty && mParty == local_player->getParty())
@@ -1140,6 +1128,16 @@ void Being::updateColors()
{
mNameColor = &userPalette->getColor(UserPalette::PC);
}
+ break;
+ case ActorSprite::NPC:
+ mNameColor = &userPalette->getColor(UserPalette::NPC);
+ break;
+ case ActorSprite::MONSTER:
+ mNameColor = &userPalette->getColor(UserPalette::MONSTER);
+ break;
+ case ActorSprite::FLOOR_ITEM:
+ case ActorSprite::PORTAL:
+ return;
}
if (mDispName)
diff --git a/src/being.h b/src/being.h
index 96749651..80620e71 100644
--- a/src/being.h
+++ b/src/being.h
@@ -524,7 +524,6 @@ class Being : public ActorSprite, public EventListener, public gcn::DeathListene
Path mPath;
std::string mSpeech;
Text *mText = nullptr;
- const gcn::Color *mTextColor;
Vector mDest; /**< destination coordinates. */
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 351ea9b0..5455f61a 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -25,10 +25,16 @@
#include <guichan/exception.hpp>
+#include <utility>
+
ImageRect::ImageRect(ImageRect &&r)
{
- image = r.image;
- r.image = nullptr;
+ image = std::exchange(r.image, nullptr);
+ top = r.top;
+ left = r.left;
+ bottom = r.bottom;
+ right = r.right;
+ fillMode = r.fillMode;
}
ImageRect::~ImageRect()
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index ba11096c..d006097c 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -30,6 +30,7 @@
#include "gui/recorder.h"
#include "gui/setup.h"
+#include "gui/widgets/browserbox.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/layout.h"
@@ -239,6 +240,7 @@ void ChatWindow::addTab(ChatTab *tab)
// Make sure we don't end up with duplicates in the gui
// TODO
+ tab->mTextOutput->setPalette(getSkin().palette);
mChatTabs->addTab(tab, tab->mScrollArea);
// Update UI
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 35951331..1efd0cf2 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -43,38 +43,38 @@
#define ITEMPOPUP_WRAP_WIDTH 196
-static const gcn::Color &getColorFromItemType(ItemType type)
+static int getColorIdFromItemType(ItemType type)
{
switch (type)
{
case ITEM_UNUSABLE:
- return Theme::getThemeColor(Theme::GENERIC);
+ return Theme::GENERIC;
case ITEM_USABLE:
- return Theme::getThemeColor(Theme::USABLE);
+ return Theme::USABLE;
case ITEM_EQUIPMENT_ONE_HAND_WEAPON:
- return Theme::getThemeColor(Theme::ONEHAND);
+ return Theme::ONEHAND;
case ITEM_EQUIPMENT_TWO_HANDS_WEAPON:
- return Theme::getThemeColor(Theme::TWOHAND);
+ return Theme::TWOHAND;
case ITEM_EQUIPMENT_TORSO:
- return Theme::getThemeColor(Theme::TORSO);
+ return Theme::TORSO;
case ITEM_EQUIPMENT_ARMS:
- return Theme::getThemeColor(Theme::ARMS);
+ return Theme::ARMS;
case ITEM_EQUIPMENT_HEAD:
- return Theme::getThemeColor(Theme::HEAD);
+ return Theme::HEAD;
case ITEM_EQUIPMENT_LEGS:
- return Theme::getThemeColor(Theme::LEGS);
+ return Theme::LEGS;
case ITEM_EQUIPMENT_SHIELD:
- return Theme::getThemeColor(Theme::SHIELD);
+ return Theme::SHIELD;
case ITEM_EQUIPMENT_RING:
- return Theme::getThemeColor(Theme::RING);
+ return Theme::RING;
case ITEM_EQUIPMENT_NECKLACE:
- return Theme::getThemeColor(Theme::NECKLACE);
+ return Theme::NECKLACE;
case ITEM_EQUIPMENT_FEET:
- return Theme::getThemeColor(Theme::FEET);
+ return Theme::FEET;
case ITEM_EQUIPMENT_AMMO:
- return Theme::getThemeColor(Theme::AMMO);
+ return Theme::AMMO;
default:
- return Theme::getThemeColor(Theme::UNKNOWN_ITEM);
+ return Theme::UNKNOWN_ITEM;
}
}
@@ -132,7 +132,10 @@ void ItemPopup::setNoItem()
mItemName->setCaption(caption);
mItemName->adjustSize();
- mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC));
+ auto theme = gui->getTheme();
+ auto &palette = theme->getPalette(getSkin().palette);
+
+ mItemName->setForegroundColor(palette.getColor(Theme::GENERIC));
mItemName->setPosition(0, 0);
mItemDesc->setText(std::string());
@@ -173,9 +176,12 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
if (!mItemEquipSlot.empty())
caption += " (" + mItemEquipSlot + ")";
+ auto theme = gui->getTheme();
+ auto &palette = theme->getPalette(getSkin().palette);
+
mItemName->setCaption(caption);
mItemName->adjustSize();
- mItemName->setForegroundColor(getColorFromItemType(mItemType));
+ mItemName->setForegroundColor(palette.getColor(getColorIdFromItemType(mItemType)));
mItemName->setPosition(space, 0);
mItemDesc->setTextWrapped(item.description, ITEMPOPUP_WRAP_WIDTH);
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 6c6e6f06..4b66b70d 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -25,7 +25,6 @@
#include <cmath>
static constexpr double PI = 3.14159265;
-const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
Timer Palette::mRainbowTimer;
Palette::Palettes Palette::mInstances;
@@ -47,23 +46,34 @@ Palette::Palette(int size) :
mInstances.insert(this);
}
+Palette::Palette(Palette &&pal)
+ : mColors(std::move(pal.mColors))
+ , mGradVector(std::move(pal.mGradVector))
+{
+ mInstances.insert(this);
+}
+
Palette::~Palette()
{
mInstances.erase(this);
}
-const gcn::Color &Palette::getColor(char c, bool &valid)
- {
- for (const auto &color : mColors)
+Palette &Palette::operator=(Palette &&pal)
+{
+ if (this != &pal)
{
- if (color.ch == c)
- {
- valid = true;
- return color.color;
- }
+ mColors = std::move(pal.mColors);
+ mGradVector = std::move(pal.mGradVector);
}
- valid = false;
- return BLACK;
+ return *this;
+}
+
+void Palette::setColor(int type,
+ const gcn::Color &color,
+ GradientType grad,
+ int delay)
+{
+ mColors[type].set(type, color, grad, delay);
}
void Palette::advanceGradients()
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 145a93ac..fc2eda9e 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -40,8 +40,13 @@ constexpr int GRADIENT_DELAY = 40;
class Palette
{
public:
- /** Black Color Constant */
- static const gcn::Color BLACK;
+ Palette(int size);
+ Palette(const Palette &) = delete;
+ Palette(Palette &&);
+ ~Palette();
+
+ Palette &operator=(const Palette &) = delete;
+ Palette &operator=(Palette &&);
/** Colors can be static or can alter over time. */
enum GradientType {
@@ -51,31 +56,21 @@ class Palette
RAINBOW
};
- /**
- * Returns the color associated with a character, if it exists. Returns
- * Palette::BLACK if the character is not found.
- *
- * @param c character requested
- * @param valid indicate whether character is known
- *
- * @return the requested color or Palette::BLACK
- */
- const gcn::Color &getColor(char c, bool &valid);
+ void setColor(int type,
+ const gcn::Color &color,
+ GradientType grad,
+ int delay);
/**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
+ * Gets the color associated with the type.
*
* @param type the color type requested
- * @param alpha alpha channel to use
*
* @return the requested color
*/
- const gcn::Color &getColor(int type, int alpha = 255)
+ const gcn::Color &getColor(int type) const
{
- gcn::Color &col = mColors[type].color;
- col.a = alpha;
- return col;
+ return mColors[type].color;
}
/**
@@ -91,18 +86,6 @@ class Palette
}
/**
- * Get the character used by the specified color.
- *
- * @param type the color type of the color
- *
- * @return the color char of the color with the given index
- */
- char getColorChar(int type) const
- {
- return mColors[type].ch;
- }
-
- /**
* Gets the gradient delay for the specified type.
*
* @param type the color type of the color
@@ -128,10 +111,6 @@ class Palette
using Palettes = std::set<Palette *>;
static Palettes mInstances;
- Palette(int size);
-
- ~Palette();
-
void advanceGradient(int advance);
struct ColorElem
@@ -141,7 +120,6 @@ class Palette
gcn::Color testColor;
gcn::Color committedColor;
std::string text;
- char ch;
GradientType grad;
GradientType committedGrad;
int gradientIndex;
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index d86d751a..d6e69a95 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -95,20 +95,19 @@ public:
auto *model = static_cast<ServersListModel*>(mListModel);
- const int alpha = gui->getTheme()->getGuiAlpha();
-
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, alpha));
graphics->setFont(getFont());
const int height = getRowHeight();
- const gcn::Color unsupported =
- Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED,
- alpha);
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
+ {
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = gui->getTheme()->getGuiAlpha();
+ graphics->setColor(highlightColor);
graphics->fillRectangle(gcn::Rectangle(0, height * mSelected,
getWidth(), height));
+ }
// Draw the list elements
for (int i = 0, y = 0; i < model->getNumberOfElements();
@@ -132,7 +131,9 @@ public:
if (info.version.first > 0)
{
- graphics->setColor(unsupported);
+ auto unsupportedColor = Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED);
+ unsupportedColor.a = gui->getTheme()->getGuiAlpha();
+ graphics->setColor(unsupportedColor);
graphics->drawText(info.version.second,
getWidth() - info.version.first - 2, top);
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index c3d6a8c8..89eb668e 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -73,14 +73,21 @@ Setup_Colors::Setup_Colors() :
mGradTypeText = new Label;
- std::string longText = _("Static");
-
- if (getFont()->getWidth(_("Pulse")) > getFont()->getWidth(longText))
- longText = _("Pulse");
- if (getFont()->getWidth(_("Rainbow")) > getFont()->getWidth(longText))
- longText = _("Rainbow");
- if (getFont()->getWidth(_("Spectrum")) > getFont()->getWidth(longText))
- longText = _("Spectrum");
+ // Initialize with widest label for layout purposes
+ const char *longText = _("Static");
+ int longWidth = getFont()->getWidth(longText);
+
+ auto maybeLonger = [&] (const char *text) {
+ const int width = getFont()->getWidth(text);
+ if (width > longWidth)
+ {
+ longText = text;
+ longWidth = width;
+ }
+ };
+ maybeLonger(_("Pulse"));
+ maybeLonger(_("Rainbow"));
+ maybeLonger(_("Spectrum"));
mGradTypeText->setCaption(longText);
@@ -214,10 +221,10 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
}
}
-void Setup_Colors::valueChanged(const gcn::SelectionEvent &event)
+void Setup_Colors::valueChanged(const gcn::SelectionEvent &)
{
mSelected = mColorBox->getSelected();
- int type = userPalette->getColorTypeAt(mSelected);
+ const int type = userPalette->getColorTypeAt(mSelected);
const gcn::Color *col = &userPalette->getColor(type);
Palette::GradientType grad = userPalette->getGradientType(type);
const int delay = userPalette->getGradientDelay(type);
@@ -226,11 +233,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event)
mPreviewBox->setContent(mTextPreview);
mTextPreview->setFont(boldFont);
mTextPreview->setTextColor(col);
- mTextPreview->setTextBGColor(nullptr);
- mTextPreview->setOpaque(false);
- mTextPreview->setShadow(true);
mTextPreview->setOutline(true);
- mTextPreview->useTextAlpha(false);
switch (type)
{
@@ -242,6 +245,10 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event)
case UserPalette::HIT_CRITICAL:
case UserPalette::MISS:
mTextPreview->setShadow(false);
+ break;
+ default:
+ mTextPreview->setShadow(true);
+ break;
}
if (grad != Palette::STATIC && grad != Palette::PULSE)
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index c1911ac5..40421daf 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -134,14 +134,14 @@ public:
auto *model = static_cast<SkillModel *>(mListModel);
auto *graphics = static_cast<Graphics *>(gcnGraphics);
- const int alpha = gui->getTheme()->getGuiAlpha();
-
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, alpha));
graphics->setFont(getFont());
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = gui->getTheme()->getGuiAlpha();
+ graphics->setColor(highlightColor);
graphics->fillRectangle(gcn::Rectangle(0, getRowHeight() * mSelected,
getWidth(), getRowHeight()));
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index f7d6e801..271fa34c 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -69,17 +69,19 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
auto *model = static_cast<AvatarListModel *>(mListModel);
auto *graphics = static_cast<Graphics *>(gcnGraphics);
- const int alpha = gui->getTheme()->getGuiAlpha();
-
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, alpha));
graphics->setFont(getFont());
const int fontHeight = getFont()->getHeight();
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
+ {
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = gui->getTheme()->getGuiAlpha();
+ graphics->setColor(highlightColor);
graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected,
getWidth(), fontHeight));
+ }
// Draw the list elements
graphics->setColor(Theme::getThemeColor(Theme::TEXT));
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 91366720..bb00d4ef 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -75,7 +75,7 @@ static void replaceKeys(std::string &text)
struct LayoutContext
{
- LayoutContext(gcn::Font *font);
+ LayoutContext(gcn::Font *font, const Palette &palette);
int y = 0;
gcn::Font *font;
@@ -83,18 +83,18 @@ struct LayoutContext
const int minusWidth;
const int tildeWidth;
int lineHeight;
- gcn::Color selColor;
const gcn::Color textColor;
+ gcn::Color selColor;
};
-LayoutContext::LayoutContext(gcn::Font *font)
+LayoutContext::LayoutContext(gcn::Font *font, const Palette &palette)
: font(font)
, fontHeight(font->getHeight())
, minusWidth(font->getWidth("-"))
, tildeWidth(font->getWidth("~"))
, lineHeight(fontHeight)
- , selColor(Theme::getThemeColor(Theme::TEXT))
- , textColor(Theme::getThemeColor(Theme::TEXT))
+ , textColor(palette.getColor(Theme::TEXT))
+ , selColor(textColor)
{
if (auto *trueTypeFont = dynamic_cast<const TrueTypeFont*>(font))
lineHeight = trueTypeFont->getLineHeight();
@@ -175,7 +175,7 @@ void BrowserBox::addRow(std::string_view row)
replaceKeys(newRow.text);
// Layout the newly added row
- LayoutContext context(getFont());
+ LayoutContext context(getFont(), gui->getTheme()->getPalette(mPalette));
context.y = getHeight();
layoutTextRow(newRow, context);
@@ -252,19 +252,20 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mHoveredLink)
{
+ auto &palette = gui->getTheme()->getPalette(mPalette);
auto &link = *mHoveredLink;
const gcn::Rectangle &rect = link.rect;
if (mHighlightMode & BACKGROUND)
{
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT));
+ graphics->setColor(palette.getColor(Theme::HIGHLIGHT));
graphics->fillRectangle(rect);
}
if (mHighlightMode & UNDERLINE)
{
- graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK));
+ graphics->setColor(palette.getColor(Theme::HYPERLINK));
graphics->drawLine(rect.x,
rect.y + rect.height,
rect.x + rect.width,
@@ -299,7 +300,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
*/
void BrowserBox::relayoutText()
{
- LayoutContext context(getFont());
+ LayoutContext context(getFont(), gui->getTheme()->getPalette(mPalette));
for (auto &row : mTextRows)
layoutTextRow(row, context);
@@ -347,6 +348,8 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context)
return;
}
+ auto theme = gui->getTheme();
+ auto &palette = gui->getTheme()->getPalette(mPalette);
gcn::Color prevColor = context.selColor;
// TODO: Check if we must take texture size limits into account here
@@ -371,44 +374,27 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context)
const char c = row.text.at(start + 2);
start += 3;
- bool valid;
- const gcn::Color &col = Theme::getThemeColor(c, valid);
-
- if (c == '>')
- {
- context.selColor = prevColor;
- }
- else if (c == '<')
- {
- prevColor = context.selColor;
- context.selColor = col;
- }
- else if (c == 'B')
- {
- context.font = boldFont;
- }
- else if (c == 'b')
- {
- context.font = getFont();
- }
- else if (valid)
- {
- context.selColor = col;
- }
- else switch (c)
+ switch (c)
{
- case '1': context.selColor = RED; break;
- case '2': context.selColor = GREEN; break;
- case '3': context.selColor = BLUE; break;
- case '4': context.selColor = ORANGE; break;
- case '5': context.selColor = YELLOW; break;
- case '6': context.selColor = PINK; break;
- case '7': context.selColor = PURPLE; break;
- case '8': context.selColor = GRAY; break;
- case '9': context.selColor = BROWN; break;
- case '0':
- default:
- context.selColor = context.textColor;
+ case '>':
+ context.selColor = prevColor;
+ break;
+ case '<':
+ prevColor = context.selColor;
+ context.selColor = palette.getColor(Theme::HYPERLINK);
+ break;
+ case 'B':
+ context.font = boldFont;
+ break;
+ case 'b':
+ context.font = getFont();
+ break;
+ default: {
+ const auto colorId = Theme::getColorIdForChar(c);
+ context.selColor = colorId ? palette.getColor(*colorId)
+ : context.textColor;
+ break;
+ }
}
// Update the position of the links
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 7066585d..03bda8cd 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -86,6 +86,8 @@ class BrowserBox : public gcn::Widget,
*/
void setLinkHandler(LinkHandler *handler) { mLinkHandler = handler; }
+ void setPalette(int palette) { mPalette = palette; }
+
/**
* Sets the Highlight mode for links.
*/
@@ -154,29 +156,6 @@ class BrowserBox : public gcn::Widget,
void drawFrame(gcn::Graphics *) override {}
/**
- * BrowserBox colors.
- *
- * NOTES (by Javila):
- * - color values is "0x" prefix followed by HTML color style.
- * - we can add up to 10 different colors: [0..9].
- * - not all colors will be fine with all backgrounds due transparent
- * windows and widgets. So, I think it's better keep BrowserBox
- * opaque (white background) by default.
- */
- enum
- {
- RED = 0xff0000, /**< Color 1 */
- GREEN = 0x009000, /**< Color 2 */
- BLUE = 0x0000ff, /**< Color 3 */
- ORANGE = 0xe0980e, /**< Color 4 */
- YELLOW = 0xf1dc27, /**< Color 5 */
- PINK = 0xff00d8, /**< Color 6 */
- PURPLE = 0x8415e2, /**< Color 7 */
- GRAY = 0x919191, /**< Color 8 */
- BROWN = 0x8e4c17 /**< Color 9 */
- };
-
- /**
* Highlight modes for links.
* This can be used for a bitmask.
*/
@@ -195,6 +174,7 @@ class BrowserBox : public gcn::Widget,
std::deque<TextRow> mTextRows;
LinkHandler *mLinkHandler = nullptr;
+ int mPalette = 0;
Mode mMode;
unsigned int mHighlightMode = UNDERLINE | BACKGROUND;
int mWrapIndent = 0;
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 485de566..03c3270a 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -160,7 +160,7 @@ void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
tmp.nick = strprintf(_("Global announcement from %s:"),
tmp.nick.c_str());
tmp.nick += " ";
- lineColor = "##1"; // Equiv. to BrowserBox::RED
+ lineColor = "##g";
}
break;
case BY_PLAYER:
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index fbdaa1d4..54b7950b 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -32,7 +32,7 @@ class LayoutHelper;
* A widget container.
*
* The main difference between the standard Guichan container and this one is
- * that childs added to this container are automatically deleted when the
+ * that children added to this container are automatically deleted when the
* container is deleted.
*
* This container is also non-opaque by default.
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index cea50b1d..7d8ad0e5 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -57,7 +57,8 @@ void DropDown::draw(gcn::Graphics* graphics)
const int alpha = gui->getTheme()->getGuiAlpha();
gcn::Color faceColor = getBaseColor();
faceColor.a = alpha;
- const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT, alpha);
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = alpha;
gcn::Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
@@ -72,7 +73,7 @@ void DropDown::draw(gcn::Graphics* graphics)
if (isFocused())
{
- graphics->setColor(*highlightColor);
+ graphics->setColor(highlightColor);
graphics->drawRectangle(
gcn::Rectangle(mPadding, mPadding, getWidth() - h - mPadding * 2, h - 2 * mPadding));
}
@@ -85,7 +86,7 @@ void DropDown::draw(gcn::Graphics* graphics)
// Draw two lines separating the ListBox with selected
// element view.
- graphics->setColor(*highlightColor);
+ graphics->setColor(highlightColor);
graphics->drawLine(0, h, getWidth(), h);
graphics->setColor(shadowColor);
graphics->drawLine(0, h + 1, getWidth(), h + 1);
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 53a82e14..a2ed8820 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -42,7 +42,7 @@ Label::Label(const std::string &caption) :
void Label::draw(gcn::Graphics *graphics)
{
int textX;
- int textY = getHeight() / 2 - getFont()->getHeight() / 2;
+ int textY = (getHeight() - getFont()->getHeight()) / 2;
switch (getAlignment())
{
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index f1fcfd53..112de232 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -41,17 +41,19 @@ void ListBox::draw(gcn::Graphics *graphics)
if (!mListModel)
return;
- const int alpha = gui->getTheme()->getGuiAlpha();
-
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, alpha));
graphics->setFont(getFont());
const int height = getRowHeight();
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
+ {
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = gui->getTheme()->getGuiAlpha();
+ graphics->setColor(highlightColor);
graphics->fillRectangle(gcn::Rectangle(0, height * mSelected,
getWidth(), height));
+ }
// Draw the list elements
graphics->setColor(Theme::getThemeColor(Theme::TEXT));
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 4095c5c3..3e4315f0 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -22,11 +22,14 @@
#include "gui/widgets/popup.h"
+#include "browserbox.h"
#include "graphics.h"
#include "log.h"
+#include "textbox.h"
#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/windowcontainer.h"
#include <guichan/exception.hpp>
@@ -42,7 +45,7 @@ Popup::Popup(const std::string &name, SkinType skinType)
if (!windowContainer)
throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
- auto &skin = gui->getTheme()->getSkin(skinType);
+ auto &skin = getSkin();
setFrameSize(skin.frameSize);
setPadding(skin.padding);
@@ -63,6 +66,31 @@ void Popup::setWindowContainer(WindowContainer *wc)
windowContainer = wc;
}
+void Popup::add(gcn::Widget *widget)
+{
+ Container::add(widget);
+ widgetAdded(widget);
+}
+
+void Popup::add(gcn::Widget *widget, int x, int y)
+{
+ Container::add(widget, x, y);
+ widgetAdded(widget);
+}
+
+void Popup::widgetAdded(gcn::Widget *widget) const
+{
+ if (const int paletteId = getSkin().palette)
+ {
+ if (auto browserBox = dynamic_cast<BrowserBox*>(widget))
+ browserBox->setPalette(paletteId);
+ else if (auto label = dynamic_cast<Label*>(widget))
+ label->setForegroundColor(gui->getTheme()->getPalette(paletteId).getColor(Theme::TEXT));
+ else if (auto textBox = dynamic_cast<TextBox*>(widget))
+ textBox->setTextColor(&gui->getTheme()->getPalette(paletteId).getColor(Theme::TEXT));
+ }
+}
+
void Popup::draw(gcn::Graphics *graphics)
{
if (getFrameSize() == 0)
@@ -76,7 +104,7 @@ void Popup::drawFrame(gcn::Graphics *graphics)
WidgetState state(this);
state.width += getFrameSize() * 2;
state.height += getFrameSize() * 2;
- gui->getTheme()->drawSkin(static_cast<Graphics *>(graphics), mSkinType, state);
+ getSkin().draw(static_cast<Graphics *>(graphics), state);
}
gcn::Rectangle Popup::getChildrenArea()
@@ -119,14 +147,12 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget)
void Popup::setMinWidth(int width)
{
- auto &skin = gui->getTheme()->getSkin(mSkinType);
- mMinWidth = std::max(skin.getMinWidth(), width);
+ mMinWidth = std::max(getSkin().getMinWidth(), width);
}
void Popup::setMinHeight(int height)
{
- auto &skin = gui->getTheme()->getSkin(mSkinType);
- mMinHeight = std::max(skin.getMinHeight(), height);
+ mMinHeight = std::max(getSkin().getMinHeight(), height);
}
void Popup::setMaxWidth(int width)
@@ -161,6 +187,11 @@ void Popup::position(int x, int y)
requestMoveToTop();
}
+const Skin &Popup::getSkin() const
+{
+ return gui->getTheme()->getSkin(mSkinType);
+}
+
void Popup::mouseMoved(gcn::MouseEvent &event)
{
if (viewport)
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 012b55de..b88cafc9 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -68,6 +68,10 @@ class Popup : public Container, public gcn::MouseListener
*/
static void setWindowContainer(WindowContainer *windowContainer);
+ // Container interface
+ void add(gcn::Widget *widget) override;
+ void add(gcn::Widget *widget, int x, int y) override;
+
/**
* Draws the popup.
*/
@@ -156,7 +160,14 @@ class Popup : public Container, public gcn::MouseListener
*/
void position(int x, int y);
+ /**
+ * Returns the Skin used by this popup.
+ */
+ const Skin &getSkin() const;
+
private:
+ void widgetAdded(gcn::Widget *widget) const;
+
std::string mPopupName; /**< Name of the popup */
int mMinWidth = 100; /**< Minimum popup width */
int mMinHeight = 40; /**< Minimum popup height */
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 31c733a6..e2313c85 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -71,14 +71,13 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
return;
const int alpha = (int)(config.guiAlpha * 255.0f);
- const gcn::Color &highlightColor =
- Theme::getThemeColor(Theme::HIGHLIGHT, alpha);
- const gcn::Color &backgroundColor =
- Theme::getThemeColor(Theme::BACKGROUND, alpha);
- const gcn::Color &warningColor =
- Theme::getThemeColor(Theme::SHOP_WARNING, alpha);
- const gcn::Color &textColor =
- Theme::getThemeColor(Theme::TEXT);
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ auto backgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ auto warningColor = Theme::getThemeColor(Theme::SHOP_WARNING);
+ auto textColor = Theme::getThemeColor(Theme::TEXT);
+ highlightColor.a = alpha;
+ backgroundColor.a = alpha;
+ warningColor.a = alpha;
auto *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -168,8 +167,7 @@ void ShopListBox::mouseMoved(gcn::MouseEvent &event)
}
else
{
- Item *item = mShopItems->at(index);
- if (item)
+ if (Item *item = mShopItems->at(index))
{
mItemPopup->setItem(item->getInfo());
mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index fb5436e0..3609791a 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -112,7 +112,7 @@ void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget)
addTab(tab, widget);
}
-void TabbedArea::removeTab(Tab *tab)
+void TabbedArea::removeTab(gcn::Tab *tab)
{
if (tab == mSelectedTab)
{
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 558b2696..5d0ccfcc 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -86,12 +86,12 @@ class TabbedArea final : public gcn::TabbedArea, public gcn::WidgetListener
void addTab(const std::string &caption, gcn::Widget *widget) override;
/**
- * Overload the remove tab function as it's broken in guichan 0.8.
+ * Override the remove tab function as it's broken in guichan 0.8.
*/
- void removeTab(Tab *tab);
+ void removeTab(gcn::Tab *tab) override;
/**
- * Overload the logic function since it's broken in guichan 0.8.
+ * Override the logic function since it's broken in guichan 0.8.
*/
void logic() override;
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp
index 7cddc1fa..909617a0 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/table.cpp
@@ -77,18 +77,12 @@ void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent)
}
-GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
+GuiTable::GuiTable(TableModel *initialModel, gcn::Color background,
bool opacity) :
- mLinewiseMode(false),
- mWrappingEnabled(false),
mOpaque(opacity),
- mBackgroundColor(background),
- mModel(nullptr),
- mSelectedRow(0),
- mSelectedColumn(0),
- mTopWidget(nullptr)
+ mBackgroundColor(background)
{
- setModel(initial_model);
+ setModel(initialModel);
setFocusable(true);
addMouseListener(this);
@@ -269,10 +263,15 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mOpaque)
{
- graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, guiAlpha));
+ auto backgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ backgroundColor.a = guiAlpha;
+ graphics->setColor(backgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
+ auto highlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ highlightColor.a = guiAlpha;
+
// First, determine how many rows we need to draw, and where we should start.
int first_row = -(getY() / getRowHeight());
@@ -314,7 +313,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
widget->setDimension(bounds);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, guiAlpha));
+ graphics->setColor(highlightColor);
if (mLinewiseMode && r == mSelectedRow && c == 0)
{
@@ -361,7 +360,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget)
mTopWidget = nullptr;
}
-gcn::Rectangle GuiTable::getChildrenArea() const
+gcn::Rectangle GuiTable::getChildrenArea()
{
return gcn::Rectangle(0, 0, getWidth(), getHeight());
}
@@ -480,7 +479,7 @@ void GuiTable::modelUpdated(bool completed)
}
}
-gcn::Widget *GuiTable::getWidgetAt(int x, int y) const
+gcn::Widget *GuiTable::getWidgetAt(int x, int y)
{
int row = getRowForY(y);
int column = getColumnForX(x);
diff --git a/src/gui/widgets/table.h b/src/gui/widgets/table.h
index 81071267..88350928 100644
--- a/src/gui/widgets/table.h
+++ b/src/gui/widgets/table.h
@@ -49,7 +49,7 @@ class GuiTable final : public gcn::Widget,
friend class GuiTableActionListener;
public:
- GuiTable(TableModel * initial_model = nullptr, gcn::Color background = 0xffffff,
+ GuiTable(TableModel *initialModel = nullptr, gcn::Color background = 0xffffff,
bool opacity = true);
~GuiTable() override;
@@ -84,7 +84,7 @@ public:
void setWrappingEnabled(bool wrappingEnabled)
{mWrappingEnabled = wrappingEnabled;}
- gcn::Rectangle getChildrenArea() const;
+ gcn::Rectangle getChildrenArea() override;
/**
* Toggle whether to use linewise selection mode, in which the table selects
@@ -105,7 +105,7 @@ public:
// Overridden to disable drawing of the frame
void drawFrame(gcn::Graphics* graphics) override {}
- virtual gcn::Widget *getWidgetAt(int x, int y) const;
+ gcn::Widget *getWidgetAt(int x, int y) override;
void moveToTop(gcn::Widget *child) override;
@@ -122,7 +122,7 @@ public:
*
* @param opaque True if the table should be opaque, false otherwise.
*/
- virtual void setOpaque(bool opaque) {mOpaque = opaque;}
+ void setOpaque(bool opaque) {mOpaque = opaque;}
/**
* Checks if the table is opaque, that is if the table area displays its
@@ -130,7 +130,7 @@ public:
*
* @return True if the table is opaque, false otherwise.
*/
- virtual bool isOpaque() const {return mOpaque;}
+ bool isOpaque() const {return mOpaque;}
// Inherited from MouseListener
void mousePressed(gcn::MouseEvent& mouseEvent) override;
@@ -146,19 +146,20 @@ public:
protected:
/** Frees all action listeners on inner widgets. */
- virtual void uninstallActionListeners();
+ void uninstallActionListeners();
/** Installs all action listeners on inner widgets. */
- virtual void installActionListeners();
+ void installActionListeners();
- virtual int getRowHeight() const;
- virtual int getColumnWidth(int i) const;
+ int getRowHeight() const;
+ int getColumnWidth(int i) const;
private:
int getRowForY(int y) const; // -1 on error
int getColumnForX(int x) const; // -1 on error
void recomputeDimensions();
- bool mLinewiseMode;
- bool mWrappingEnabled;
+
+ bool mLinewiseMode = false;
+ bool mWrappingEnabled = false;
bool mOpaque;
/**
@@ -166,16 +167,13 @@ private:
*/
gcn::Color mBackgroundColor;
- TableModel *mModel;
-
- int mSelectedRow;
- int mSelectedColumn;
+ TableModel *mModel = nullptr;
- /** Number of frames to skip upwards when drawing the selected widget. */
- int mPopFramesNr;
+ int mSelectedRow = 0;
+ int mSelectedColumn = 0;
/** If someone moves a fresh widget to the top, we must display it. */
- gcn::Widget *mTopWidget;
+ gcn::Widget *mTopWidget = nullptr;
/** Vector for compactness; used as a list in practice. */
std::vector<GuiTableActionListener *> mActionListeners;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index f9e85052..2f80bd23 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -29,49 +29,19 @@
#include <typeinfo>
-float TextPreview::mAlpha = 1.0;
-
-TextPreview::TextPreview(const std::string &text):
- mText(text)
+TextPreview::TextPreview(const std::string &text)
+ : mText(text)
{
mFont = gui->getFont();
mTextColor = &Theme::getThemeColor(Theme::TEXT);
- mBGColor = &Theme::getThemeColor(Theme::BACKGROUND);
}
void TextPreview::draw(gcn::Graphics* graphics)
{
- if (config.guiAlpha != mAlpha)
- mAlpha = config.guiAlpha;
-
- int alpha = (int) (mAlpha * 255.0f);
-
- if (!mTextAlpha)
- alpha = 255;
-
- if (mOpaque)
- {
- graphics->setColor(gcn::Color((int) mBGColor->r,
- (int) mBGColor->g,
- (int) mBGColor->b,
- (int)(mAlpha * 255.0f)));
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
- }
-
- if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont))
- {
- auto *font = static_cast<TrueTypeFont*>(mFont);
- int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0);
- int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0);
- graphics->setColor(gcn::Color((int) mTextBGColor->r,
- (int) mTextBGColor->g,
- (int) mTextBGColor->b,
- (int)(mAlpha * 255.0f)));
- graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
- }
-
TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT,
- gcn::Color(mTextColor->r, mTextColor->g,
- mTextColor->b, alpha),
+ gcn::Color(mTextColor->r,
+ mTextColor->g,
+ mTextColor->b,
+ 255),
mFont, mOutline, mShadow);
}
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index da24b61e..8246a200 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -44,37 +44,6 @@ class TextPreview : public gcn::Widget
}
/**
- * Sets the text to use the set alpha value.
- *
- * @param alpha whether to use alpha values for the text or not
- */
- void useTextAlpha(bool alpha)
- {
- mTextAlpha = alpha;
- }
-
- /**
- * Sets the color the text background is drawn in. This is only the
- * rectangle directly behind the text, not to full widget.
- *
- * @param color the color to set
- */
- void setTextBGColor(const gcn::Color *color)
- {
- mTextBGColor = color;
- }
-
- /**
- * Sets the background color of the widget.
- *
- * @param color the color to set
- */
- void setBGColor(const gcn::Color *color)
- {
- mBGColor = color;
- }
-
- /**
* Sets the font to render the text in.
*
* @param font the font to use.
@@ -111,29 +80,10 @@ class TextPreview : public gcn::Widget
*/
void draw(gcn::Graphics *graphics) override;
- /**
- * Set opacity for this widget (whether or not to show the background
- * color)
- *
- * @param opaque Whether the widget should be opaque or not
- */
- void setOpaque(bool opaque) { mOpaque = opaque; }
-
- /**
- * Gets opacity for this widget (whether or not the background color
- * is shown below the widget)
- */
- bool isOpaque() const { return mOpaque; }
-
private:
gcn::Font *mFont;
std::string mText;
const gcn::Color *mTextColor;
- const gcn::Color *mBGColor;
- const gcn::Color *mTextBGColor = nullptr;
- static float mAlpha;
- bool mTextAlpha = false;
- bool mOpaque = false;
bool mShadow = false;
bool mOutline = false;
};
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index b899e001..e57918b7 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -60,7 +60,7 @@ Window::Window(SkinType skinType, const std::string &caption, bool modal, Window
instances++;
- auto &skin = gui->getTheme()->getSkin(mSkinType);
+ auto &skin = getSkin();
setFrameSize(skin.frameSize);
setPadding(skin.padding);
setTitleBarHeight(skin.titleBarHeight);
@@ -126,13 +126,12 @@ void Window::draw(gcn::Graphics *graphics)
void Window::drawFrame(gcn::Graphics *graphics)
{
auto g = static_cast<Graphics*>(graphics);
- auto theme = gui->getTheme();
WidgetState widgetState(this);
widgetState.width += getFrameSize() * 2;
widgetState.height += getFrameSize() * 2;
- auto &skin = theme->getSkin(mSkinType);
+ auto &skin = getSkin();
skin.draw(g, widgetState);
if (mShowTitle)
@@ -172,7 +171,7 @@ void Window::setMinimumContentSize(int width, int height)
{
const int padding = getPadding();
const int titleBarHeight = getTitleBarHeight();
- auto &skin = gui->getTheme()->getSkin(mSkinType);
+ auto &skin = getSkin();
setMinWidth(std::max(skin.getMinWidth(), width + 2 * padding));
setMinHeight(std::max(skin.getMinHeight(), height + padding + titleBarHeight));
@@ -240,14 +239,12 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position,
void Window::setMinWidth(int width)
{
- auto &skin = gui->getTheme()->getSkin(mSkinType);
- mMinWinWidth = std::max(skin.getMinWidth(), width);
+ mMinWinWidth = std::max(getSkin().getMinWidth(), width);
}
void Window::setMinHeight(int height)
{
- auto &skin = gui->getTheme()->getSkin(mSkinType);
- mMinWinHeight = std::max(skin.getMinHeight(), height);
+ mMinWinHeight = std::max(getSkin().getMinHeight(), height);
}
void Window::setMaxWidth(int width)
@@ -380,6 +377,11 @@ void Window::close()
setVisible(false);
}
+const Skin &Window::getSkin() const
+{
+ return gui->getTheme()->getSkin(mSkinType);
+}
+
void Window::mouseReleased(gcn::MouseEvent &event)
{
mouseResize = 0;
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index e9efa3a7..6331a715 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -363,6 +363,11 @@ class Window : public gcn::Window, gcn::WidgetListener
virtual void close();
/**
+ * Returns the Skin used by this window.
+ */
+ const Skin &getSkin() const;
+
+ /**
* Gets the alpha value used by the window, in a Guichan usable format.
*/
static int getGuiAlpha();
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index 6e57df0c..66908ae6 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -38,7 +38,6 @@
#include <guichan/widget.hpp>
#include <algorithm>
-#include <optional>
/**
* Initializes the directory in which the client looks for GUI themes, which at
@@ -228,24 +227,20 @@ void Skin::updateAlpha(float alpha)
Theme::Theme(const ThemeInfo &themeInfo)
- : Palette(THEME_COLORS_END)
- , mThemePath(themeInfo.getFullPath())
+ : mThemePath(themeInfo.getFullPath())
, mProgressColors(THEME_PROG_END)
{
listen(Event::ConfigChannel);
readTheme(themeInfo);
- mColors[HIGHLIGHT].ch = 'H';
- mColors[CHAT].ch = 'C';
- mColors[GM].ch = 'G';
- mColors[PLAYER].ch = 'Y';
- mColors[WHISPER].ch = 'W';
- mColors[IS].ch = 'I';
- mColors[PARTY].ch = 'P';
- mColors[GUILD].ch = 'U';
- mColors[SERVER].ch = 'S';
- mColors[LOGGER].ch = 'L';
- mColors[HYPERLINK].ch = '<';
+ if (mPalettes.empty())
+ {
+ logger->log("Error, theme did not define any palettes: %s",
+ themeInfo.getPath().c_str());
+
+ // Avoid crashing
+ mPalettes.emplace_back(THEME_COLORS_END);
+ }
}
Theme::~Theme()
@@ -317,14 +312,9 @@ ResourceRef<Image> Theme::getImageFromTheme(const std::string &path)
return gui->getTheme()->getImage(path);
}
-const gcn::Color &Theme::getThemeColor(int type, int alpha)
-{
- return gui->getTheme()->getColor(type, alpha);
-}
-
-const gcn::Color &Theme::getThemeColor(char c, bool &valid)
+const gcn::Color &Theme::getThemeColor(int type)
{
- return gui->getTheme()->getColor(c, valid);
+ return gui->getTheme()->getColor(type);
}
gcn::Color Theme::getProgressColor(int type, float progress)
@@ -337,6 +327,51 @@ gcn::Color Theme::getProgressColor(int type, float progress)
return gcn::Color(color[0], color[1], color[2]);
}
+const Palette &Theme::getPalette(size_t index) const
+{
+ return mPalettes.at(index < mPalettes.size() ? index : 0);
+}
+
+const gcn::Color &Theme::getColor(int type) const
+{
+ return getPalette(0).getColor(type);
+}
+
+std::optional<int> Theme::getColorIdForChar(char c)
+{
+ switch (c) {
+ case '0': return BLACK;
+ case '1': return RED;
+ case '2': return GREEN;
+ case '3': return BLUE;
+ case '4': return ORANGE;
+ case '5': return YELLOW;
+ case '6': return PINK;
+ case '7': return PURPLE;
+ case '8': return GRAY;
+ case '9': return BROWN;
+
+ case 'H': return HIGHLIGHT;
+ case 'C': return CHAT;
+ case 'G': return GM;
+ case 'g': return GLOBAL;
+ case 'Y': return PLAYER;
+ case 'W': return WHISPER;
+ // case 'w': return WHISPER_TAB_OFFLINE;
+ case 'I': return IS;
+ case 'P': return PARTY;
+ case 'U': return GUILD;
+ case 'S': return SERVER;
+ case 'L': return LOGGER;
+ case '<': return HYPERLINK;
+ // case 's': return SELFNICK;
+ case 'o': return OLDCHAT;
+ case 'a': return AWAYCHAT;
+ }
+
+ return {};
+}
+
void Theme::drawSkin(Graphics *graphics, SkinType type, const WidgetState &state) const
{
getSkin(type).draw(graphics, state);
@@ -424,8 +459,8 @@ void Theme::updateAlpha()
mAlpha = alpha;
- for (auto &skin : mSkins)
- skin.second.updateAlpha(mAlpha);
+ for (auto &[_, skin] : mSkins)
+ skin.updateAlpha(mAlpha);
}
void Theme::event(Event::Channel channel, const Event &event)
@@ -465,8 +500,8 @@ bool Theme::readTheme(const ThemeInfo &themeInfo)
{
if (childNode.name() == "skin")
readSkinNode(childNode);
- else if (childNode.name() == "color")
- readColorNode(childNode);
+ else if (childNode.name() == "palette")
+ readPaletteNode(childNode);
else if (childNode.name() == "progressbar")
readProgressBarNode(childNode);
else if (childNode.name() == "icon")
@@ -534,6 +569,7 @@ void Theme::readSkinNode(XML::Node node)
node.attribute("titleBarHeight", skin.titleBarHeight);
node.attribute("titleOffsetX", skin.titleOffsetX);
node.attribute("titleOffsetY", skin.titleOffsetY);
+ node.attribute("palette", skin.palette);
node.attribute("showButtons", skin.showButtons);
for (auto childNode : node.children())
@@ -669,7 +705,7 @@ inline void fromString(const char *str, gcn::Color &value)
{
error:
logger->log("Error, invalid theme color palette: %s", str);
- value = Palette::BLACK;
+ value = gcn::Color(0, 0, 0);
return;
}
@@ -730,10 +766,37 @@ void Theme::readIconNode(XML::Node node)
mIcons[name] = image->getSubImage(x, y, width, height);
}
+void Theme::readPaletteNode(XML::Node node)
+{
+ int paletteId;
+ if (node.attribute("id", paletteId) && static_cast<size_t>(paletteId) != mPalettes.size())
+ logger->log("Theme: Non-consecutive palette 'id' attribute with value %d!", paletteId);
+
+ Palette &palette = mPalettes.emplace_back(THEME_COLORS_END);
+
+ for (auto childNode : node.children())
+ {
+ if (childNode.name() == "color")
+ readColorNode(childNode, palette);
+ else
+ logger->log("Theme: Unknown node '%s'!", childNode.name().data());
+ }
+}
+
static int readColorId(const std::string &id)
{
static constexpr const char *colors[Theme::THEME_COLORS_END] = {
"TEXT",
+ "BLACK",
+ "RED",
+ "GREEN",
+ "BLUE",
+ "ORANGE",
+ "YELLOW",
+ "PINK",
+ "PURPLE",
+ "GRAY",
+ "BROWN",
"CARET",
"SHADOW",
"OUTLINE",
@@ -745,8 +808,11 @@ static int readColorId(const std::string &id)
"SHOP_WARNING",
"ITEM_EQUIPPED",
"CHAT",
+ "OLDCHAT",
+ "AWAYCHAT",
"BUBBLE_TEXT",
"GM",
+ "GLOBAL",
"PLAYER",
"WHISPER",
"IS",
@@ -801,7 +867,7 @@ static Palette::GradientType readGradientType(const std::string &grad)
return Palette::STATIC;
}
-void Theme::readColorNode(XML::Node node)
+void Theme::readColorNode(XML::Node node, Palette &palette)
{
const auto idStr = node.getProperty("id", std::string());
const int id = readColorId(idStr);
@@ -812,9 +878,8 @@ void Theme::readColorNode(XML::Node node)
if (check(node.attribute("color", color), "Theme: 'color' element missing 'color' attribute!"))
return;
- const GradientType grad = readGradientType(node.getProperty("effect", std::string()));
-
- mColors[id].set(id, color, grad, 10);
+ const auto grad = readGradientType(node.getProperty("effect", std::string()));
+ palette.setColor(id, color, grad, 10);
}
static int readProgressId(const std::string &id)
diff --git a/src/resources/theme.h b/src/resources/theme.h
index b83c8aa3..6046667b 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -32,6 +32,7 @@
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <variant>
@@ -55,7 +56,7 @@ public:
const std::string &getName() const { return name; }
const std::string &getPath() const { return path; }
std::string getFullPath() const;
- XML::Document &getDocument() const { return *doc; }
+ const XML::Document &getDocument() const { return *doc; }
private:
std::string name;
@@ -181,13 +182,14 @@ class Skin
int titleBarHeight = 0;
int titleOffsetX = 0;
int titleOffsetY = 0;
+ int palette = 0;
bool showButtons = true;
private:
std::vector<SkinState> mStates;
};
-class Theme : public Palette, public EventListener
+class Theme : public EventListener
{
public:
static std::string prepareThemePath();
@@ -207,6 +209,16 @@ class Theme : public Palette, public EventListener
enum ThemePalette {
TEXT,
+ BLACK, // Color 0
+ RED, // Color 1
+ GREEN, // Color 2
+ BLUE, // Color 3
+ ORANGE, // Color 4
+ YELLOW, // Color 5
+ PINK, // Color 6
+ PURPLE, // Color 7
+ GRAY, // Color 8
+ BROWN, // Color 9
CARET,
SHADOW,
OUTLINE,
@@ -218,8 +230,11 @@ class Theme : public Palette, public EventListener
SHOP_WARNING,
ITEM_EQUIPPED,
CHAT,
+ OLDCHAT,
+ AWAYCHAT,
BUBBLE_TEXT,
GM,
+ GLOBAL,
PLAYER,
WHISPER,
IS,
@@ -259,18 +274,30 @@ class Theme : public Palette, public EventListener
};
/**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
+ * Gets the color associated with the type in the default palette (0).
*
* @param type the color type requested
- * @param alpha alpha channel to use
- *
* @return the requested color
*/
- static const gcn::Color &getThemeColor(int type, int alpha = 255);
- static const gcn::Color &getThemeColor(char c, bool &valid);
+ static const gcn::Color &getThemeColor(int type);
static gcn::Color getProgressColor(int type, float progress);
+
+ const Palette &getPalette(size_t index) const;
+
+ /**
+ * Returns a color from the default palette (0).
+ */
+ const gcn::Color &getColor(int type) const;
+
+ /**
+ * Returns the color ID associated with a character, if it exists.
+ * Returns no value if the character is not found.
+ *
+ * @param c character requested
+ * @return the requested color or none
+ */
+ static std::optional<int> getColorIdForChar(char c);
void drawSkin(Graphics *graphics, SkinType type, const WidgetState &state) const;
void drawProgressBar(Graphics *graphics,
@@ -314,7 +341,8 @@ class Theme : public Palette, public EventListener
void readSkinStateNode(XML::Node node, Skin &skin) const;
void readSkinStateImgNode(XML::Node node, SkinState &state) const;
void readIconNode(XML::Node node);
- void readColorNode(XML::Node node);
+ void readPaletteNode(XML::Node node);
+ void readColorNode(XML::Node node, Palette &palette);
void readProgressBarNode(XML::Node node);
std::string mThemePath;
@@ -328,5 +356,6 @@ class Theme : public Palette, public EventListener
float mMinimumOpacity = 0.0f;
float mAlpha = 1.0;
+ std::vector<Palette> mPalettes;
std::vector<std::unique_ptr<DyePalette>> mProgressColors;
};
diff --git a/src/textrenderer.h b/src/textrenderer.h
index c9cd9310..de4fcff2 100644
--- a/src/textrenderer.h
+++ b/src/textrenderer.h
@@ -64,9 +64,15 @@ public:
if (shadow)
{
if (shadowColor)
+ {
graphics->setColor(*shadowColor);
+ }
else
- graphics->setColor(Theme::getThemeColor(Theme::SHADOW, color.a / 2));
+ {
+ auto sc = Theme::getThemeColor(Theme::SHADOW);
+ sc.a = color.a / 2;
+ graphics->setColor(sc);
+ }
if (outline)
font->drawString(graphics, text, x + 2, y + 2);
@@ -87,9 +93,15 @@ public:
// Text outline
if (outlineColor)
+ {
graphics->setColor(*outlineColor);
+ }
else
- graphics->setColor(Theme::getThemeColor(Theme::OUTLINE, color.a));
+ {
+ auto oc = Theme::getThemeColor(Theme::OUTLINE);
+ oc.a = color.a;
+ graphics->setColor(oc);
+ }
font->drawString(graphics, text, x + 1, y);
font->drawString(graphics, text, x - 1, y);
diff --git a/src/utils/xml.h b/src/utils/xml.h
index d268c52c..fe896c60 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -47,7 +47,7 @@ namespace XML
std::string_view textContent() const;
template<typename T>
- bool attribute(const char *name, T &value);
+ bool attribute(const char *name, T &value) const;
bool hasAttribute(const char *name) const;
int getProperty(const char *name, int def) const;
@@ -126,7 +126,7 @@ namespace XML
}
template<typename T>
- inline bool Node::attribute(const char *name, T &value)
+ inline bool Node::attribute(const char *name, T &value) const
{
if (const char *str = attribute(name))
{
@@ -204,13 +204,13 @@ namespace XML
* Returns the root node of the document (or NULL if there was a
* load error).
*/
- Node rootNode();
+ Node rootNode() const;
private:
xmlDocPtr mDoc;
};
- inline Node Document::rootNode()
+ inline Node Document::rootNode() const
{
return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
}