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>
This commit is contained in:
1 parent
9243db1b9f
commit
9434e4e87d
5 files changed
+27
-29
No files matched your search
@@ -12,6 +12,7 @@
|
||||
#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 {
|
||||
@@ -37,7 +38,7 @@ namespace GlobalInputs {
|
||||
}
|
||||
|
||||
void notifyLocale(const std::string& key) {
|
||||
Notifier::get().notify(Locale::get().text(key));
|
||||
Notification::notify(Locale::get().text(key));
|
||||
}
|
||||
|
||||
void onDecZoom() {
|
||||
@@ -46,7 +47,7 @@ namespace GlobalInputs {
|
||||
Options::window.zoom--;
|
||||
Screen::get().setWindowZoom(Options::window.zoom);
|
||||
Options::saveToFile();
|
||||
Notifier::get().notify(Locale::get().text("input.zoom") + " x" + std::to_string(Options::window.zoom));
|
||||
Notification::notify(Locale::get().text("input.zoom") + " x" + std::to_string(Options::window.zoom));
|
||||
}
|
||||
|
||||
void onIncZoom() {
|
||||
@@ -55,7 +56,7 @@ namespace GlobalInputs {
|
||||
Options::window.zoom++;
|
||||
Screen::get().setWindowZoom(Options::window.zoom);
|
||||
Options::saveToFile();
|
||||
Notifier::get().notify(Locale::get().text("input.zoom") + " x" + std::to_string(Options::window.zoom));
|
||||
Notification::notify(Locale::get().text("input.zoom") + " x" + std::to_string(Options::window.zoom));
|
||||
}
|
||||
|
||||
void onFullscreen() {
|
||||
@@ -83,7 +84,7 @@ namespace GlobalInputs {
|
||||
Options::video.shader.current_shader = (Options::video.shader.current_shader == "crtpi") ? "postfx" : "crtpi";
|
||||
reapplyShader();
|
||||
Options::saveToFile();
|
||||
Notifier::get().notify(Locale::get().text("input.shader") + ": " + Options::video.shader.current_shader);
|
||||
Notification::notify(Locale::get().text("input.shader") + ": " + Options::video.shader.current_shader);
|
||||
}
|
||||
|
||||
// Busca l'entrada actual al vector de presets i passa a la següent
|
||||
@@ -108,7 +109,7 @@ namespace GlobalInputs {
|
||||
reapplyShader();
|
||||
Options::saveToFile();
|
||||
const std::string& name = IS_CRTPI ? Options::video.shader.current_crtpi_preset : Options::video.shader.current_postfx_preset;
|
||||
Notifier::get().notify(Locale::get().text("input.preset") + ": " + name);
|
||||
Notification::notify(Locale::get().text("input.preset") + ": " + name);
|
||||
}
|
||||
|
||||
void onNextScalingMode() {
|
||||
@@ -151,7 +152,7 @@ namespace GlobalInputs {
|
||||
return;
|
||||
}
|
||||
exit_window_s = EXIT_WINDOW_S;
|
||||
Notifier::get().notify(Locale::get().text("input.press_again_exit"), Notification::EXIT);
|
||||
Notification::notify(Locale::get().text("input.press_again_exit"), Notification::EXIT);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -67,14 +67,6 @@ void Notifier::render() {
|
||||
current_text_color_);
|
||||
}
|
||||
|
||||
void Notifier::notify(const std::string& text) {
|
||||
notify(text, Notification::DEFAULT);
|
||||
}
|
||||
|
||||
void Notifier::notify(const std::string& text, const Notification::Preset& preset) {
|
||||
notify(text, preset.text_color, preset.bg_color, preset.time_ms);
|
||||
}
|
||||
|
||||
void Notifier::notify(const std::string& text, Uint8 text_color, Uint8 bg_color, int time_ms) {
|
||||
// Política simple: la nova notificació reemplaça la que hi havia. Per
|
||||
// gestionar-ne una cua, canviar ací per una FIFO quan calga.
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "game/ui/notification_presets.hpp"
|
||||
|
||||
class Text;
|
||||
|
||||
// Popup transitori a dalt i centrat. Entra lliscant des de dalt, es queda
|
||||
@@ -15,10 +13,9 @@ class Text;
|
||||
// 8bithud i la paleta "ui" amb la resta d'overlays (carregades per RenderInfo
|
||||
// a l'arrencada; si Notifier::init() es crida primer, les carrega ell).
|
||||
//
|
||||
// Ús típic:
|
||||
// Notifier::get().notify("Text ràpid"); // preset DEFAULT
|
||||
// Notifier::get().notify("Text ràpid", miPreset); // preset custom
|
||||
// Notifier::get().notify("Urgent", 11, 3, 800); // colors i durada explícits
|
||||
// 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.
|
||||
class Notifier {
|
||||
public:
|
||||
static auto get() -> Notifier&;
|
||||
@@ -33,9 +30,6 @@ class Notifier {
|
||||
void update(int delta_ms);
|
||||
void render();
|
||||
|
||||
// Tres overloads; els dos simples deleguen al tercer.
|
||||
void notify(const std::string& text);
|
||||
void notify(const std::string& text, const Notification::Preset& preset);
|
||||
void notify(const std::string& text, Uint8 text_color, Uint8 bg_color, int time_ms);
|
||||
|
||||
static constexpr int PADDING_H = 6;
|
||||
|
||||
Reference in new issue
Block a user