From 7853eb16365a02969d08730c2688dfbb7811ef82 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Jun 2011 23:53:08 +0300 Subject: If client cant set video mode, it fall back to last mode. --- src/client.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index ac6970503..25389f92a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -456,8 +456,29 @@ Client::Client(const Options &options): // Try to set the desired video mode if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { - logger->error(strprintf("Couldn't set %dx%dx%d video mode: %s", + logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); + + const int oldWidth = config.getValueInt("oldscreenwidth", -1); + const int oldHeight = config.getValueInt("oldscreenheight", -1); + const bool oldFullscreen = config.getValueInt("oldscreen", -1); + if (oldWidth != -1 && oldHeight != -1 && oldFullscreen != -1) + { + config.deleteKey("oldscreenwidth"); + config.deleteKey("oldscreenheight"); + config.deleteKey("oldscreen"); + + config.setValueInt("screenwidth", oldWidth); + config.setValueInt("screenheight", oldHeight); + config.setValue("screen", oldFullscreen); + if (!graphics->setVideoMode(oldWidth, oldHeight, bpp, + oldFullscreen, hwaccel)) + { + logger->error(strprintf("Couldn't restore %dx%dx%d " + "video mode: %s", oldWidth, oldHeight, bpp, + SDL_GetError())); + } + } } // Initialize for drawing -- cgit v1.2.3-60-g2f50