difficulty: mogut desde options a un fitxer propi
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <utility> // Para move
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "difficulty.h" //Para Difficulty
|
||||
#include "input.h" // Para InputAction, InputDevice
|
||||
#include "lang.h" // Para Code
|
||||
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||
@@ -14,22 +15,6 @@
|
||||
static constexpr int INVALID_INDEX = -1;
|
||||
|
||||
namespace Options {
|
||||
// --- Dificultad del juego ---
|
||||
enum class DifficultyCode {
|
||||
EASY = 0,
|
||||
NORMAL = 1,
|
||||
HARD = 2,
|
||||
};
|
||||
|
||||
// --- Estructura que representa un nivel de dificultad
|
||||
struct Difficulty {
|
||||
DifficultyCode code; // Código que identifica la dificultad
|
||||
std::string name; // Nombre que identifica la dificultad
|
||||
|
||||
Difficulty(DifficultyCode c, std::string n)
|
||||
: code(c), name(std::move(n)) {}
|
||||
};
|
||||
|
||||
// --- Opciones de ventana ---
|
||||
struct WindowOptions {
|
||||
std::string caption; // Texto que aparece en la barra de título de la ventana
|
||||
@@ -85,7 +70,7 @@ struct AudioOptions {
|
||||
|
||||
// --- Opciones de configuración ---
|
||||
struct SettingsOptions {
|
||||
DifficultyCode difficulty{DifficultyCode::NORMAL}; // Dificultad del juego
|
||||
Difficulty::Code difficulty{Difficulty::Code::NORMAL}; // Dificultad del juego
|
||||
Lang::Code language{Lang::Code::VALENCIAN}; // Idioma usado en el juego
|
||||
bool autofire{true}; // Indicador de autofire
|
||||
bool shutdown_enabled{false}; // Especifica si se puede apagar el sistema
|
||||
@@ -135,7 +120,7 @@ struct GamepadOptions {
|
||||
// --- Opciones pendientes de aplicar ---
|
||||
struct PendingChanges {
|
||||
Lang::Code new_language{Lang::Code::VALENCIAN}; // Idioma en espera de aplicar
|
||||
DifficultyCode new_difficulty{DifficultyCode::NORMAL}; // Dificultad 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
|
||||
|
||||
// Constructor por defecto con valores iniciales
|
||||
@@ -149,18 +134,16 @@ extern VideoOptions video; // Opciones de vídeo
|
||||
extern AudioOptions audio; // Opciones de audio
|
||||
extern std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
|
||||
extern PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
extern std::vector<Difficulty> difficulties; // Lista de los diferentes tipos de dificultad
|
||||
|
||||
// --- Funciones de configuración ---
|
||||
void init(); // Inicializa las opciones del programa
|
||||
auto loadFromFile() -> bool; // Carga el fichero de configuración
|
||||
auto saveToFile() -> bool; // Guarda el fichero de configuración
|
||||
void setKeyboardToPlayer(int 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() -> int; // Averigua quién está usando el teclado
|
||||
void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables
|
||||
void checkPendingChanges(); // Verifica si hay cambios pendientes
|
||||
auto getDifficultyCodeFromName(const std::string &name) -> DifficultyCode; // Obtiene el código de dificultad a partir del nombre
|
||||
auto getDifficultyNameFromCode(DifficultyCode code) -> std::string; // Obtiene el nombre de la dificultad a partir del código
|
||||
void init(); // Inicializa las opciones del programa
|
||||
void setFile(const std::string &file_path); // Establece el fichero de configuración
|
||||
auto loadFromFile() -> bool; // Carga el fichero de configuración
|
||||
auto saveToFile() -> bool; // Guarda el fichero de configuración
|
||||
void setKeyboardToPlayer(int 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() -> int; // Averigua quién está usando el teclado
|
||||
void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables
|
||||
void checkPendingChanges(); // Verifica si hay cambios pendientes
|
||||
} // namespace Options
|
||||
Reference in New Issue
Block a user