summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-30 23:15:23 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-30 23:15:23 +0300
commit63ebe55b2d9b14f9f368b2e744d00fd7c1d7ff67 (patch)
tree6a20cb1daa56b31e369c5f5f71ea923acc6f34d8 /src
parent812d838ddba701e8997c59e956523f9cb9acc801 (diff)
downloadmanaverse-63ebe55b2d9b14f9f368b2e744d00fd7c1d7ff67.tar.gz
manaverse-63ebe55b2d9b14f9f368b2e744d00fd7c1d7ff67.tar.bz2
manaverse-63ebe55b2d9b14f9f368b2e744d00fd7c1d7ff67.tar.xz
manaverse-63ebe55b2d9b14f9f368b2e744d00fd7c1d7ff67.zip
Move set video mode code from client to graphics manager.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp37
-rw-r--r--src/graphicsmanager.cpp40
-rw-r--r--src/graphicsmanager.h2
3 files changed, 43 insertions, 36 deletions
diff --git a/src/client.cpp b/src/client.cpp
index d3a11b369..05860592b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -514,44 +514,9 @@ void Client::gameInit()
runCounters = config.getBoolValue("packetcounters");
- const int width = config.getIntValue("screenwidth");
- const int height = config.getIntValue("screenheight");
- const int bpp = 0;
- const bool fullscreen = config.getBoolValue("screen");
- const bool hwaccel = config.getBoolValue("hwaccel");
- const bool enableResize = config.getBoolValue("enableresize");
- const bool noFrame = config.getBoolValue("noframe");
-
applyVSync();
- // Try to set the desired video mode
- if (!mainGraphics->setVideoMode(width, height, bpp,
- fullscreen, hwaccel, enableResize, noFrame))
- {
- 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 int 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 == 1);
- if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp,
- oldFullscreen, hwaccel, enableResize, noFrame))
- {
- logger->safeError(strprintf("Couldn't restore %dx%dx%d "
- "video mode: %s", oldWidth, oldHeight, bpp,
- SDL_GetError()));
- }
- }
- }
+ graphicsManager.setVideoMode();
applyGrabMode();
applyGamma();
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 5beede539..83439b03e 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -142,3 +142,43 @@ void GraphicsManager::logString(const char *format, int num)
logger->log(format, str);
#endif
}
+
+void GraphicsManager::setVideoMode()
+{
+ const int width = config.getIntValue("screenwidth");
+ const int height = config.getIntValue("screenheight");
+ const int bpp = 0;
+ const bool fullscreen = config.getBoolValue("screen");
+ const bool hwaccel = config.getBoolValue("hwaccel");
+ const bool enableResize = config.getBoolValue("enableresize");
+ const bool noFrame = config.getBoolValue("noframe");
+
+ // Try to set the desired video mode
+ if (!mainGraphics->setVideoMode(width, height, bpp,
+ fullscreen, hwaccel, enableResize, noFrame))
+ {
+ 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 int 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 == 1);
+ if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp,
+ oldFullscreen, hwaccel, enableResize, noFrame))
+ {
+ logger->safeError(strprintf("Couldn't restore %dx%dx%d "
+ "video mode: %s", oldWidth, oldHeight, bpp,
+ SDL_GetError()));
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index bd5288ed7..95657a2e8 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -43,6 +43,8 @@ class GraphicsManager
void logString(const char *format, int num);
+ void setVideoMode();
+
private:
std::set<std::string> mExtensions;
};