From 78a689760d7d7706d971ad06311a4fd938bfdbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sat, 6 Jul 2024 00:19:28 +0200 Subject: [PATCH] =?UTF-8?q?cambios=20en=20el=20fichero=20de=20configuraci?= =?UTF-8?q?=C3=B3n=20para=20hacer=20m=C3=A1s=20facil=20la=20selecci=C3=B3n?= =?UTF-8?q?=20de=20modos=20de=20video=20y=20filtros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/common/screen.cpp | 26 +++++++++++++------------- source/common/screen.h | 3 +++ source/director.cpp | 33 ++++++++++++--------------------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index 88ae486..367d2bf 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -120,18 +120,15 @@ void Screen::blit() // Establece el modo de video void Screen::setVideoMode(int videoMode) { - // Aplica el modo de video - SDL_SetWindowFullscreen(window, videoMode); - // 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 SDL_ShowCursor(SDL_ENABLE); - // Esconde la ventana - // SDL_HideWindow(window); - if (options->video.border.enabled) { windowWidth = gameCanvasWidth + borderWidth; @@ -152,8 +149,11 @@ void Screen::setVideoMode(int videoMode) } // 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 SDL_ShowCursor(SDL_DISABLE); @@ -232,7 +232,7 @@ void Screen::setVideoMode(int videoMode) // Camibia entre pantalla completa y ventana 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); } @@ -240,7 +240,7 @@ void Screen::switchVideoMode() void Screen::setWindowSize(int size) { options->video.window.size = size; - setVideoMode(0); + setVideoMode(VIDEO_MODE_WINDOW); } // Reduce el tamaño de la ventana @@ -248,7 +248,7 @@ void Screen::decWindowSize() { --options->video.window.size; options->video.window.size = std::max(options->video.window.size, 1); - setVideoMode(0); + setVideoMode(VIDEO_MODE_WINDOW); } // Aumenta el tamaño de la ventana @@ -256,7 +256,7 @@ void Screen::incWindowSize() { ++options->video.window.size; options->video.window.size = std::min(options->video.window.size, 4); - setVideoMode(0); + setVideoMode(VIDEO_MODE_WINDOW); } // Cambia el color del borde @@ -293,7 +293,7 @@ void Screen::setBorderEnabled(bool value) void Screen::switchBorder() { options->video.border.enabled = !options->video.border.enabled; - setVideoMode(0); + setVideoMode(VIDEO_MODE_WINDOW); } // Activa el fade diff --git a/source/common/screen.h b/source/common/screen.h index 74f385c..2ed2186 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -13,6 +13,9 @@ #define FILTER_NEAREST 0 #define FILTER_LINEAL 1 +#define VIDEO_MODE_WINDOW 0 +#define VIDEO_MODE_FULLSCREEN 1 + class Screen { private: diff --git a/source/director.cpp b/source/director.cpp index 8cdd480..3df50a3 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -615,28 +615,23 @@ bool Director::saveConfigFile() // Opciones de video file << "## VIDEO\n"; - file << "## video.mode [0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP]\n"; - file << "## video.filter [FILTER_NEAREST, FILTER_LINEAL]\n"; + file << "## video.mode [0: window, 1: full screen]\n"; + file << "## video.filter [0: nearest, 1: lineal]\n"; file << "\n"; - if (options->video.mode == 0) + if (options->video.mode == VIDEO_MODE_WINDOW) { 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"; - } - - else if (options->video.mode == SDL_WINDOW_FULLSCREEN_DESKTOP) - { - file << "video.mode=SDL_WINDOW_FULLSCREEN_DESKTOP\n"; + file << "video.mode=1\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.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 if (var == "video.mode") { - if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP") + if (value == "0") { - options->video.mode = SDL_WINDOW_FULLSCREEN_DESKTOP; - } - else if (value == "SDL_WINDOW_FULLSCREEN") - { - options->video.mode = SDL_WINDOW_FULLSCREEN; + options->video.mode = VIDEO_MODE_WINDOW; } 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") { - if (value == "FILTER_LINEAL") + if (value == "0") { - options->video.filter = FILTER_LINEAL; + options->video.filter = FILTER_NEAREST; } else { - options->video.filter = FILTER_NEAREST; + options->video.filter = FILTER_LINEAL; } }