From ca99857b5bfe67263a3449f8b9066ee57400411a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sun, 12 Feb 2023 18:19:13 +0100 Subject: [PATCH] =?UTF-8?q?Cuando=20se=20cambia=20el=20tama=C3=B1o=20de=20?= =?UTF-8?q?la=20ventana,=20aparece=20centrada=20en=20el=20escritorio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/common/screen.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index 97d8c6d..3ba91b1 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -86,15 +86,15 @@ void Screen::blit() // Establece el modo de video void Screen::setVideoMode(int videoMode) { - // Muestra el puntero - SDL_ShowCursor(SDL_ENABLE); - // Aplica el modo de video SDL_SetWindowFullscreen(window, videoMode); // Si está activo el modo ventana quita el borde if (videoMode == 0) { + // Muestra el puntero + SDL_ShowCursor(SDL_ENABLE); + if (options->borderEnabled) { windowWidth = gameCanvasWidth + borderWidth; @@ -109,9 +109,9 @@ void Screen::setVideoMode(int videoMode) dest = {0, 0, gameCanvasWidth, gameCanvasHeight}; } - // Modifica el tamaño del renderizador y de la ventana - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); + // Modifica el tamaño de la ventana SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize); + SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } // Si está activo el modo de pantalla completa añade el borde @@ -162,11 +162,11 @@ void Screen::setVideoMode(int videoMode) dest.h = windowHeight; dest.x = dest.y = 0; } - - // Modifica el tamaño del renderizador - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); } + // Modifica el tamaño del renderizador + SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); + // Actualiza las opciones options->videoMode = videoMode; options->screen.windowWidth = windowWidth;