From af43367789cf51f3deda131b9dbf0c115730dd29 Mon Sep 17 00:00:00 2001 From: beaglejoe Date: Tue, 14 Dec 2021 04:02:33 +0000 Subject: [PATCH] Only restart game on Display changes that require it git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7822 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 763db90c0f42b24de8ae13d70c43de975e37699f Former-commit-id: 36da23a4517bcddf48edb01a257c34ed375d26d4 --- .../legacymenu/confscreens/displayconfig.cpp | 31 ++++++++++++++----- .../legacymenu/confscreens/displayconfig.h | 5 +++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/modules/userinterface/legacymenu/confscreens/displayconfig.cpp b/src/modules/userinterface/legacymenu/confscreens/displayconfig.cpp index b1d96b0ae..53cc8fb17 100644 --- a/src/modules/userinterface/legacymenu/confscreens/displayconfig.cpp +++ b/src/modules/userinterface/legacymenu/confscreens/displayconfig.cpp @@ -167,11 +167,24 @@ void DisplayMenu::onAccept(void *pDisplayMenu) // Save some settings to graph.xml pMenu->storeGraphicSettings(); - // Shutdown the user interface. - LegacyMenu::self().shutdown(); + if(pMenu->restartNeeded()) + { + // Shutdown the user interface. + LegacyMenu::self().shutdown(); - // Restart the game. - GfuiApp().restart(); + // Restart the game. + GfuiApp().restart(); + } + GfuiScreenActivate(pMenu->getPreviousMenuHandle()); +} + +bool DisplayMenu::restartNeeded() +{ + bool needRestart = ((_eDisplayMode != _eOriginalDisplayMode) + || (_nScreenWidth !=_nOriginalScreenWidth) + || (_nScreenHeight != _nOriginalScreenHeight)); + + return needRestart; } void DisplayMenu::onCancel(void *pDisplayMenu) @@ -235,11 +248,11 @@ void DisplayMenu::loadSettings() // Display mode : Full-screen or Windowed. const char *pszFullScreen = GfParmGetStr(hScrConfParams, pszScrPropSec, GFSCR_ATT_FSCR, GFSCR_VAL_NO); - _eDisplayMode = strcmp(pszFullScreen, GFSCR_VAL_YES) ? eWindowed : eFullScreen; + _eOriginalDisplayMode = _eDisplayMode = strcmp(pszFullScreen, GFSCR_VAL_YES) ? eWindowed : eFullScreen; // Screen / window size. - _nScreenWidth = (int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_WIN_X, NULL, 800); - _nScreenHeight = (int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_WIN_Y, NULL, 600); + _nOriginalScreenWidth =_nScreenWidth = (int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_WIN_X, NULL, 800); + _nOriginalScreenHeight = _nScreenHeight = (int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_WIN_Y, NULL, 600); #ifndef NoMaxRefreshRate // Max. refresh rate (Hz). @@ -486,10 +499,12 @@ DisplayMenu::DisplayMenu() _fArcRatio = 1.0f; _fBezelComp = 110.0f; _fScreenDist = 1.0f; + _nOriginalScreenWidth = 800; + _nOriginalScreenHeight = 600; + _eOriginalDisplayMode = eWindowed; #ifndef NoMaxRefreshRate _nMaxRefreshRate = 0; #endif - printf("this = %p \n", this); } DisplayMenu::~DisplayMenu() diff --git a/src/modules/userinterface/legacymenu/confscreens/displayconfig.h b/src/modules/userinterface/legacymenu/confscreens/displayconfig.h index 536dae165..b78b05d8e 100644 --- a/src/modules/userinterface/legacymenu/confscreens/displayconfig.h +++ b/src/modules/userinterface/legacymenu/confscreens/displayconfig.h @@ -62,6 +62,8 @@ protected: void resetColorDepths(); void resetScreenSizes(); + bool restartNeeded(); + // Control callback functions (must be static). static void onActivate(void *pDisplayMenu); static void onChangeScreenSize(tComboBoxInfo *pInfo); @@ -86,10 +88,13 @@ private: //! Currently selected display mode. EDisplayMode _eDisplayMode; + EDisplayMode _eOriginalDisplayMode; //! Currently selected screen size. int _nScreenWidth; int _nScreenHeight; + int _nOriginalScreenWidth; + int _nOriginalScreenHeight; EDisplayType _eDisplayType; float _fArcRatio;