migrant a SDL3

This commit is contained in:
2025-03-27 08:14:37 +01:00
parent a9c869baf6
commit d2286905dc
83 changed files with 570 additions and 541 deletions

View File

@@ -1,14 +1,14 @@
#include "options.h"
#include <SDL3/SDL_gamecontroller.h> // Para SDL_GameControllerButton
#include <algorithm> // Para clamp
#include <fstream> // Para basic_ostream, operator<<, basi...
#include <iostream> // Para cout
#include <utility> // Para swap
#include <vector> // Para vector
#include "input.h" // Para InputDeviceToUse
#include "lang.h" // Para Code
#include "screen.h" // Para ScreenVideoMode, ScreenFilter
#include "utils.h" // Para boolToString, stringToBool, get...
#include <SDL3/SDL.h> // Para SDL_GamepadButton
#include <algorithm> // Para clamp
#include <fstream> // Para basic_ostream, operator<<, basi...
#include <iostream> // Para cout
#include <utility> // Para swap
#include <vector> // Para vector
#include "input.h" // Para InputDeviceToUse
#include "lang.h" // Para Code
#include "screen.h" // Para ScreenFilter
#include "utils.h" // Para boolToString, stringToBool, get...
// Variables
Options options;
@@ -21,10 +21,10 @@ void initOptions()
{
// Opciones de video
#ifdef ANBERNIC
options.video.mode = ScreenVideoMode::WINDOW;
options.video.mode = false;
options.video.window.size = 3;
#else
options.video.mode = ScreenVideoMode::WINDOW;
options.video.fullscreen = false;
options.video.window.zoom = 2;
#endif
options.video.filter = ScreenFilter::NEAREST;
@@ -98,13 +98,6 @@ bool loadOptionsFile(std::string file_path)
}
// Normaliza los valores
const bool a = options.video.mode == ScreenVideoMode::WINDOW;
const bool b = options.video.mode == ScreenVideoMode::FULLSCREEN;
if (!(a || b))
{
options.video.mode = ScreenVideoMode::WINDOW;
}
options.video.window.zoom = std::clamp(options.video.window.zoom, 1, 4);
if (options.game.language != lang::Code::en_UK &&
@@ -132,11 +125,10 @@ bool saveOptionsFile(std::string file_path)
// Opciones de video
file << "## VIDEO\n";
file << "## video.mode [" << static_cast<int>(ScreenVideoMode::WINDOW) << ": window, " << static_cast<int>(ScreenVideoMode::FULLSCREEN) << ": fullscreen]\n";
file << "## video.filter [" << static_cast<int>(ScreenFilter::NEAREST) << ": nearest, " << static_cast<int>(ScreenFilter::LINEAL) << ": lineal]\n";
file << "\n";
file << "video.mode=" << static_cast<int>(options.video.mode) << "\n";
file << "video.fullscreen=" << boolToString(options.video.fullscreen) << "\n";
file << "video.window.size=" << options.video.window.zoom << "\n";
file << "video.filter=" << static_cast<int>(options.video.filter) << "\n";
file << "video.v_sync=" << boolToString(options.video.v_sync) << "\n";
@@ -200,7 +192,7 @@ bool setOptions(const std::string &var, const std::string &value)
// Opciones de video
if (var == "video.mode")
{
options.video.mode = static_cast<ScreenVideoMode>(std::stoi(value));
options.video.fullscreen = stringToBool(value);
}
else if (var == "video.window.size")
{
@@ -282,23 +274,23 @@ bool setOptions(const std::string &var, const std::string &value)
}
else if (var == "controller.0.button.fire_left")
{
options.controllers.at(0).buttons.at(0) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(0).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.fire_center")
{
options.controllers.at(0).buttons.at(1) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(0).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.fire_right")
{
options.controllers.at(0).buttons.at(2) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(0).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.start")
{
options.controllers.at(0).buttons.at(3) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(0).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.0.button.service")
{
options.controllers.at(0).buttons.at(4) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(0).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.name")
{
@@ -314,23 +306,23 @@ bool setOptions(const std::string &var, const std::string &value)
}
else if (var == "controller.1.button.fire_left")
{
options.controllers.at(1).buttons.at(0) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(1).buttons.at(0) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.fire_center")
{
options.controllers.at(1).buttons.at(1) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(1).buttons.at(1) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.fire_right")
{
options.controllers.at(1).buttons.at(2) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(1).buttons.at(2) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.start")
{
options.controllers.at(1).buttons.at(3) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(1).buttons.at(3) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
else if (var == "controller.1.button.service")
{
options.controllers.at(1).buttons.at(4) = static_cast<SDL_GameControllerButton>(std::stoi(value));
options.controllers.at(1).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
}
// Lineas vacias o que empiezan por comentario