clang-format
This commit is contained in:
@@ -23,40 +23,40 @@
|
||||
// --- Namespace Options: gestión de configuración y opciones del juego ---
|
||||
namespace Options {
|
||||
|
||||
// --- Estructuras ---
|
||||
struct Window {
|
||||
// --- Estructuras ---
|
||||
struct Window {
|
||||
std::string caption = GameDefaults::Options::WINDOW_CAPTION; // Texto que aparece en la barra de título de la ventana
|
||||
int zoom = GameDefaults::Options::WINDOW_ZOOM; // Valor por el que se multiplica el tamaño de la ventana
|
||||
int max_zoom = GameDefaults::Options::WINDOW_MAX_ZOOM; // Tamaño máximo para que la ventana no sea mayor que la pantalla
|
||||
};
|
||||
};
|
||||
|
||||
struct Video {
|
||||
struct Video {
|
||||
SDL_ScaleMode scale_mode = GameDefaults::Options::VIDEO_SCALE_MODE; // Filtro usado para el escalado de la imagen
|
||||
bool fullscreen = GameDefaults::Options::VIDEO_FULLSCREEN; // Indica si se usa pantalla completa
|
||||
bool vsync = GameDefaults::Options::VIDEO_VSYNC; // Indica si se usa vsync
|
||||
bool integer_scale = GameDefaults::Options::VIDEO_INTEGER_SCALE; // Indica si se usa escalado entero
|
||||
bool shaders = GameDefaults::Options::VIDEO_SHADERS; // Indica si se usan shaders para los filtros de vídeo
|
||||
std::string info; // Información sobre el modo de vídeo
|
||||
};
|
||||
};
|
||||
|
||||
struct Music {
|
||||
struct Music {
|
||||
bool enabled = GameDefaults::Options::MUSIC_ENABLED; // Indica si la música suena o no
|
||||
int volume = GameDefaults::Options::MUSIC_VOLUME; // Volumen de la música
|
||||
};
|
||||
};
|
||||
|
||||
struct Sound {
|
||||
struct Sound {
|
||||
bool enabled = GameDefaults::Options::SOUND_ENABLED; // Indica si los sonidos suenan o no
|
||||
int volume = GameDefaults::Options::SOUND_VOLUME; // Volumen de los sonidos
|
||||
};
|
||||
};
|
||||
|
||||
struct Audio {
|
||||
struct Audio {
|
||||
Music music; // Opciones para la música
|
||||
Sound sound; // Opciones para los efectos de sonido
|
||||
bool enabled = GameDefaults::Options::AUDIO_ENABLED; // Indica si el audio está activo o no
|
||||
int volume = GameDefaults::Options::AUDIO_VOLUME; // Volumen general del audio
|
||||
};
|
||||
};
|
||||
|
||||
struct Settings {
|
||||
struct Settings {
|
||||
int config_version = 2; // Versión del archivo de configuración
|
||||
Difficulty::Code difficulty = Difficulty::Code::NORMAL; // Dificultad del juego
|
||||
Lang::Code language = Lang::Code::VALENCIAN; // Idioma usado en el juego
|
||||
@@ -73,9 +73,9 @@ struct Settings {
|
||||
glowing_entries.at(0) = ManageHiScoreTable::NO_ENTRY;
|
||||
glowing_entries.at(1) = ManageHiScoreTable::NO_ENTRY;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct Gamepad {
|
||||
struct Gamepad {
|
||||
std::shared_ptr<Input::Gamepad> instance = nullptr; // Referencia al mando
|
||||
std::string name; // Nombre del mando
|
||||
std::string path; // Ruta física del dispositivo
|
||||
@@ -83,11 +83,11 @@ struct Gamepad {
|
||||
|
||||
Gamepad(Player::Id custom_player_id = Player::Id::NO_PLAYER)
|
||||
: player_id(custom_player_id) {}
|
||||
};
|
||||
};
|
||||
|
||||
// --- Clases ---
|
||||
class GamepadManager {
|
||||
public:
|
||||
// --- Clases ---
|
||||
class GamepadManager {
|
||||
public:
|
||||
void init() {
|
||||
gamepads_[0] = Gamepad(Player::Id::PLAYER1);
|
||||
gamepads_[1] = Gamepad(Player::Id::PLAYER2);
|
||||
@@ -222,7 +222,7 @@ class GamepadManager {
|
||||
|
||||
[[nodiscard]] static auto size() -> size_t { return MAX_PLAYERS; }
|
||||
|
||||
private:
|
||||
private:
|
||||
static constexpr std::string_view UNASSIGNED_TEXT = "---";
|
||||
static constexpr size_t MAX_PLAYERS = 2;
|
||||
std::array<Gamepad, MAX_PLAYERS> gamepads_; // Punteros a las estructuras de mandos de Options
|
||||
@@ -251,9 +251,9 @@ class GamepadManager {
|
||||
[[nodiscard]] static auto isGamepadAssigned(
|
||||
const std::shared_ptr<Input::Gamepad>& physical_gamepad,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) -> bool;
|
||||
};
|
||||
};
|
||||
|
||||
struct Keyboard {
|
||||
struct Keyboard {
|
||||
Player::Id player_id = Player::Id::PLAYER1; // Jugador asociado al teclado
|
||||
std::vector<std::shared_ptr<Player>> players; // Punteros a los jugadores
|
||||
|
||||
@@ -267,36 +267,36 @@ struct Keyboard {
|
||||
player->setUsesKeyboard(player->getId() == player_id);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct PendingChanges {
|
||||
struct PendingChanges {
|
||||
Lang::Code new_language = Lang::Code::VALENCIAN; // Idioma en espera de aplicar
|
||||
Difficulty::Code new_difficulty = Difficulty::Code::NORMAL; // Dificultad en espera de aplicar
|
||||
bool has_pending_changes = false; // Indica si hay cambios pendientes
|
||||
};
|
||||
};
|
||||
|
||||
// --- Variables ---
|
||||
extern Window window; // Opciones de la ventana
|
||||
extern Settings settings; // Opciones del juego
|
||||
extern Video video; // Opciones de vídeo
|
||||
extern Audio audio; // Opciones de audio
|
||||
extern GamepadManager gamepad_manager; // Manager de mandos para cada jugador
|
||||
extern Keyboard keyboard; // Opciones para el teclado
|
||||
extern PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
// --- Variables ---
|
||||
extern Window window; // Opciones de la ventana
|
||||
extern Settings settings; // Opciones del juego
|
||||
extern Video video; // Opciones de vídeo
|
||||
extern Audio audio; // Opciones de audio
|
||||
extern GamepadManager gamepad_manager; // Manager de mandos para cada jugador
|
||||
extern Keyboard keyboard; // Opciones para el teclado
|
||||
extern PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
|
||||
// --- Funciones ---
|
||||
void init(); // Inicializa las opciones del programa
|
||||
void setConfigFile(const std::string& file_path); // Establece el fichero de configuración
|
||||
void setControllersFile(const std::string& file_path); // Establece el fichero de configuración de mandos
|
||||
auto loadFromFile() -> bool; // Carga el fichero de configuración
|
||||
auto saveToFile() -> bool; // Guarda el fichero de configuración
|
||||
void setKeyboardToPlayer(Player::Id player_id); // Asigna el teclado al jugador
|
||||
void swapKeyboard(); // Intercambia el teclado de jugador
|
||||
void swapControllers(); // Intercambia los jugadores asignados a los dos primeros mandos
|
||||
auto getPlayerWhoUsesKeyboard() -> Player::Id; // Averigua quién está usando el teclado
|
||||
auto playerIdToString(Player::Id player_id) -> std::string; // Convierte un player id a texto segun Lang
|
||||
auto stringToPlayerId(const std::string& name) -> Player::Id; // Convierte un texto a player id segun Lang
|
||||
void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables
|
||||
void checkPendingChanges(); // Verifica si hay cambios pendientes
|
||||
auto assignGamepadByName(const std::string& gamepad_name, Player::Id player_id) -> bool; // Buscar y asignar un mando disponible por nombre
|
||||
// --- Funciones ---
|
||||
void init(); // Inicializa las opciones del programa
|
||||
void setConfigFile(const std::string& file_path); // Establece el fichero de configuración
|
||||
void setControllersFile(const std::string& file_path); // Establece el fichero de configuración de mandos
|
||||
auto loadFromFile() -> bool; // Carga el fichero de configuración
|
||||
auto saveToFile() -> bool; // Guarda el fichero de configuración
|
||||
void setKeyboardToPlayer(Player::Id player_id); // Asigna el teclado al jugador
|
||||
void swapKeyboard(); // Intercambia el teclado de jugador
|
||||
void swapControllers(); // Intercambia los jugadores asignados a los dos primeros mandos
|
||||
auto getPlayerWhoUsesKeyboard() -> Player::Id; // Averigua quién está usando el teclado
|
||||
auto playerIdToString(Player::Id player_id) -> std::string; // Convierte un player id a texto segun Lang
|
||||
auto stringToPlayerId(const std::string& name) -> Player::Id; // Convierte un texto a player id segun Lang
|
||||
void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables
|
||||
void checkPendingChanges(); // Verifica si hay cambios pendientes
|
||||
auto assignGamepadByName(const std::string& gamepad_name, Player::Id player_id) -> bool; // Buscar y asignar un mando disponible por nombre
|
||||
} // namespace Options
|
||||
Reference in New Issue
Block a user