netejant capçaleres

This commit is contained in:
2025-11-11 12:35:21 +01:00
parent 54fc6d2902
commit d6ced94316
14 changed files with 453 additions and 325 deletions

View File

@@ -2,12 +2,12 @@
#include <SDL3/SDL.h>
#include "core/rendering/screen.hpp" // Para ScreenFilter
#include "core/rendering/screen.hpp" // Para Screen::Filter
#include "utils/utils.hpp" // Para PaletteColor
// Forward declarations from Options namespace
namespace Options {
//enum class ControlScheme;
// enum class ControlScheme;
enum class NotificationPosition;
} // namespace Options
@@ -21,13 +21,13 @@ constexpr int GAME_HEIGHT = 192; // Alto de la ventana por defecto
constexpr int WINDOW_ZOOM = 2; // Zoom de la ventana por defecto
// VIDEO
constexpr bool VIDEO_MODE = false; // Modo de pantalla completa por defecto (false = ventana)
constexpr ScreenFilter VIDEO_FILTER = ScreenFilter::NEAREST; // Filtro por defecto
constexpr bool VIDEO_VERTICAL_SYNC = true; // Vsync activado por defecto
constexpr bool VIDEO_SHADERS = false; // Shaders desactivados por defecto
constexpr bool VIDEO_INTEGER_SCALE = true; // Escalado entero activado por defecto
constexpr bool VIDEO_KEEP_ASPECT = true; // Mantener aspecto activado por defecto
constexpr const char* PALETTE_NAME = "zx-spectrum"; // Paleta por defecto
constexpr bool VIDEO_MODE = false; // Modo de pantalla completa por defecto (false = ventana)
constexpr Screen::Filter VIDEO_FILTER = Screen::Filter::NEAREST; // Filtro por defecto
constexpr bool VIDEO_VERTICAL_SYNC = true; // Vsync activado por defecto
constexpr bool VIDEO_SHADERS = false; // Shaders desactivados por defecto
constexpr bool VIDEO_INTEGER_SCALE = true; // Escalado entero activado por defecto
constexpr bool VIDEO_KEEP_ASPECT = true; // Mantener aspecto activado por defecto
constexpr const char* PALETTE_NAME = "zx-spectrum"; // Paleta por defecto
// BORDER
constexpr bool BORDER_ENABLED = true; // Borde activado por defecto

View File

@@ -212,8 +212,8 @@ auto setOptions(const std::string& var, const std::string& value) -> bool {
{"video.mode", [](const std::string& v) { video.fullscreen = stringToBool(v); }},
{"video.filter", [](const std::string& v) {
int val = safeStoi(v, static_cast<int>(GameDefaults::VIDEO_FILTER));
if (val == static_cast<int>(ScreenFilter::NEAREST) || val == static_cast<int>(ScreenFilter::LINEAR)) {
video.filter = static_cast<ScreenFilter>(val);
if (val == static_cast<int>(Screen::Filter::NEAREST) || val == static_cast<int>(Screen::Filter::LINEAR)) {
video.filter = static_cast<Screen::Filter>(val);
} else {
video.filter = GameDefaults::VIDEO_FILTER;
}

View File

@@ -6,7 +6,7 @@
#include <string> // Para string, basic_string
#include <utility>
#include "core/rendering/screen.hpp" // Para ScreenFilter
#include "core/rendering/screen.hpp" // Para Screen::Filter
#include "utils/defines.hpp" // Para WINDOW_CAPTION
#include "utils/utils.hpp" // Para Color, Palette
@@ -161,7 +161,7 @@ struct Border {
// Estructura para las opciones de video
struct Video {
bool fullscreen{GameDefaults::VIDEO_MODE}; // Contiene el valor del modo de pantalla completa
ScreenFilter filter{GameDefaults::VIDEO_FILTER}; // Filtro usado para el escalado de la imagen
Screen::Filter filter{GameDefaults::VIDEO_FILTER}; // Filtro usado para el escalado de la imagen
bool vertical_sync{GameDefaults::VIDEO_VERTICAL_SYNC}; // Indica si se quiere usar vsync o no
bool shaders{GameDefaults::VIDEO_SHADERS}; // Indica si se van a usar shaders o no
bool integer_scale{GameDefaults::VIDEO_INTEGER_SCALE}; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
@@ -174,7 +174,7 @@ struct Video {
Video() = default;
// Constructor
Video(bool is_fullscreen, ScreenFilter screen_filter, bool vsync, bool use_shaders, bool int_scale, bool keep_aspect_ratio, Border video_border, std::string palette_name)
Video(bool is_fullscreen, Screen::Filter screen_filter, bool vsync, bool use_shaders, bool int_scale, bool keep_aspect_ratio, Border video_border, std::string palette_name)
: fullscreen(is_fullscreen),
filter(screen_filter),
vertical_sync(vsync),
@@ -246,17 +246,17 @@ struct Game {
};
// --- Variables globales (inline C++17+) ---
inline std::string version{}; // Versión del fichero de configuración. Sirve para saber si las opciones son compatibles
inline bool console{false}; // Indica si ha de mostrar información por la consola de texto
inline Cheat cheats{}; // Contiene trucos y ventajas para el juego
inline Game game{}; // Opciones de juego
inline Video video{}; // Opciones de video
inline Stats stats{}; // Datos con las estadisticas de juego
inline Notification notifications{}; // Opciones relativas a las notificaciones;
inline Window window{}; // Opciones relativas a la ventana
inline Audio audio{}; // Opciones relativas al audio
inline ControlScheme controls{}; // Teclas usadas para jugar
inline GamepadControlScheme gamepad_controls{}; // Botones del gamepad usados para jugar
inline std::string version{}; // Versión del fichero de configuración. Sirve para saber si las opciones son compatibles
inline bool console{false}; // Indica si ha de mostrar información por la consola de texto
inline Cheat cheats{}; // Contiene trucos y ventajas para el juego
inline Game game{}; // Opciones de juego
inline Video video{}; // Opciones de video
inline Stats stats{}; // Datos con las estadisticas de juego
inline Notification notifications{}; // Opciones relativas a las notificaciones;
inline Window window{}; // Opciones relativas a la ventana
inline Audio audio{}; // Opciones relativas al audio
inline ControlScheme controls{}; // Teclas usadas para jugar
inline GamepadControlScheme gamepad_controls{}; // Botones del gamepad usados para jugar
// --- Funciones ---
void init(); // Crea e inicializa las opciones del programa