summaryrefslogtreecommitdiff
path: root/src/gui/setup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/setup.cpp')
-rw-r--r--src/gui/setup.cpp45
1 files changed, 13 insertions, 32 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index cda9ae31..91f64ecc 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -214,39 +214,20 @@ void Setup::action(const std::string &eventId)
else if (eventId == "apply")
{
setVisible(false);
- bool changed = false;
-
- if (fsCheckBox->isMarked() && config.getValue("screen", 0) == 0) {
- // Fullscreen
- config.setValue("screen", 1);
- displayFlags |= SDL_FULLSCREEN;
- changed = true;
- }
- else if(!fsCheckBox->isMarked() && config.getValue("screen", 0) == 1) {
- // Windowed
- config.setValue("screen", 0);
- displayFlags &= ~SDL_FULLSCREEN;
- changed = true;
- }
-
- if(changed) {
- displayFlags |= SDL_DOUBLEBUF;
- if (useOpenGL) {
- //displayFlags |= SDL_OPENGL;
- //SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ bool fullscreen = fsCheckBox->isMarked();
+
+ if (fullscreen != (config.getValue("screen", 0) == 1)) {
+ if (!guiGraphics->setFullscreen(fullscreen)) {
+ fullscreen = !fullscreen;
+ if (!guiGraphics->setFullscreen(fullscreen)) {
+ std::cerr << "Failed to switch to " <<
+ (fullscreen ? "windowed" : "fullscreen") <<
+ "mode and restoration of old mode also failed!" <<
+ std::endl;
+ exit(1);
+ }
}
-
- SDL_Surface *screen =
- SDL_SetVideoMode(screenW, screenH, bitDepth, displayFlags);
-
- if (screen == NULL) {
- std::cerr << "Couldn't set " << screenW << "x" <<
- screenH << "x" << bitDepth << " video mode: " <<
- SDL_GetError() << std::endl;
- exit(1);
- }
-
- guiGraphics->setScreen(screen);
+ config.setValue("screen", fullscreen ? 1 : 0);
}
// Sound settings