Files
aee-arcade/source/core/rendering/notification_presets.hpp
T
JailDesigner dc8a7723e3 feat(ui): captura F9, tema a data/ui.yaml i retocs estètics
Captura de pantalla amb F9: volca el canvas ARGB a
screenshots/scr_<timestamp>.png via stb_image_write.

Tot el tema d'UI (colors, timings, fonts, flag hud.bg_enabled)
passa a data/ui.yaml via UiConfig; els valors de Defaults::UI
queden com a fallbacks si el fitxer falta o li manca alguna clau.

Retocs estètics: paleta "uzebox" per a la UI, strings del HUD
(P1/P2/V/T/PIRAMIDE/SALA) traduïts a locale, i fons del marcador
opcional amb backdrop continu de franja per evitar el trencament
visual durant el shake o l'animació d'entrada dels panells.
2026-04-24 10:58:02 +02:00

57 lines
2.1 KiB
C++

#pragma once
#include <SDL3/SDL.h>
#include <string>
#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/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/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