59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "core/rendering/screen.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 Video {
|
|
bool vsync{Defaults::Video::VSYNC};
|
|
Defaults::ScalingMode scaling_mode{Defaults::Video::SCALING_MODE};
|
|
Defaults::TextureFilter texture_filter{Defaults::Video::TEXTURE_FILTER};
|
|
};
|
|
|
|
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 Window window{};
|
|
inline Video video{};
|
|
inline Audio audio{};
|
|
|
|
// --- API pública ---
|
|
void setConfigFile(const std::string& path);
|
|
auto loadFromFile() -> bool;
|
|
auto saveToFile() -> bool;
|
|
|
|
// --- Builders per als subsistemes ---
|
|
[[nodiscard]] auto buildScreenConfig() -> Screen::Config;
|
|
|
|
} // namespace Options
|