refactor(core/rendering): desacoplar RenderInfo d'Options i UiColor (COUP-01b)

core/rendering/render_info ja no inclou game/options.hpp ni
game/ui/ui_palette.hpp. S'introdueix RenderInfo::Frame amb tot l'estat
extern (posició, show_time, shader_enabled, shader_name, shader_preset,
colors) que el caller injecta a cada init()/update(). La lògica de
persistència (cyclePosition/toggleShowTime) surt de RenderInfo i passa
a global_inputs.cpp, que muta Options i crida saveToFile() directament.

Options::buildRenderInfoFrame(text_color, shadow_color) centralitza la
construcció del Frame seguint el mateix patró que buildScreenConfig /
buildPostFXParams. Director i GameScene criden aquest builder quan
necessiten un Frame (amb UiColor::RENDER_INFO_{TEXT,SHADOW} com a
colors actius).

Amb aquest canvi queda tancada COUP-01: core/rendering/ no té cap
include de game/*.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
JailDesignerandClaude Opus 4.7 committed 2026-04-20 09:13:58 +02:00
1 parent 9434e4e87d
commit 9395520a23
8 files changed
+77 -59

No files matched your search

+15
View File
@@ -553,6 +553,21 @@ namespace Options {
return Rendering::ShaderType::POSTFX;
}
auto buildRenderInfoFrame(Uint8 text_color, Uint8 shadow_color) -> RenderInfo::Frame {
const std::string& active_preset = (video.shader.current_shader == "crtpi")
? video.shader.current_crtpi_preset
: video.shader.current_postfx_preset;
return {
.target_position = video.render_info_position,
.show_time = video.render_info_show_time,
.shader_enabled = video.shader.enabled,
.shader_name = video.shader.current_shader,
.shader_preset = active_preset,
.text_color = text_color,
.shadow_color = shadow_color,
};
}
auto buildCrtPiParams() -> Rendering::CrtPiParams {
// Si el shader està deshabilitat, retornem defaults (el dispatch anirà per
// PostFX passthrough, però sent nets per si algú consulta aquests params).
+4
View File
@@ -4,6 +4,7 @@
#include <vector>
#include "core/audio/audio.hpp"
#include "core/rendering/render_info.hpp"
#include "core/rendering/screen.hpp"
#include "core/rendering/shader_backend.hpp"
#include "utils/defaults.hpp"
@@ -121,6 +122,9 @@ namespace Options {
[[nodiscard]] auto buildPostFXParams() -> Rendering::PostFXParams;
[[nodiscard]] auto buildCrtPiParams() -> Rendering::CrtPiParams;
[[nodiscard]] auto buildActiveShader() -> Rendering::ShaderType;
// Els colors de text/ombra els decideix la UI del joc (no Options), per
// això es passen com a paràmetres.
[[nodiscard]] auto buildRenderInfoFrame(Uint8 text_color, Uint8 shadow_color) -> RenderInfo::Frame;
// `::Audio` és la classe global d'àudio (no `Options::Audio`, que és la
// struct serialitzable). Retornem la seua Config per passar-la a init().
[[nodiscard]] auto buildAudioConfig() -> ::Audio::Config;
+2 -1
View File
@@ -15,6 +15,7 @@
#include "core/resources/resource_cache.hpp"
#include "game/entities/player.hpp"
#include "game/map/map.hpp"
#include "game/options.hpp"
#include "game/ui/ui_palette.hpp"
#include "utils/defaults.hpp"
#include "utils/defines.hpp"
@@ -60,7 +61,7 @@ void GameScene::update(int delta_ms) {
const float DT = static_cast<float>(delta_ms) / 1000.0F;
for (auto& player : players_) { player->update(DT); }
RenderInfo::get().update(delta_ms);
RenderInfo::get().update(delta_ms, Options::buildRenderInfoFrame(UiColor::RENDER_INFO_TEXT, UiColor::RENDER_INFO_SHADOW));
Notifier::get().update(delta_ms);
}