1ef9ca551f
Permet alternar l'AA geomètric en runtime:
- Action::TOGGLE_ANTIALIAS bound a F5.
- GlobalEvents::handle reacciona al scancode F5 cridant sdl.toggleAntialias().
- SDLManager::toggleAntialias muta cfg_->rendering.antialias i propaga a
gpu_renderer_.setAntialias().
- GpuFrameRenderer manté l'estat antialias_enabled_ (true per defecte) i
pushLine adapta extrusió i edge_dist en funció del flag — geometria nua
quan està OFF, fade als bords quan està ON.
- RenderingConfig guanya el camp `antialias{1}` per coherència amb vsync;
l'estat NO es persisteix al YAML de moment (decisió volgudament conservadora,
podem afegir-ho en un commit a part si cal).
- DebugOverlay (F11) mostra una tercera línia "AA: ON/OFF" sota VSYNC per
poder comparar a temps real.
74 lines
2.6 KiB
C++
74 lines
2.6 KiB
C++
// engine_config.hpp - Configuració runtime del motor (window, render, input)
|
|
// © 2026 JailDesigner
|
|
//
|
|
// Struct POD que conté la configuració runtime que els sistemes de `core/`
|
|
// llegeixen i muten. La capa de persistència (YAML) viu a `game/config_yaml.cpp`,
|
|
// que omple aquesta struct a init() i loadFromFile().
|
|
//
|
|
// Es passa per referència (mutable quan cal) al constructor dels sistemes
|
|
// que la necessiten, mantenint `core/` agnòstic a `game/`.
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
namespace Config {
|
|
|
|
struct WindowConfig {
|
|
int width{1280};
|
|
int height{720};
|
|
bool fullscreen{false};
|
|
float zoom_factor{1.0F}; // Zoom level (0.5x to max_zoom)
|
|
};
|
|
|
|
struct RenderingConfig {
|
|
int vsync{1}; // 0=disabled, 1=enabled
|
|
int antialias{1}; // 0=disabled, 1=enabled (AA geomètric a les línies, toggle F5)
|
|
};
|
|
|
|
struct KeyboardBindings {
|
|
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 GamepadBindings {
|
|
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 PlayerBindings {
|
|
KeyboardBindings keyboard{};
|
|
GamepadBindings gamepad{};
|
|
std::string gamepad_name; // Empty = auto-assign by index
|
|
};
|
|
|
|
struct EngineConfig {
|
|
WindowConfig window{};
|
|
RenderingConfig rendering{};
|
|
PlayerBindings player1{};
|
|
PlayerBindings player2{};
|
|
KeyboardBindings keyboard_controls{}; // Defaults globals per Input
|
|
GamepadBindings gamepad_controls{};
|
|
bool console{false};
|
|
};
|
|
|
|
// Capa de persistència delegada cap a l'EngineConfig. Permet al Director
|
|
// orquestrar init/load/save sense conèixer cap esquema concret (YAML,
|
|
// SQLite, ...) ni la capa que el conté (`game/config_yaml.cpp`).
|
|
struct ConfigPersistence {
|
|
std::function<void()> init_defaults; // Restaura valors per defecte
|
|
std::function<void(const std::string& path)> set_path; // Indica on guardar
|
|
std::function<bool()> load; // Llegeix path → EngineConfig
|
|
std::function<bool()> save; // Escriu EngineConfig → path
|
|
};
|
|
|
|
} // namespace Config
|