129 lines
4.4 KiB
C++
129 lines
4.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/audio/audio.hpp"
|
|
#include "core/rendering/screen.hpp"
|
|
#include "core/rendering/shader_backend.hpp"
|
|
#include "utils/defaults.hpp"
|
|
|
|
// Gestor de configuració del joc. És l'ÚNIC lloc que coneix YAML i la ruta
|
|
// del config.yaml. Els subsistemes (Screen, Audio, ...) reben structs tipats
|
|
// a través dels build*Config(), de manera que no queden acoblats a aquest
|
|
// namespace ni al format concret del fitxer.
|
|
namespace Options {
|
|
|
|
struct Window {
|
|
int zoom{Defaults::Window::ZOOM};
|
|
bool fullscreen{Defaults::Window::FULLSCREEN};
|
|
};
|
|
|
|
struct Gpu {
|
|
bool acceleration{Defaults::Video::GPU_ACCELERATION};
|
|
std::string preferred_driver{Defaults::Video::GPU_PREFERRED_DRIVER};
|
|
};
|
|
|
|
struct Shader {
|
|
bool enabled{Defaults::Video::SHADER_ENABLED};
|
|
std::string current_shader{Defaults::Video::CURRENT_SHADER}; // "postfx" o "crtpi"
|
|
std::string current_postfx_preset{Defaults::Video::POSTFX_DEFAULT_PRESET};
|
|
std::string current_crtpi_preset{Defaults::Video::CRTPI_DEFAULT_PRESET};
|
|
};
|
|
|
|
struct Video {
|
|
bool vsync{Defaults::Video::VSYNC};
|
|
Defaults::ScalingMode scaling_mode{Defaults::Video::SCALING_MODE};
|
|
Defaults::TextureFilter texture_filter{Defaults::Video::TEXTURE_FILTER};
|
|
Defaults::RenderInfoPosition render_info_position{Defaults::Video::RENDER_INFO_POSITION};
|
|
bool render_info_show_time{Defaults::Video::RENDER_INFO_SHOW_TIME};
|
|
Gpu gpu{};
|
|
Shader shader{};
|
|
};
|
|
|
|
// Preset d'efectes PostFX (un per entrada a postfx.yaml).
|
|
struct PostFXPreset {
|
|
std::string name;
|
|
float vignette{0.0F};
|
|
float scanlines{0.0F};
|
|
float chroma{0.0F};
|
|
float mask{0.0F};
|
|
float gamma{0.0F};
|
|
float curvature{0.0F};
|
|
float bleeding{0.0F};
|
|
float flicker{0.0F};
|
|
};
|
|
|
|
// Preset del shader CRT-Pi (un per entrada a crtpi.yaml).
|
|
struct CrtPiPreset {
|
|
std::string name;
|
|
float scanline_weight{6.0F};
|
|
float scanline_gap_brightness{0.12F};
|
|
float bloom_factor{3.5F};
|
|
float input_gamma{2.4F};
|
|
float output_gamma{2.2F};
|
|
float mask_brightness{0.80F};
|
|
float curvature_x{0.05F};
|
|
float curvature_y{0.10F};
|
|
int mask_type{2};
|
|
bool enable_scanlines{true};
|
|
bool enable_multisample{true};
|
|
bool enable_gamma{true};
|
|
bool enable_curvature{false};
|
|
bool enable_sharper{false};
|
|
};
|
|
|
|
struct Music {
|
|
bool enabled{Defaults::Audio::MUSIC_ENABLED};
|
|
float volume{Defaults::Audio::MUSIC_VOLUME};
|
|
};
|
|
|
|
struct Sound {
|
|
bool enabled{Defaults::Audio::SOUND_ENABLED};
|
|
float volume{Defaults::Audio::SOUND_VOLUME};
|
|
};
|
|
|
|
struct Audio {
|
|
bool enabled{Defaults::Audio::ENABLED};
|
|
float volume{Defaults::Audio::VOLUME};
|
|
Music music{};
|
|
Sound sound{};
|
|
};
|
|
|
|
// --- Estat global (inline vars per a que una sola definició viva a tot
|
|
// el programa sense necessitar un .cpp extra per a cada una) ---
|
|
inline std::string config_version{};
|
|
inline std::string config_file_path{};
|
|
inline std::string postfx_file_path{};
|
|
inline std::string crtpi_file_path{};
|
|
inline std::string locale{Defaults::I18n::LOCALE};
|
|
inline Window window{};
|
|
inline Video video{};
|
|
inline Audio audio{};
|
|
inline std::vector<PostFXPreset> postfx_presets{};
|
|
inline std::vector<CrtPiPreset> crtpi_presets{};
|
|
|
|
// --- API pública ---
|
|
void setConfigFile(const std::string& path);
|
|
auto loadFromFile() -> bool;
|
|
auto saveToFile() -> bool;
|
|
|
|
void setPostFXFile(const std::string& path);
|
|
auto loadPostFXFromFile() -> bool;
|
|
auto savePostFXToFile() -> bool;
|
|
|
|
void setCrtPiFile(const std::string& path);
|
|
auto loadCrtPiFromFile() -> bool;
|
|
auto saveCrtPiToFile() -> bool;
|
|
|
|
// --- Builders per als subsistemes ---
|
|
[[nodiscard]] auto buildScreenConfig() -> Screen::Config;
|
|
[[nodiscard]] auto buildPostFXParams() -> Rendering::PostFXParams;
|
|
[[nodiscard]] auto buildCrtPiParams() -> Rendering::CrtPiParams;
|
|
[[nodiscard]] auto buildActiveShader() -> Rendering::ShaderType;
|
|
// `::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;
|
|
|
|
} // namespace Options
|