From 73a18998f6791ae21a568996b5d0b884110b87d5 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 8 Aug 2012 17:42:04 +0100 Subject: Scale and fullscreen loaded/saved to config and commandline diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 2b606c9..0e01c66 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -6,6 +6,7 @@ #include "SDL.h" #ifdef WIN #include "SDL_syswm.h" +#include #endif #include #include @@ -16,6 +17,11 @@ #include "icon.h" #endif +#ifndef WIN +#include +#endif + +#include "Format.h" #include "interface/Engine.h" #include "interface/Button.h" #include "interface/Panel.h" @@ -287,15 +293,45 @@ int main(int argc, char * argv[]) std::map arguments = readArguments(argc, argv); + if(arguments["ddir"].length()) +#ifdef WIN + _chdir(arguments["ddir"].c_str()); +#else + chdir(arguments["ddir"].c_str()); +#endif + + int tempScale = 1; + bool tempFullscreen = false; + + tempScale = Client::Ref().GetPrefInteger("Scale", 1); + tempFullscreen = Client::Ref().GetPrefBool("Fullscreen", false); + + + if(arguments["kiosk"] == "true") + { + tempFullscreen = true; + Client::Ref().SetPref("Fullscreen", tempFullscreen); + } + + if(arguments["scale"].length()) + { + tempScale = format::StringToNumber(arguments["scale"]); + Client::Ref().SetPref("Scale", tempScale); + } + + if(tempScale != 1 && tempScale != 2) + tempScale = 1; + int sdlStatus = SDLOpen(); - sdl_scrn = SDLSetScreen(1, false); + sdl_scrn = SDLSetScreen(tempScale, tempFullscreen); #ifdef OGLI SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); //glScaled(2.0f, 2.0f, 1.0f); - #endif ui::Engine::Ref().g = new Graphics(); - //ui::Engine::Ref().g->AttachSDLSurface(SDLOpen()); + ui::Engine::Ref().Scale = scale; + inputScale = 1.0f/float(scale); + ui::Engine::Ref().Fullscreen = fullscreen; ui::Engine * engine = &ui::Engine::Ref(); engine->Begin(XRES+BARSIZE, YRES+MENUSIZE); diff --git a/src/options/OptionsModel.cpp b/src/options/OptionsModel.cpp index 6e71f36..be88d9b 100644 --- a/src/options/OptionsModel.cpp +++ b/src/options/OptionsModel.cpp @@ -102,6 +102,7 @@ bool OptionsModel::GetScale() void OptionsModel::SetScale(bool doubleScale) { ui::Engine::Ref().SetScale(doubleScale?2:1); + Client::Ref().SetPref("Scale", int(doubleScale?2:1)); notifySettingsChanged(); } @@ -113,6 +114,7 @@ bool OptionsModel::GetFullscreen() void OptionsModel::SetFullscreen(bool fullscreen) { ui::Engine::Ref().SetFullscreen(fullscreen); + Client::Ref().SetPref("Fullscreen", bool(fullscreen)); notifySettingsChanged(); } -- cgit v0.9.2-21-gd62e