summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-28 14:30:10 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-02-09 23:45:11 +0100
commit8aeb42b16430c85e4bc4052d881b8335d4a2ff36 (patch)
treeb2c3deb9a722bcff49192578995ae7182a711cda /src/client.cpp
parent011f69af465085bd8555737a3297f0e070040128 (diff)
downloadmana-8aeb42b16430c85e4bc4052d881b8335d4a2ff36.tar.gz
mana-8aeb42b16430c85e4bc4052d881b8335d4a2ff36.tar.bz2
mana-8aeb42b16430c85e4bc4052d881b8335d4a2ff36.tar.xz
mana-8aeb42b16430c85e4bc4052d881b8335d4a2ff36.zip
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
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp37
1 files changed, 22 insertions, 15 deletions
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);
+}