From 0e8a195ddd42c61ed76880eb5b347c3d637c7a05 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 14 May 2026 09:39:46 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui):=20temes=20de=20color=20del=20men?= =?UTF-8?q?=C3=BA=20amb=20tema=20eg=C3=ADpci=20per=20defecte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config/ui.yaml | 42 ++++++++++++++++++++++++++++++------ source/core/ui/ui_config.cpp | 29 +++++++++++++++++++------ 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/data/config/ui.yaml b/data/config/ui.yaml index 8eb2af3..42ef72a 100644 --- a/data/config/ui.yaml +++ b/data/config/ui.yaml @@ -9,13 +9,6 @@ colors: notification_bg: 64 exit_text: 71 exit_bg: 2 - menu_bg: 2 - menu_border: 232 - menu_title: 237 - menu_label: 58 - menu_value: 232 - menu_cursor: 71 - menu_disabled: 16 hud_bg: 9 hud_flash: 63 # Rètol de transició de sala (ROOM_INTRO i ROOM_OUTRO). Independents @@ -27,6 +20,41 @@ colors: room_text: 55 # or brillant (#FFDA00, = hud_center.value) room_text_outline: 10 # marró cremat (#482400, = hud_center.shadow) +# Tema actiu del menú de servei. Ha de coincidir amb una clau de +# `menu_themes`; si manca o no existeix, cada slot cau al default +# compilat a Defaults::UI (= tema "classic"). Canviar de tema requereix +# reiniciar el joc — la càrrega de paleta es fa només en arrencar. +menu_theme: egyptian + +# Conjunts de colors del menú de servei. Cada tema defineix els 7 slots +# (sense prefix `menu_` perquè ja som dins del bloc del tema). Si manca +# alguna clau dins d'un tema, cau al default compilat. Per afegir un +# tema nou, només cal una nova entrada aquí i posar-ne el nom a +# `menu_theme`. +menu_themes: + # Tema històric (defaults compilats). Cian + verd llima + magenta — + # paleta arcade clàssica, freda i amb molt contrast. + classic: + bg: 2 # marró-vermell fosc (#480000) + border: 232 # cian brillant (#00B6FF) + title: 237 # lavanda (#B6B6FF) + label: 58 # verd llima (#48FF00) + value: 232 # cian brillant (#00B6FF) — coincideix amb el border + cursor: 71 # magenta-vermell (#FF0055) + disabled: 16 # verd fosc (#004800) + # Tema "egípci": família or/ambre/marró coherent amb el HUD i el + # rètol de transició de sala (room_text). El bg comparteix to amb + # `room_text_outline` i `hud_center.shadow` perquè el menú "creixi" + # del mateix món visual que el joc. + egyptian: + bg: 10 # marró cremat (#482400) + border: 55 # or brillant (#FFDA00) + title: 127 # groc llimona viu (#FFFF55) + label: 47 # ambre (#FFB600) + value: 191 # crema clar (#FFFFAA) + cursor: 23 # vermilló (#FF4800) + disabled: 19 # oliva fosc (#6D4800) + timings: notification_ms: 4000 exit_ms: 4000 diff --git a/source/core/ui/ui_config.cpp b/source/core/ui/ui_config.cpp index 4067a44..b158274 100644 --- a/source/core/ui/ui_config.cpp +++ b/source/core/ui/ui_config.cpp @@ -215,19 +215,34 @@ void UiConfig::load(const std::string& file_path) { readColorIndex(c, "notification_bg", notification_bg_); readColorIndex(c, "exit_text", exit_text_); readColorIndex(c, "exit_bg", exit_bg_); - readColorIndex(c, "menu_bg", menu_bg_); - readColorIndex(c, "menu_border", menu_border_); - readColorIndex(c, "menu_title", menu_title_); - readColorIndex(c, "menu_label", menu_label_); - readColorIndex(c, "menu_value", menu_value_); - readColorIndex(c, "menu_cursor", menu_cursor_); - readColorIndex(c, "menu_disabled", menu_disabled_); readColorIndex(c, "hud_bg", hud_bg_); readColorIndex(c, "hud_flash", hud_flash_); readColorIndex(c, "room_text", room_text_); readColorIndex(c, "room_text_outline", room_text_outline_); } + // Tema actiu del menú: `menu_theme` és el nom del bloc dins de + // `menu_themes` que aporta els 7 slots de color. Si qualsevol + // de les dues claus manca o el nom no existeix, els slots + // queden amb el default compilat (= tema "classic" hardcoded + // a Defaults::UI). Per-key dins del tema també és opcional. + if (yaml.contains("menu_theme") && yaml.contains("menu_themes")) { + const auto THEME_NAME = yaml["menu_theme"].get_value(); + const auto& themes = yaml["menu_themes"]; + if (themes.contains(THEME_NAME)) { + const auto& t = themes[THEME_NAME]; + readColorIndex(t, "bg", menu_bg_); + readColorIndex(t, "border", menu_border_); + readColorIndex(t, "title", menu_title_); + readColorIndex(t, "label", menu_label_); + readColorIndex(t, "value", menu_value_); + readColorIndex(t, "cursor", menu_cursor_); + readColorIndex(t, "disabled", menu_disabled_); + } else { + Log::warn("UiConfig", "menu_theme '{}' no existeix a menu_themes — s'usen defaults", THEME_NAME); + } + } + // Famílies de color del HUD: blocs `hud_p1`, `hud_center`, // `hud_p2` amb claus `label`, `value`, `shadow`. Cada bloc i // cada clau són opcionals — el que manqui cau al default