cambios en el fichero de configuración para hacer más facil la selección de modos de video y filtros

This commit is contained in:
2024-07-06 00:19:28 +02:00
parent abb0151560
commit 78a689760d
3 changed files with 28 additions and 34 deletions

View File

@@ -120,18 +120,15 @@ void Screen::blit()
// Establece el modo de video // Establece el modo de video
void Screen::setVideoMode(int videoMode) void Screen::setVideoMode(int videoMode)
{ {
// Aplica el modo de video
SDL_SetWindowFullscreen(window, videoMode);
// Si está activo el modo ventana quita el borde // Si está activo el modo ventana quita el borde
if (videoMode == 0) if (videoMode == VIDEO_MODE_WINDOW)
{ {
// Aplica el modo de video
SDL_SetWindowFullscreen(window, 0);
// Muestra el puntero // Muestra el puntero
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
// Esconde la ventana
// SDL_HideWindow(window);
if (options->video.border.enabled) if (options->video.border.enabled)
{ {
windowWidth = gameCanvasWidth + borderWidth; windowWidth = gameCanvasWidth + borderWidth;
@@ -152,8 +149,11 @@ void Screen::setVideoMode(int videoMode)
} }
// Si está activo el modo de pantalla completa añade el borde // Si está activo el modo de pantalla completa añade el borde
else if (videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP) else if (videoMode == VIDEO_MODE_FULLSCREEN)
{ {
// Aplica el modo de video
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
// Oculta el puntero // Oculta el puntero
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
@@ -232,7 +232,7 @@ void Screen::setVideoMode(int videoMode)
// Camibia entre pantalla completa y ventana // Camibia entre pantalla completa y ventana
void Screen::switchVideoMode() void Screen::switchVideoMode()
{ {
options->video.mode = (options->video.mode == 0) ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0; options->video.mode = (options->video.mode == VIDEO_MODE_WINDOW) ? VIDEO_MODE_FULLSCREEN : VIDEO_MODE_WINDOW;
setVideoMode(options->video.mode); setVideoMode(options->video.mode);
} }
@@ -240,7 +240,7 @@ void Screen::switchVideoMode()
void Screen::setWindowSize(int size) void Screen::setWindowSize(int size)
{ {
options->video.window.size = size; options->video.window.size = size;
setVideoMode(0); setVideoMode(VIDEO_MODE_WINDOW);
} }
// Reduce el tamaño de la ventana // Reduce el tamaño de la ventana
@@ -248,7 +248,7 @@ void Screen::decWindowSize()
{ {
--options->video.window.size; --options->video.window.size;
options->video.window.size = std::max(options->video.window.size, 1); options->video.window.size = std::max(options->video.window.size, 1);
setVideoMode(0); setVideoMode(VIDEO_MODE_WINDOW);
} }
// Aumenta el tamaño de la ventana // Aumenta el tamaño de la ventana
@@ -256,7 +256,7 @@ void Screen::incWindowSize()
{ {
++options->video.window.size; ++options->video.window.size;
options->video.window.size = std::min(options->video.window.size, 4); options->video.window.size = std::min(options->video.window.size, 4);
setVideoMode(0); setVideoMode(VIDEO_MODE_WINDOW);
} }
// Cambia el color del borde // Cambia el color del borde
@@ -293,7 +293,7 @@ void Screen::setBorderEnabled(bool value)
void Screen::switchBorder() void Screen::switchBorder()
{ {
options->video.border.enabled = !options->video.border.enabled; options->video.border.enabled = !options->video.border.enabled;
setVideoMode(0); setVideoMode(VIDEO_MODE_WINDOW);
} }
// Activa el fade // Activa el fade

View File

@@ -13,6 +13,9 @@
#define FILTER_NEAREST 0 #define FILTER_NEAREST 0
#define FILTER_LINEAL 1 #define FILTER_LINEAL 1
#define VIDEO_MODE_WINDOW 0
#define VIDEO_MODE_FULLSCREEN 1
class Screen class Screen
{ {
private: private:

View File

@@ -615,28 +615,23 @@ bool Director::saveConfigFile()
// Opciones de video // Opciones de video
file << "## VIDEO\n"; file << "## VIDEO\n";
file << "## video.mode [0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP]\n"; file << "## video.mode [0: window, 1: full screen]\n";
file << "## video.filter [FILTER_NEAREST, FILTER_LINEAL]\n"; file << "## video.filter [0: nearest, 1: lineal]\n";
file << "\n"; file << "\n";
if (options->video.mode == 0) if (options->video.mode == VIDEO_MODE_WINDOW)
{ {
file << "video.mode=0\n"; file << "video.mode=0\n";
} }
else if (options->video.mode == SDL_WINDOW_FULLSCREEN) else if (options->video.mode == VIDEO_MODE_FULLSCREEN)
{ {
file << "video.mode=SDL_WINDOW_FULLSCREEN\n"; file << "video.mode=1\n";
}
else if (options->video.mode == SDL_WINDOW_FULLSCREEN_DESKTOP)
{
file << "video.mode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
} }
file << "video.window.size=" + std::to_string(options->video.window.size) + "\n"; file << "video.window.size=" + std::to_string(options->video.window.size) + "\n";
options->video.filter == FILTER_NEAREST ? file << "video.filter=FILTER_NEAREST\n" : file << "video.filter=FILTER_LINEAL\n"; options->video.filter == FILTER_NEAREST ? file << "video.filter=0\n" : file << "video.filter=1\n";
file << "video.shaders=" + boolToString(options->video.shaders) + "\n"; file << "video.shaders=" + boolToString(options->video.shaders) + "\n";
file << "video.vSync=" + boolToString(options->video.vSync) + "\n"; file << "video.vSync=" + boolToString(options->video.vSync) + "\n";
@@ -831,17 +826,13 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
// Opciones de video // Opciones de video
if (var == "video.mode") if (var == "video.mode")
{ {
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP") if (value == "0")
{ {
options->video.mode = SDL_WINDOW_FULLSCREEN_DESKTOP; options->video.mode = VIDEO_MODE_WINDOW;
}
else if (value == "SDL_WINDOW_FULLSCREEN")
{
options->video.mode = SDL_WINDOW_FULLSCREEN;
} }
else else
{ {
options->video.mode = 0; options->video.mode = VIDEO_MODE_FULLSCREEN;
} }
} }
@@ -856,13 +847,13 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
else if (var == "video.filter") else if (var == "video.filter")
{ {
if (value == "FILTER_LINEAL") if (value == "0")
{ {
options->video.filter = FILTER_LINEAL; options->video.filter = FILTER_NEAREST;
} }
else else
{ {
options->video.filter = FILTER_NEAREST; options->video.filter = FILTER_LINEAL;
} }
} }