afegit vsync toggle
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "../../core/rendering/sdl_manager.hpp"
|
||||
#include "../../core/types.hpp"
|
||||
#include "../effects/debris_manager.hpp"
|
||||
#include "core/defaults.hpp"
|
||||
|
||||
class EscenaLogo {
|
||||
public:
|
||||
@@ -64,8 +65,8 @@ class EscenaLogo {
|
||||
|
||||
// Constants d'animació seqüencial
|
||||
static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0)
|
||||
static constexpr float ORIGEN_ZOOM_X = 640.0f / 2.0f; // Punt inicial X del zoom (320)
|
||||
static constexpr float ORIGEN_ZOOM_Y = 480.0f * 0.4f; // Punt inicial Y del zoom (240)
|
||||
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5f; // Punt inicial X del zoom
|
||||
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4f; // Punt inicial Y del zoom
|
||||
|
||||
// Mètodes privats
|
||||
void inicialitzar_lletres();
|
||||
|
||||
@@ -36,6 +36,9 @@ void init() {
|
||||
gameplay.max_enemies = Defaults::Entities::MAX_ORNIS;
|
||||
gameplay.max_bullets = Defaults::Entities::MAX_BALES;
|
||||
|
||||
// Rendering
|
||||
rendering.vsync = Defaults::Rendering::VSYNC_DEFAULT;
|
||||
|
||||
// Version
|
||||
version = std::string(Project::VERSION);
|
||||
}
|
||||
@@ -181,6 +184,22 @@ static void loadGameplayConfigFromYaml(const fkyaml::node& yaml) {
|
||||
}
|
||||
}
|
||||
|
||||
static void loadRenderingConfigFromYaml(const fkyaml::node& yaml) {
|
||||
if (yaml.contains("rendering")) {
|
||||
const auto& rend = yaml["rendering"];
|
||||
|
||||
if (rend.contains("vsync")) {
|
||||
try {
|
||||
int val = rend["vsync"].get_value<int>();
|
||||
// Validar: només 0 o 1
|
||||
rendering.vsync = (val == 0 || val == 1) ? val : Defaults::Rendering::VSYNC_DEFAULT;
|
||||
} catch (...) {
|
||||
rendering.vsync = Defaults::Rendering::VSYNC_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Carregar configuració des del fitxer YAML
|
||||
auto loadFromFile() -> bool {
|
||||
const std::string CONFIG_VERSION = std::string(Project::VERSION);
|
||||
@@ -226,6 +245,7 @@ auto loadFromFile() -> bool {
|
||||
loadWindowConfigFromYaml(yaml);
|
||||
loadPhysicsConfigFromYaml(yaml);
|
||||
loadGameplayConfigFromYaml(yaml);
|
||||
loadRenderingConfigFromYaml(yaml);
|
||||
|
||||
if (console) {
|
||||
std::cout << "Config carregada correctament des de: " << config_file_path
|
||||
@@ -285,7 +305,11 @@ auto saveToFile() -> bool {
|
||||
file << "# GAMEPLAY\n";
|
||||
file << "gameplay:\n";
|
||||
file << " max_enemies: " << gameplay.max_enemies << "\n";
|
||||
file << " max_bullets: " << gameplay.max_bullets << "\n";
|
||||
file << " max_bullets: " << gameplay.max_bullets << "\n\n";
|
||||
|
||||
file << "# RENDERITZACIÓ\n";
|
||||
file << "rendering:\n";
|
||||
file << " vsync: " << rendering.vsync << " # 0=disabled, 1=enabled\n";
|
||||
|
||||
file.close();
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ struct Gameplay {
|
||||
int max_bullets{3};
|
||||
};
|
||||
|
||||
struct Rendering {
|
||||
int vsync{1}; // 0=disabled, 1=enabled
|
||||
};
|
||||
|
||||
// Variables globals (inline per evitar ODR violations)
|
||||
|
||||
inline std::string version{}; // Versió del config per validació
|
||||
@@ -34,6 +38,7 @@ inline bool console{false}; // Eixida de debug
|
||||
inline Window window{};
|
||||
inline Physics physics{};
|
||||
inline Gameplay gameplay{};
|
||||
inline Rendering rendering{};
|
||||
|
||||
inline std::string config_file_path{}; // Establert per setConfigFile()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user