From 8aeb42b16430c85e4bc4052d881b8335d4a2ff36 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sat, 28 Jan 2012 14:30:10 +0100 Subject: Allow changing fullscreen resolution without restart Unified Graphics:setFullscreen and Graphics:resize into a single Graphics:changeVideoMode function that tries to restore the existing mode when changing to the new mode didn't work, and exists with an error when that also fails. Split up handling of SDL_VIDEORESIZE and the adapting to new resolution in the Client class, so that the second part could also be called when changing resolution fullscreen mode. The Video tab in the Setup window now also filters out any modes smaller than 640x480 since the game won't properly adapt to that resolution anyway. Reviewed-by: Yohann Ferreira --- src/client.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 2dcb3ba3..5a9cc726 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -515,7 +515,7 @@ int Client::exec() break; case SDL_VIDEORESIZE: - resizeVideo(event.resize.w, event.resize.h); + handleVideoResize(event.resize.w, event.resize.h); break; } @@ -1391,7 +1391,7 @@ void Client::accountLogin(LoginData *loginData) config.setValue("remember", loginData->remember); } -void Client::resizeVideo(int width, int height) +void Client::handleVideoResize(int width, int height) { // Keep a minimum size. This isn't adhered to by the actual window, but // it keeps some window positions from getting messed up. @@ -1401,20 +1401,13 @@ void Client::resizeVideo(int width, int height) if (graphics->getWidth() == width && graphics->getHeight() == height) return; - if (graphics->resize(width, height)) + if (graphics->changeVideoMode(width, + height, + graphics->getBpp(), + false, + graphics->getHWAccel())) { - gui->videoResized(); - - if (mDesktop) - mDesktop->setSize(width, height); - - if (mSetupButton) - mSetupButton->setPosition(width - mSetupButton->getWidth() - 3, 3); - - if (mGame) - mGame->videoResized(width, height); - - gui->draw(); + videoResized(width, height); // Since everything appears to have worked out, remember to store the // new size in the configuration. @@ -1422,3 +1415,17 @@ void Client::resizeVideo(int width, int height) config.setValue("screenheight", height); } } + +void Client::videoResized(int width, int height) +{ + gui->videoResized(); + + if (mDesktop) + mDesktop->setSize(width, height); + + if (mSetupButton) + mSetupButton->setPosition(width - mSetupButton->getWidth() - 3, 3); + + if (mGame) + mGame->videoResized(width, height); +} -- cgit v1.2.3-70-g09d2