diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-21 23:53:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-21 23:53:08 +0300 |
commit | 7853eb16365a02969d08730c2688dfbb7811ef82 (patch) | |
tree | cfc58740afca1b3a4070bf7e4c1e068cb4fcc68f | |
parent | 109a9a97e598f10e673fc235000bcec415fe047d (diff) | |
download | mv-7853eb16365a02969d08730c2688dfbb7811ef82.tar.gz mv-7853eb16365a02969d08730c2688dfbb7811ef82.tar.bz2 mv-7853eb16365a02969d08730c2688dfbb7811ef82.tar.xz mv-7853eb16365a02969d08730c2688dfbb7811ef82.zip |
If client cant set video mode, it fall back to last mode.
-rw-r--r-- | src/client.cpp | 23 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 3 |
2 files changed, 25 insertions, 1 deletions
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 diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index d007bc275..db2dabcd1 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -775,6 +775,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) _("Restart your client for the change to take effect.")); } + config.setValue("oldscreen", config.getBoolValue("screen")); + config.setValue("oldscreenwidth", graphics->getWidth()); + config.setValue("oldscreenheight", graphics->getHeight()); config.setValue("screenwidth", width); config.setValue("screenheight", height); } |