From 95d8d84464407910a8a229dacda0130b91ef3879 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 8 Jun 2025 10:14:39 +0200 Subject: [PATCH 1/4] [ZH] Prevent force changing a custom Display Resolution when making changes in the Options Menu --- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 1984623f6b1..89474cdf9bb 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1614,7 +1614,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) AsciiString selectedResolution = (*pref) ["Resolution"]; Int selectedXRes=800,selectedYRes=600; Int selectedResIndex=-1; - Int defaultResIndex=0; //index of default video mode that should always exist if (!selectedResolution.isEmpty()) { //try to parse 2 integers out of string if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2) @@ -1630,22 +1629,21 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth); str.format(L"%d x %d",xres,yres); GadgetComboBoxAddEntry( comboBoxResolution, str, color); - if (xres == 800 && yres == 600) //keep track of default mode in case we need it. - defaultResIndex=i; if (xres == selectedXRes && yres == selectedYRes) selectedResIndex=i; } if (selectedResIndex == -1) //check if saved mode no longer available - { //pick default resolution - selectedXRes = 800; - selectedXRes = 600; - selectedResIndex = defaultResIndex; + { + // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. + // This avoids force changing the resolution when the user has set a custom resolution (in Options.ini). + Int xres = TheDisplay->getWidth(); + Int yres = TheDisplay->getHeight(); + str.format(L"%d x %d",xres,yres); + GadgetComboBoxAddEntry( comboBoxResolution, str, color ); + selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1; } - TheWritableGlobalData->m_xResolution = selectedXRes; - TheWritableGlobalData->m_yResolution = selectedYRes; - GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex ); // set the display detail From e70c10a5ef57316c43da3e938fe4174857fd381b Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:42:25 +0200 Subject: [PATCH 2/4] Replicate in Generals --- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 7ea0bdadfae..ced8ee6b14b 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1548,7 +1548,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) AsciiString selectedResolution = (*pref) ["Resolution"]; Int selectedXRes=800,selectedYRes=600; Int selectedResIndex=-1; - Int defaultResIndex=0; //index of default video mode that should always exist if (!selectedResolution.isEmpty()) { //try to parse 2 integers out of string if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2) @@ -1564,22 +1563,21 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth); str.format(L"%d x %d",xres,yres); GadgetComboBoxAddEntry( comboBoxResolution, str, color); - if (xres == 800 && yres == 600) //keep track of default mode in case we need it. - defaultResIndex=i; if (xres == selectedXRes && yres == selectedYRes) selectedResIndex=i; } if (selectedResIndex == -1) //check if saved mode no longer available - { //pick default resolution - selectedXRes = 800; - selectedXRes = 600; - selectedResIndex = defaultResIndex; + { + // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. + // This avoids force changing the resolution when the user has set a custom resolution (in Options.ini). + Int xres = TheDisplay->getWidth(); + Int yres = TheDisplay->getHeight(); + str.format(L"%d x %d",xres,yres); + GadgetComboBoxAddEntry( comboBoxResolution, str, color ); + selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1; } - TheWritableGlobalData->m_xResolution = selectedXRes; - TheWritableGlobalData->m_yResolution = selectedYRes; - GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex ); // set the display detail From 7330412368a5f2125f2b9eed45eb79a447d3920e Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:08:45 +0200 Subject: [PATCH 3/4] Tweak comment --- .../Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 +- .../Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index ced8ee6b14b..5445fbccfa2 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1570,7 +1570,7 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) if (selectedResIndex == -1) //check if saved mode no longer available { // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. - // This avoids force changing the resolution when the user has set a custom resolution (in Options.ini). + // This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences. Int xres = TheDisplay->getWidth(); Int yres = TheDisplay->getHeight(); str.format(L"%d x %d",xres,yres); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 89474cdf9bb..68e362f2d4f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1636,7 +1636,7 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) if (selectedResIndex == -1) //check if saved mode no longer available { // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. - // This avoids force changing the resolution when the user has set a custom resolution (in Options.ini). + // This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences. Int xres = TheDisplay->getWidth(); Int yres = TheDisplay->getHeight(); str.format(L"%d x %d",xres,yres); From 8d5ba38e4269a0617d56cbe07f2714a924ee08dd Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:12:35 +0200 Subject: [PATCH 4/4] Update comment keyword --- .../Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 +- .../Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 5445fbccfa2..bf176be093e 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1569,7 +1569,7 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) if (selectedResIndex == -1) //check if saved mode no longer available { - // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. + // TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. // This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences. Int xres = TheDisplay->getWidth(); Int yres = TheDisplay->getHeight(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 68e362f2d4f..f8384ed56c1 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1635,7 +1635,7 @@ void OptionsMenuInit( WindowLayout *layout, void *userData ) if (selectedResIndex == -1) //check if saved mode no longer available { - // TheSuperHackers @tweak xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. + // TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600. // This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences. Int xres = TheDisplay->getWidth(); Int yres = TheDisplay->getHeight();