Files
aee-arcade/source/game/ui/notification_presets.hpp
T
JailDesignerandClaude Opus 4.7 9434e4e87d refactor(core/rendering): desacoplar Notifier de game/ui (COUP-01a)
core/rendering/notifier.hpp ja no inclou game/ui/notification_presets.hpp,
i Notifier només exposa l'API crua notify(text, text_color, bg_color,
time_ms). El helper de conveniència basat en Preset es trasllada com a
funció lliure Notification::notify() a game/ui/notification_presets.hpp
(direcció game → core, correcta). Els callers de global_inputs.cpp
passen a usar el helper i afegeixen l'include explícit.

Sota l'auditoria de core/rendering (docs/audit-core-rendering.md).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 09:06:40 +02:00

47 lines
1.6 KiB
C++

#pragma once
#include <SDL3/SDL.h>
#include <string>
#include "core/rendering/notifier.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. Per a llançar una notificació amb un preset concret,
// cridar Notification::notify(text, preset); si s'omet, s'usa DEFAULT.
namespace Notification {
struct Preset {
Uint8 text_color;
Uint8 bg_color;
int time_ms;
};
// Tema per defecte: text clar sobre fons fosc, 2 segons de visibilitat.
// Per a ajustar l'aparença global de totes les notificacions sense
// presetejar-les manualment, toca només aquest bloc.
constexpr Preset DEFAULT{
.text_color = 197,
.bg_color = 96,
.time_ms = 4000,
};
// Preset per al missatge de confirmació d'eixida (ESC doble). Color
// d'accent per a 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.
constexpr Preset EXIT{
.text_color = 88,
.bg_color = 40,
.time_ms = 4000,
};
// Helper de conveniència: aplica un preset (per defecte DEFAULT) cridant
// la API crua de Notifier. La direcció game → core és la correcta.
inline void notify(const std::string& text, const Preset& preset = DEFAULT) {
Notifier::get().notify(text, preset.text_color, preset.bg_color, preset.time_ms);
}
} // namespace Notification