11e9d6569b
Aquestes tres seccions s'estaven carregant del YAML, parsejant, validant i escrivint, però cap d'elles tenia consumidor en runtime: - Options::physics: l'únic call-site era un std::cout informatiu a director.cpp:109. Ship/Enemy/Bullet llegeixen Defaults::Physics directament. - Options::audio: explícitament desacoblat (audio.hpp:22-25) — la font de configuració era Defaults::Audio via Audio::Config. - Options::gameplay: zero readers. Els arrays són compile-time. Esborrats: - Structs Physics/Gameplay/Music/Sound/Audio i les globals. - Defaults a init(), helpers loadXxxConfigFromYaml, secció escrita a saveToFile, crides al loadFromFile. - La línia "Física: rotation=..." del console output del Director. Es manté Options::window i Options::rendering (sí utilitzats). Hallazgo #21 de CODE_REVIEW.md (opció a: borrar). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h> // Para SDL_Scancode
|
|
|
|
#include <string>
|
|
|
|
namespace Options {
|
|
|
|
// Estructures de configuración
|
|
|
|
struct Window {
|
|
int width{1280};
|
|
int height{720};
|
|
bool fullscreen{false};
|
|
float zoom_factor{1.0F}; // Zoom level (0.5x to max_zoom)
|
|
};
|
|
|
|
struct Rendering {
|
|
int vsync{1}; // 0=disabled, 1=enabled
|
|
};
|
|
|
|
// Controles de jugadors
|
|
|
|
struct KeyboardControls {
|
|
SDL_Scancode key_left{SDL_SCANCODE_LEFT};
|
|
SDL_Scancode key_right{SDL_SCANCODE_RIGHT};
|
|
SDL_Scancode key_thrust{SDL_SCANCODE_UP};
|
|
SDL_Scancode key_shoot{SDL_SCANCODE_SPACE};
|
|
SDL_Scancode key_start{SDL_SCANCODE_1};
|
|
};
|
|
|
|
struct GamepadControls {
|
|
int button_left{SDL_GAMEPAD_BUTTON_DPAD_LEFT};
|
|
int button_right{SDL_GAMEPAD_BUTTON_DPAD_RIGHT};
|
|
int button_thrust{SDL_GAMEPAD_BUTTON_WEST}; // X button
|
|
int button_shoot{SDL_GAMEPAD_BUTTON_SOUTH}; // A button
|
|
};
|
|
|
|
struct PlayerControls {
|
|
KeyboardControls keyboard{};
|
|
GamepadControls gamepad{};
|
|
std::string gamepad_name; // Buit = auto-assignar per índex
|
|
};
|
|
|
|
// Variables globals (inline per evitar ODR violations)
|
|
|
|
inline std::string version{}; // Versión del config per validació
|
|
inline bool console{false}; // Eixida de debug
|
|
inline Window window{};
|
|
inline Rendering rendering{};
|
|
|
|
// Controles per player
|
|
inline PlayerControls player1{
|
|
.keyboard =
|
|
{.key_left = SDL_SCANCODE_LEFT,
|
|
.key_right = SDL_SCANCODE_RIGHT,
|
|
.key_thrust = SDL_SCANCODE_UP,
|
|
.key_shoot = SDL_SCANCODE_SPACE,
|
|
.key_start = SDL_SCANCODE_1},
|
|
.gamepad_name = "" // Primer gamepad disponible
|
|
};
|
|
|
|
inline PlayerControls player2{
|
|
.keyboard =
|
|
{.key_left = SDL_SCANCODE_A,
|
|
.key_right = SDL_SCANCODE_D,
|
|
.key_thrust = SDL_SCANCODE_W,
|
|
.key_shoot = SDL_SCANCODE_LSHIFT,
|
|
.key_start = SDL_SCANCODE_2},
|
|
.gamepad_name = "" // Segon gamepad disponible
|
|
};
|
|
|
|
// Per compatibilitat con pollo (no utilitzat en orni, pero necessari per Input)
|
|
inline KeyboardControls keyboard_controls{};
|
|
inline GamepadControls gamepad_controls{};
|
|
|
|
inline std::string config_file_path{}; // Establert per setConfigFile()
|
|
|
|
// Funciones públiques
|
|
|
|
void init(); // Inicialitzar con valors per defecte
|
|
void setConfigFile(
|
|
const std::string& path); // Establir ruta del file de config
|
|
auto loadFromFile() -> bool; // Carregar config YAML
|
|
auto saveToFile() -> bool; // Guardar config YAML
|
|
|
|
} // namespace Options
|