options.h ara gasta defaults.h
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h> // Para SDL_ScaleMode
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
@@ -200,4 +202,35 @@ constexpr const char* PLAYER0 = "66323FFF";
|
|||||||
constexpr const char* PLAYER1 = "422028FF";
|
constexpr const char* PLAYER1 = "422028FF";
|
||||||
} // namespace OutlineColor
|
} // namespace OutlineColor
|
||||||
} // namespace Player
|
} // namespace Player
|
||||||
|
|
||||||
|
// --- OPTIONS ---
|
||||||
|
namespace Options {
|
||||||
|
// Window
|
||||||
|
constexpr const char* WINDOW_CAPTION = "Coffee Crisis Arcade Edition";
|
||||||
|
constexpr int WINDOW_ZOOM = 2;
|
||||||
|
constexpr int WINDOW_MAX_ZOOM = 2;
|
||||||
|
|
||||||
|
// Video
|
||||||
|
constexpr SDL_ScaleMode VIDEO_SCALE_MODE = SDL_ScaleMode::SDL_SCALEMODE_NEAREST;
|
||||||
|
constexpr bool VIDEO_FULLSCREEN = false;
|
||||||
|
constexpr bool VIDEO_VSYNC = true;
|
||||||
|
constexpr bool VIDEO_INTEGER_SCALE = true;
|
||||||
|
constexpr bool VIDEO_SHADERS = false;
|
||||||
|
|
||||||
|
// Music
|
||||||
|
constexpr bool MUSIC_ENABLED = true;
|
||||||
|
constexpr int MUSIC_VOLUME = 100;
|
||||||
|
|
||||||
|
// Sound
|
||||||
|
constexpr bool SOUND_ENABLED = true;
|
||||||
|
constexpr int SOUND_VOLUME = 100;
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
constexpr bool AUDIO_ENABLED = true;
|
||||||
|
constexpr int AUDIO_VOLUME = 100;
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
constexpr bool SETTINGS_AUTOFIRE = true;
|
||||||
|
constexpr bool SETTINGS_SHUTDOWN_ENABLED = false;
|
||||||
|
} // namespace Options
|
||||||
} // namespace GameDefaults
|
} // namespace GameDefaults
|
||||||
@@ -11,9 +11,10 @@
|
|||||||
#include <stdexcept> // Para out_of_range, invalid_argument
|
#include <stdexcept> // Para out_of_range, invalid_argument
|
||||||
#include <string> // Para char_traits, string, allocator, operator==, swap, operator<<, basic_string, stoi
|
#include <string> // Para char_traits, string, allocator, operator==, swap, operator<<, basic_string, stoi
|
||||||
#include <string_view> // Para string_view
|
#include <string_view> // Para string_view
|
||||||
#include <utility>
|
#include <utility> // Para swap
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
|
#include "defaults.h" // Para GameDefaults
|
||||||
#include "difficulty.h" // Para Code
|
#include "difficulty.h" // Para Code
|
||||||
#include "input.h" // Para Input
|
#include "input.h" // Para Input
|
||||||
#include "lang.h" // Para Code
|
#include "lang.h" // Para Code
|
||||||
@@ -25,66 +26,46 @@ namespace Options {
|
|||||||
|
|
||||||
// --- Estructuras ---
|
// --- Estructuras ---
|
||||||
struct Window {
|
struct Window {
|
||||||
std::string caption; // Texto que aparece en la barra de título de la ventana
|
std::string caption = GameDefaults::Options::WINDOW_CAPTION; // Texto que aparece en la barra de título de la ventana
|
||||||
int zoom{2}; // Valor por el que se multiplica el tamaño de la ventana
|
int zoom = GameDefaults::Options::WINDOW_ZOOM; // Valor por el que se multiplica el tamaño de la ventana
|
||||||
int max_zoom{2}; // Tamaño máximo para que la ventana no sea mayor que la pantalla
|
int max_zoom = GameDefaults::Options::WINDOW_MAX_ZOOM; // Tamaño máximo para que la ventana no sea mayor que la pantalla
|
||||||
|
|
||||||
// Constructor por defecto con valores iniciales
|
|
||||||
Window()
|
|
||||||
: caption("Coffee Crisis Arcade Edition") {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Video {
|
struct Video {
|
||||||
SDL_ScaleMode scale_mode{SDL_ScaleMode::SDL_SCALEMODE_NEAREST}; // Filtro usado para el escalado de la imagen
|
SDL_ScaleMode scale_mode = GameDefaults::Options::VIDEO_SCALE_MODE; // Filtro usado para el escalado de la imagen
|
||||||
bool fullscreen{false}; // Indica si se usa pantalla completa
|
bool fullscreen = GameDefaults::Options::VIDEO_FULLSCREEN; // Indica si se usa pantalla completa
|
||||||
bool vsync{true}; // Indica si se usa vsync
|
bool vsync = GameDefaults::Options::VIDEO_VSYNC; // Indica si se usa vsync
|
||||||
bool integer_scale{true}; // Indica si se usa escalado entero
|
bool integer_scale = GameDefaults::Options::VIDEO_INTEGER_SCALE; // Indica si se usa escalado entero
|
||||||
bool shaders{false}; // Indica si se usan shaders para los filtros de vídeo
|
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
|
std::string info; // Información sobre el modo de vídeo
|
||||||
|
|
||||||
// Constructor por defecto con valores iniciales
|
|
||||||
Video() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Music {
|
struct Music {
|
||||||
bool enabled{true}; // Indica si la música suena o no
|
bool enabled = GameDefaults::Options::MUSIC_ENABLED; // Indica si la música suena o no
|
||||||
int volume{100}; // Volumen de la música
|
int volume = GameDefaults::Options::MUSIC_VOLUME; // Volumen de la música
|
||||||
|
|
||||||
// Constructor por defecto
|
|
||||||
Music() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Sound {
|
struct Sound {
|
||||||
bool enabled{true}; // Indica si los sonidos suenan o no
|
bool enabled = GameDefaults::Options::SOUND_ENABLED; // Indica si los sonidos suenan o no
|
||||||
int volume{100}; // Volumen de los sonidos
|
int volume = GameDefaults::Options::SOUND_VOLUME; // Volumen de los sonidos
|
||||||
|
|
||||||
// Constructor por defecto
|
|
||||||
Sound() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Audio {
|
struct Audio {
|
||||||
Music music; // Opciones para la música
|
Music music; // Opciones para la música
|
||||||
Sound sound; // Opciones para los efectos de sonido
|
Sound sound; // Opciones para los efectos de sonido
|
||||||
bool enabled{true}; // Indica si el audio está activo o no
|
bool enabled = GameDefaults::Options::AUDIO_ENABLED; // Indica si el audio está activo o no
|
||||||
int volume{100}; // Volumen general del audio
|
int volume = GameDefaults::Options::AUDIO_VOLUME; // Volumen general del audio
|
||||||
|
|
||||||
// Constructor por defecto
|
|
||||||
Audio() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
Difficulty::Code difficulty{Difficulty::Code::NORMAL}; // Dificultad del juego
|
Difficulty::Code difficulty = Difficulty::Code::NORMAL; // Dificultad del juego
|
||||||
Lang::Code language{Lang::Code::VALENCIAN}; // Idioma usado en el juego
|
Lang::Code language = Lang::Code::VALENCIAN; // Idioma usado en el juego
|
||||||
bool autofire{true}; // Indicador de autofire
|
bool autofire = GameDefaults::Options::SETTINGS_AUTOFIRE; // Indicador de autofire
|
||||||
bool shutdown_enabled{false}; // Especifica si se puede apagar el sistema
|
bool shutdown_enabled = GameDefaults::Options::SETTINGS_SHUTDOWN_ENABLED; // Especifica si se puede apagar el sistema
|
||||||
Table hi_score_table; // Tabla de mejores puntuaciones
|
Table hi_score_table; // Tabla de mejores puntuaciones
|
||||||
std::vector<int> glowing_entries; // Últimas posiciones de entrada en la tabla
|
std::vector<int> glowing_entries = {ManageHiScoreTable::NO_ENTRY, ManageHiScoreTable::NO_ENTRY}; // Últimas posiciones de entrada en la tabla
|
||||||
std::string config_file; // Ruta al fichero donde guardar la configuración y las opciones del juego
|
std::string config_file; // Ruta al fichero donde guardar la configuración y las opciones del juego
|
||||||
std::string controllers_file; // Ruta al fichero con las configuraciones de los mandos
|
std::string controllers_file; // Ruta al fichero con las configuraciones de los mandos
|
||||||
|
|
||||||
// Constructor por defecto con valores iniciales
|
|
||||||
Settings()
|
|
||||||
: glowing_entries({ManageHiScoreTable::NO_ENTRY, ManageHiScoreTable::NO_ENTRY}) {}
|
|
||||||
|
|
||||||
// Reinicia las últimas entradas de puntuación
|
// Reinicia las últimas entradas de puntuación
|
||||||
void clearLastHiScoreEntries() {
|
void clearLastHiScoreEntries() {
|
||||||
@@ -288,12 +269,9 @@ struct Keyboard {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PendingChanges {
|
struct PendingChanges {
|
||||||
Lang::Code new_language{Lang::Code::VALENCIAN}; // Idioma en espera de aplicar
|
Lang::Code new_language = Lang::Code::VALENCIAN; // Idioma en espera de aplicar
|
||||||
Difficulty::Code new_difficulty{Difficulty::Code::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
|
bool has_pending_changes = false; // Indica si hay cambios pendientes
|
||||||
|
|
||||||
// Constructor por defecto con valores iniciales
|
|
||||||
PendingChanges() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables ---
|
// --- Variables ---
|
||||||
|
|||||||
Reference in New Issue
Block a user