COUP-01: notification_presets.hpp mogut de game/ui/ a core/rendering/
El fitxer definia presets del Notifier (que ja viu a core/rendering/), però estava a game/ i era consumit únicament per core/input/global_inputs.cpp — una dependència invertida core→game. El mogueu al costat del component que consumeix; el comentari de `notifier.hpp` hi apunta. `game/ui/` es queda només amb `ui_palette.hpp`.
This commit is contained in:
1 parent
e6c7f0dcfb
commit
ab7a79dc50
4 files changed
+5
-5
No files matched your search
@@ -7,12 +7,12 @@
|
||||
|
||||
#include "core/input/key_config.hpp"
|
||||
#include "core/locale/locale.hpp"
|
||||
#include "core/rendering/notification_presets.hpp"
|
||||
#include "core/rendering/notifier.hpp"
|
||||
#include "core/rendering/render_info.hpp"
|
||||
#include "core/rendering/screen.hpp"
|
||||
#include "core/system/event_buffer.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include "game/ui/notification_presets.hpp"
|
||||
#include "utils/defaults.hpp"
|
||||
|
||||
namespace GlobalInputs {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#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
|
||||
@@ -17,8 +17,8 @@ class Text;
|
||||
// a l'arrencada; si Notifier::init() es crida primer, les carrega ell).
|
||||
//
|
||||
// API crua: Notifier::get().notify(text, text_color, bg_color, time_ms).
|
||||
// Per a treballar amb presets del joc, vegeu Notification::notify() a
|
||||
// game/ui/notification_presets.hpp.
|
||||
// Per a treballar amb presets pre-definits, vegeu Notification::notify() a
|
||||
// core/rendering/notification_presets.hpp.
|
||||
class Notifier {
|
||||
public:
|
||||
static auto get() -> Notifier&;
|
||||
|
||||
Reference in new issue
Block a user