options: canviat size per zoom i v_sync per vsync
options: moguda la opció de window a la seua seccio
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
#include "options.h"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_ScaleMode, SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
|
||||
#include <algorithm> // Para clamp, max
|
||||
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream
|
||||
#include <utility> // Para swap
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "input.h" // Para InputDevice
|
||||
#include "lang.h" // Para Code
|
||||
#include "utils.h" // Para boolToString, stringToBool, getFileName
|
||||
#include <algorithm> // Para clamp, max
|
||||
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream
|
||||
#include <utility> // Para swap
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "input.h" // Para InputDevice
|
||||
#include "lang.h" // Para Code
|
||||
#include "utils.h" // Para boolToString, stringToBool, getFileName
|
||||
|
||||
namespace Options {
|
||||
// --- Variables globales ---
|
||||
@@ -105,15 +106,20 @@ auto saveToFile() -> bool {
|
||||
|
||||
applyPendingChanges();
|
||||
|
||||
// Opciones de ventana
|
||||
file << "## WINDOW\n";
|
||||
file << "\n";
|
||||
|
||||
file << "window.zoom=" << window.zoom << "\n";
|
||||
|
||||
// Opciones de video
|
||||
file << "## VIDEO\n";
|
||||
file << "## video.scale_mode [" << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_NEAREST) << ": nearest, " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_LINEAR) << ": lineal]\n";
|
||||
file << "\n";
|
||||
|
||||
file << "window.zoom=" << window.size << "\n";
|
||||
file << "video.fullscreen=" << boolToString(video.fullscreen) << "\n";
|
||||
file << "video.scale_mode=" << static_cast<int>(video.scale_mode) << "\n";
|
||||
file << "video.v_sync=" << boolToString(video.v_sync) << "\n";
|
||||
file << "video.vsync=" << boolToString(video.vsync) << "\n";
|
||||
file << "video.integer_scale=" << boolToString(video.integer_scale) << "\n";
|
||||
file << "video.shaders=" << boolToString(video.shaders) << "\n";
|
||||
|
||||
@@ -168,21 +174,27 @@ auto saveToFile() -> bool {
|
||||
// Asigna variables a partir de dos cadenas
|
||||
auto set(const std::string &var, const std::string &value) -> bool {
|
||||
// Indicador de éxito en la asignación
|
||||
auto success = true;
|
||||
// Lineas vacias o que empiezan por comentario
|
||||
if (var.empty() || var.starts_with("#")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Opciones de ventana
|
||||
if (var == "window.zoom") {
|
||||
window.zoom = std::stoi(value);
|
||||
}
|
||||
|
||||
// Opciones de video
|
||||
if (var == "video.fullscreen") {
|
||||
video.fullscreen = stringToBool(value);
|
||||
} else if (var == "window.zoom") {
|
||||
window.size = std::stoi(value);
|
||||
} else if (var == "video.scale_mode") {
|
||||
video.scale_mode = static_cast<SDL_ScaleMode>(std::stoi(value));
|
||||
} else if (var == "video.shaders") {
|
||||
video.shaders = stringToBool(value);
|
||||
} else if (var == "video.integer_scale") {
|
||||
video.integer_scale = stringToBool(value);
|
||||
} else if (var == "video.v_sync") {
|
||||
video.v_sync = stringToBool(value);
|
||||
} else if (var == "video.vsync") {
|
||||
video.vsync = stringToBool(value);
|
||||
}
|
||||
|
||||
// Opciones de audio
|
||||
@@ -248,13 +260,7 @@ auto set(const std::string &var, const std::string &value) -> bool {
|
||||
controllers.at(1).buttons.at(4) = static_cast<SDL_GamepadButton>(std::stoi(value));
|
||||
}
|
||||
|
||||
// Lineas vacias o que empiezan por comentario
|
||||
else if (var.empty() || var.starts_with("#")) {
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Asigna el teclado al jugador
|
||||
|
||||
Reference in New Issue
Block a user