#pragma once #include #include #include "core/rendering/notifier.hpp" #include "core/ui/ui_config.hpp" // Temes per a les notificacions de pantalla. Un "preset" captura els dos // colors (text i fons, índexs sobre la paleta "ui") i el temps de visibilitat // en mil·lisegons. Els valors concrets viuen a data/config/ui.yaml (carregat per // UiConfig); per llançar una notificació amb un preset concret, cridar // Notification::notify(text, preset). Sense preset s'usa el DEFAULT. namespace Notification { struct Preset { Uint8 text_color; Uint8 bg_color; int time_ms; }; // Preset per defecte: text clar sobre fons fosc. Es construeix en cada // crida a partir d'UiConfig perquè els valors no són constexpr: viuen a // data/config/ui.yaml i es carreguen a l'arrencada. [[nodiscard]] inline auto defaultPreset() -> Preset { return { .text_color = UiConfig::get().notificationText(), .bg_color = UiConfig::get().notificationBg(), .time_ms = UiConfig::get().notificationMs(), }; } // Preset per al missatge de confirmació d'eixida (ESC doble). Color // d'accent per distingir-lo d'una notificació informativa; la durada // coincideix amb la finestra durant la qual la segona pulsació d'ESC // confirma el tancament — veure GlobalInputs::onExit. [[nodiscard]] inline auto exitPreset() -> Preset { return { .text_color = UiConfig::get().exitText(), .bg_color = UiConfig::get().exitBg(), .time_ms = UiConfig::get().exitMs(), }; } // Helper de conveniència: aplica un preset (per defecte el DEFAULT) // cridant la API crua de Notifier. La direcció game → core és correcta. inline void notify(const std::string& text) { const auto P = defaultPreset(); Notifier::get().notify(text, P.text_color, P.bg_color, P.time_ms); } inline void notify(const std::string& text, const Preset& preset) { Notifier::get().notify(text, preset.text_color, preset.bg_color, preset.time_ms); } } // namespace Notification