3e8f2f35bf
Afegeix l'accio MENU a InputAction (obre el menu de servei des del mando, equivalent a F12 al teclat) i els camps gamepad.button_start i gamepad.button_menu al config per jugador. Tambe afegeix gamepad_path per distingir dos mandos del mateix model i prioritza path > name > slot a applyPlayerNBindings via el nou resolvePlayerGamepad. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84 lines
3.0 KiB
C++
84 lines
3.0 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 <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)
|
||
// Resolució del render target offscreen (independent del tamany lògic
|
||
// 1280×720 del joc). Aquesta és la resolució real on rasteritzen les
|
||
// línies abans de l'escala final a la swapchain; pujar-la millora
|
||
// la nitidesa en finestres grans i fullscreen. Llista tancada de
|
||
// presets 16:9 — veure Defaults::Rendering::RESOLUTION_PRESETS.
|
||
int render_width{1280};
|
||
int render_height{720};
|
||
};
|
||
|
||
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
|
||
int button_start{SDL_GAMEPAD_BUTTON_START}; // Start button
|
||
int button_menu{SDL_GAMEPAD_BUTTON_BACK}; // Select/Back -> obre menu servei
|
||
};
|
||
|
||
struct PlayerBindings {
|
||
KeyboardBindings keyboard{};
|
||
GamepadBindings gamepad{};
|
||
std::string gamepad_name; // Empty = auto-assign by index
|
||
std::string gamepad_path; // Prioritari sobre name per distingir mateixos models
|
||
};
|
||
|
||
struct AudioConfig {
|
||
bool enabled{true};
|
||
float volume{1.0F}; // Master 0..1
|
||
bool music_enabled{true};
|
||
float music_volume{1.0F};
|
||
bool sound_enabled{true};
|
||
float sound_volume{0.25F};
|
||
};
|
||
|
||
struct EngineConfig {
|
||
WindowConfig window{};
|
||
RenderingConfig rendering{};
|
||
AudioConfig audio{};
|
||
PlayerBindings player1{};
|
||
PlayerBindings player2{};
|
||
KeyboardBindings keyboard_controls{}; // Defaults globals per Input
|
||
GamepadBindings gamepad_controls{};
|
||
bool console{false};
|
||
std::string locale{"ca"}; // "ca" | "en" — fixat a l'arrencada, sense hot-swap
|
||
};
|
||
|
||
} // namespace Config
|