From: Neal Gompa (ニール・ゴンパ) Date: Sun, 20 Nov 2016 11:23:01 +0000 (+0000) Subject: Merge branch 'opt-fullscreen' into 'master' X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=87d53cb937619e05c0516a6f2f57f7da0d415c27;hp=f2af094c2b32baf5b605214f5451df5cc8f611a1;p=lugaru.git Merge branch 'opt-fullscreen' into 'master' Option to toggle fullscreen Adds a command line switch, saved config option and option menu entry to toggle fullscreen. It also defaults to windowed mode. Also toggling fullscreen on does not play well with the mouse pointer (it disappears), but the same happens with Alt+Return, so it's not a regression. Part of #15. See merge request !4 --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index bcbce6e..1a743f3 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -148,12 +148,13 @@ extern bool winfreeze; extern bool campaign; +extern void toggleFullscreen(); + void Loadlevel(int which); void Loadlevel(const char *name); - class CampaignLevel { private: @@ -5795,6 +5796,7 @@ void updateSettingsMenu() else sprintf (sbuf, "Resolution: %d*%d (widescreen)", (int)newscreenwidth, (int)newscreenheight); Menu::setText(0, sbuf); + Menu::setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off"); if (newdetail == 0) Menu::setText(1, "Detail: Low"); if (newdetail == 1) Menu::setText(1, "Detail: Medium"); if (newdetail == 2) Menu::setText(1, "Detail: High"); @@ -5875,6 +5877,7 @@ void Game::LoadMenu() break; case 3: Menu::addButton( 0, "", 10 + 20, 440); + Menu::addButton(14, "", 10 + 400, 440); Menu::addButton( 1, "", 10 + 60, 405); Menu::addButton( 2, "", 10 + 70, 370); Menu::addButton( 3, "", 10 + 20 - 1000, 335 - 1000); @@ -6165,6 +6168,9 @@ void MenuTick() case 13: showdamagebar = !showdamagebar; break; + case 14: + toggleFullscreen(); + break; } updateSettingsMenu(); break; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index 1cb6dbf..524f1fa 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -59,6 +59,7 @@ int difficulty = 0; float multiplier = 0; float realmultiplier = 0; float screenwidth = 0, screenheight = 0; +bool fullscreen = 0; float viewdistance = 0; XYZ viewer; XYZ viewerfacing; diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index dc30a03..2c7272d 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -217,8 +217,9 @@ void initGL() } } -static void toggleFullscreen() +void toggleFullscreen() { + fullscreen = !fullscreen; Uint32 flags = SDL_GetWindowFlags(sdlwindow); if (flags & SDL_WINDOW_FULLSCREEN) { flags &= ~SDL_WINDOW_FULLSCREEN; @@ -331,8 +332,10 @@ Boolean SetUp () SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); Uint32 sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; - if (!cmdline("windowed")) + if ((fullscreen || cmdline("fullscreen")) && !cmdline("windowed")) { + fullscreen = 1; sdlflags |= SDL_WINDOW_FULLSCREEN; + } if (!cmdline("nomousegrab")) sdlflags |= SDL_WINDOW_INPUT_GRABBED; diff --git a/Source/Settings.cpp b/Source/Settings.cpp index 2a1ad12..e0b4db1 100644 --- a/Source/Settings.cpp +++ b/Source/Settings.cpp @@ -32,6 +32,7 @@ void DefaultSettings() usermousesensitivity = 1; newscreenwidth = kContextWidth = 640; newscreenheight = kContextHeight = 480; + fullscreen = 0; kBitsPerPixel = 32; floatjump = 0; autoslomo = 1; @@ -86,6 +87,8 @@ void SaveSettings() opstream << newscreenwidth; opstream << "\nScreenheight:\n"; opstream << newscreenheight; + opstream << "\nFullscreen:\n"; + opstream << fullscreen; opstream << "\nMouse sensitivity:\n"; opstream << usermousesensitivity; opstream << "\nBlur(0,1):\n"; @@ -198,6 +201,8 @@ bool LoadSettings() ipstream >> kContextWidth; } else if ( !strncmp(setting, "Screenheight", 12) ) { ipstream >> kContextHeight; + } else if ( !strncmp(setting, "Fullscreen", 10) ) { + ipstream >> fullscreen; } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) { ipstream >> usermousesensitivity; } else if ( !strncmp(setting, "Blur", 4) ) { diff --git a/Source/Settings.h b/Source/Settings.h index 0cd2678..e28e346 100644 --- a/Source/Settings.h +++ b/Source/Settings.h @@ -54,6 +54,7 @@ extern int kBitsPerPixel; extern int kContextWidth; extern int kContextHeight; extern float screenwidth, screenheight; +extern bool fullscreen; void DefaultSettings(); void SaveSettings();