- renderInfo

- fix: no guardava el preset actual
This commit is contained in:
2026-04-04 20:14:11 +02:00
parent eb3f449a1e
commit d4fc7c0ee8
12 changed files with 197 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ namespace Defaults::KeysGUI {
constexpr SDL_Scancode NEXT_SHADER = SDL_SCANCODE_F7;
constexpr SDL_Scancode NEXT_SHADER_PRESET = SDL_SCANCODE_F8;
constexpr SDL_Scancode TOGGLE_STRETCH_FILTER = SDL_SCANCODE_F9;
constexpr SDL_Scancode TOGGLE_RENDER_INFO = SDL_SCANCODE_F10;
} // namespace Defaults::KeysGUI
// Tecles de joc (moviment del personatge, accions)

View File

@@ -61,6 +61,31 @@ namespace Options {
video.downscale_algo = node["downscale_algo"].get_value<int>();
if (node.contains("linear_upscale"))
video.linear_upscale = node["linear_upscale"].get_value<bool>();
if (node.contains("current_shader"))
video.current_shader = node["current_shader"].get_value<std::string>();
if (node.contains("current_postfx_preset"))
video.current_postfx_preset = node["current_postfx_preset"].get_value<std::string>();
if (node.contains("current_crtpi_preset"))
video.current_crtpi_preset = node["current_crtpi_preset"].get_value<std::string>();
}
static void loadRenderInfoFromYaml(const fkyaml::node& yaml) {
if (!yaml.contains("render_info")) return;
const auto& node = yaml["render_info"];
if (node.contains("position")) {
auto pos = node["position"].get_value<std::string>();
if (pos == "top")
render_info.position = RenderInfoPosition::TOP;
else if (pos == "bottom")
render_info.position = RenderInfoPosition::BOTTOM;
else
render_info.position = RenderInfoPosition::OFF;
}
if (node.contains("text_color"))
render_info.text_color = static_cast<Uint32>(node["text_color"].get_value<uint64_t>());
if (node.contains("shadow_color"))
render_info.shadow_color = static_cast<Uint32>(node["shadow_color"].get_value<uint64_t>());
}
static void loadWindowConfigFromYaml(const fkyaml::node& yaml) {
@@ -117,6 +142,7 @@ namespace Options {
}
loadVideoConfigFromYaml(yaml);
loadRenderInfoFromYaml(yaml);
loadWindowConfigFromYaml(yaml);
loadAudioConfigFromYaml(yaml);
loadGameConfigFromYaml(yaml);
@@ -163,6 +189,24 @@ namespace Options {
file << " stretch_filter_linear: " << (video.stretch_filter_linear ? "true" : "false") << " # filtre 4:3: false=nearest, true=linear\n";
file << " downscale_algo: " << video.downscale_algo << " # 0=bilinear, 1=Lanczos2, 2=Lanczos3\n";
file << " linear_upscale: " << (video.linear_upscale ? "true" : "false") << "\n";
file << " current_shader: " << video.current_shader << "\n";
file << " current_postfx_preset: " << video.current_postfx_preset << "\n";
file << " current_crtpi_preset: " << video.current_crtpi_preset << "\n";
file << "\n";
// RENDER INFO
file << "# RENDER INFO\n";
file << "render_info:\n";
{
const char* pos = "off";
if (render_info.position == RenderInfoPosition::TOP)
pos = "top";
else if (render_info.position == RenderInfoPosition::BOTTOM)
pos = "bottom";
file << " position: " << pos << " # off/top/bottom\n";
}
file << " text_color: " << render_info.text_color << "\n";
file << " shadow_color: " << render_info.shadow_color << "\n";
file << "\n";
// WINDOW

View File

@@ -19,6 +19,7 @@ namespace Options {
SDL_Scancode next_shader{Defaults::KeysGUI::NEXT_SHADER};
SDL_Scancode next_shader_preset{Defaults::KeysGUI::NEXT_SHADER_PRESET};
SDL_Scancode toggle_stretch_filter{Defaults::KeysGUI::TOGGLE_STRETCH_FILTER};
SDL_Scancode toggle_render_info{Defaults::KeysGUI::TOGGLE_RENDER_INFO};
};
// Tecles de joc (moviment, accions)
@@ -30,6 +31,11 @@ namespace Options {
SDL_Scancode exit{Defaults::KeysGame::EXIT};
};
// Posició del render info
enum class RenderInfoPosition { OFF = 0,
TOP = 1,
BOTTOM = 2 };
// Opcions de vídeo
struct Video {
bool gpu_acceleration{Defaults::Video::GPU_ACCELERATION};
@@ -40,6 +46,16 @@ namespace Options {
bool stretch_filter_linear{Defaults::Video::STRETCH_FILTER_LINEAR};
int downscale_algo{Defaults::Video::DOWNSCALE_ALGO};
bool linear_upscale{Defaults::Video::LINEAR_UPSCALE};
std::string current_shader{"postfx"}; // "postfx" o "crtpi"
std::string current_postfx_preset{"CRT"}; // Nom del preset PostFX actiu
std::string current_crtpi_preset{"DEFAULT"}; // Nom del preset CrtPi actiu
};
// Opcions del render info
struct RenderInfo {
RenderInfoPosition position{RenderInfoPosition::OFF};
Uint32 text_color{0xFF00D7FF}; // Groc daurat (ABGR)
Uint32 shadow_color{0xFF005A6B}; // Ombra daurada fosca (ABGR)
};
// Opcions d'àudio
@@ -101,6 +117,7 @@ namespace Options {
inline KeysGUI keys_gui{};
inline KeysGame keys_game{};
inline Video video{};
inline RenderInfo render_info{};
inline Audio audio{};
inline Window window{};
inline Game game{};