From 3b05704e97cbe12b4c02d1adebf4f4b01afd8693 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 26 Apr 2026 17:02:26 +0200 Subject: [PATCH] =?UTF-8?q?feat(intro):=20colors=20del=20r=C3=A8tol=20inde?= =?UTF-8?q?pendents=20+=20restitueix=20line=5Fgap=5Fpx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dues claus noves a data/ui.yaml > colors: room_text (relleno, default 232) room_text_outline (contorn, default 255) Abans el relleno reciclava notification_text (compartit amb les notificacions del HUD) i el contorn estava hardcodejat a 255 dins renderRoomText. Ara són canals separats: tocar el rètol no afecta les notificacions i tot viu al YAML. UiConfig guanya roomText() / roomTextOutline(); Defaults::UI hi posa els fallbacks; renderRoomText els consumeix. Drive-by: torna a posar la clau room_intro.line_gap_px: 8 al data/scenes/game.yaml — s'havia perdut en una edició manual del fitxer per afinar timings. --- data/scenes/game.yaml | 7 ++++--- data/ui.yaml | 6 ++++++ source/core/ui/ui_config.cpp | 4 ++++ source/core/ui/ui_config.hpp | 4 ++++ source/game/scenes/game_scene.cpp | 11 ++++++++--- source/utils/defaults.hpp | 7 +++++++ 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/data/scenes/game.yaml b/data/scenes/game.yaml index 93e04ee..1a3353e 100644 --- a/data/scenes/game.yaml +++ b/data/scenes/game.yaml @@ -7,9 +7,10 @@ room_intro: fade_in_ms: 500 # negre opac → món visible text_delay_ms: 500 # espera amb el món net abans de sortir el text - text_enter_ms: 500 # text esquerra → centre - text_hold_ms: 1000 # text quiet al centre - text_exit_ms: 500 # text centre → fora per l'esquerra + text_enter_ms: 400 # text esquerra → centre + text_hold_ms: 1500 # text quiet al centre + text_exit_ms: 400 # text centre → fora per l'esquerra + line_gap_px: 8 # px extra entre les dues línies (piràmide / sala) room_outro: text_enter_ms: 500 diff --git a/data/ui.yaml b/data/ui.yaml index 62081a3..de6a63b 100644 --- a/data/ui.yaml +++ b/data/ui.yaml @@ -20,6 +20,12 @@ colors: hud_label: 58 hud_value: 187 hud_flash: 237 + # Rètol de transició de sala (ROOM_INTRO i ROOM_OUTRO). Independents + # de notification_* perquè la fase i les notificacions són dos canals + # visuals distints: ací pots canviar el color del rètol sense tocar + # els missatges del HUD. + room_text: 232 + room_text_outline: 255 timings: notification_ms: 4000 diff --git a/source/core/ui/ui_config.cpp b/source/core/ui/ui_config.cpp index faa1a87..92e3bb6 100644 --- a/source/core/ui/ui_config.cpp +++ b/source/core/ui/ui_config.cpp @@ -85,6 +85,8 @@ UiConfig::UiConfig() hud_label_(Defaults::UI::HUD_LABEL), hud_value_(Defaults::UI::HUD_VALUE), hud_flash_(Defaults::UI::HUD_FLASH), + room_text_(Defaults::UI::ROOM_TEXT), + room_text_outline_(Defaults::UI::ROOM_TEXT_OUTLINE), notification_ms_(Defaults::UI::NOTIFICATION_TIME_MS), exit_ms_(Defaults::UI::EXIT_TIME_MS), hud_entry_ms_(Defaults::UI::HUD_ENTRY_MS), @@ -148,6 +150,8 @@ void UiConfig::load(const std::string& file_path) { readColorIndex(c, "hud_label", hud_label_); readColorIndex(c, "hud_value", hud_value_); readColorIndex(c, "hud_flash", hud_flash_); + readColorIndex(c, "room_text", room_text_); + readColorIndex(c, "room_text_outline", room_text_outline_); } if (yaml.contains("timings")) { diff --git a/source/core/ui/ui_config.hpp b/source/core/ui/ui_config.hpp index 44df727..1219006 100644 --- a/source/core/ui/ui_config.hpp +++ b/source/core/ui/ui_config.hpp @@ -48,6 +48,8 @@ class UiConfig { [[nodiscard]] auto hudLabel() const -> Uint8 { return hud_label_; } [[nodiscard]] auto hudValue() const -> Uint8 { return hud_value_; } [[nodiscard]] auto hudFlash() const -> Uint8 { return hud_flash_; } + [[nodiscard]] auto roomText() const -> Uint8 { return room_text_; } + [[nodiscard]] auto roomTextOutline() const -> Uint8 { return room_text_outline_; } // Signatura d'una funció d'easing: t ∈ [0, 1] → valor ∈ [0, 1]. // Permet triar corbes des de data/ui.yaml per nom (cadena) i guardar @@ -106,6 +108,8 @@ class UiConfig { Uint8 hud_label_; Uint8 hud_value_; Uint8 hud_flash_; + Uint8 room_text_; + Uint8 room_text_outline_; int notification_ms_; int exit_ms_; diff --git a/source/game/scenes/game_scene.cpp b/source/game/scenes/game_scene.cpp index a7f37ef..2f66be5 100644 --- a/source/game/scenes/game_scene.cpp +++ b/source/game/scenes/game_scene.cpp @@ -649,8 +649,13 @@ void GameScene::renderRoomText() { if (!room_text_font_) { return; } constexpr int KERNING = 0; - constexpr Uint8 OUTLINE_WHITE = 255; constexpr Uint8 STROKE_DIST = 1; + // Colors del rètol via UiConfig — abans el contorn estava + // hardcodejat a 255. Ara `data/ui.yaml > colors.room_text` i + // `room_text_outline` controlen relleno i contorn sense afectar + // les notificacions del HUD. + const Uint8 FILL_COLOR = UiConfig::get().roomText(); + const Uint8 OUTLINE_COLOR = UiConfig::get().roomTextOutline(); // Calcula la X animada d'una línia: entra des de fora de pantalla, // s'atura al CENTER_X durant el hold i surt pel costat oposat. @@ -686,9 +691,9 @@ void GameScene::renderRoomText() { y, text, KERNING, - UiConfig::get().notificationText(), + FILL_COLOR, STROKE_DIST, - OUTLINE_WHITE); + OUTLINE_COLOR); }; if (state_ == RoomFsm::State::ROOM_INTRO && transition_.phase >= 2 && transition_.phase <= 4) { diff --git a/source/utils/defaults.hpp b/source/utils/defaults.hpp index d8e2905..739056b 100644 --- a/source/utils/defaults.hpp +++ b/source/utils/defaults.hpp @@ -191,6 +191,13 @@ namespace Defaults { constexpr Uint8 HUD_VALUE = 187; // Valors (score, vides, tresors). constexpr Uint8 HUD_FLASH = 237; // Color temporal del valor en flash. + // Rètol de transició de sala (ROOM_INTRO i ROOM_OUTRO). + // Independent dels colors de notificació perquè el rètol de + // fase és un canal visual diferent. `ROOM_TEXT_OUTLINE` és el + // contorn que abans estava hardcodejat al `renderRoomText`. + constexpr Uint8 ROOM_TEXT = 232; + constexpr Uint8 ROOM_TEXT_OUTLINE = 255; + // Timings d'animació del HUD. L'entrada són els tres blocs lliscant // a la seua posició; flash i shake acompanyen un `player_hit`. constexpr int HUD_ENTRY_MS = 400;