Skip to content

Commit e8b55f5

Browse files
authored
[GEN][ZH] Prevent a custom Display Resolution from changing when making other changes in the Options Menu (#1030)
1 parent 2934adb commit e8b55f5

File tree

2 files changed

+16
-20
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus

2 files changed

+16
-20
lines changed

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
15621562
AsciiString selectedResolution = (*pref) ["Resolution"];
15631563
Int selectedXRes=800,selectedYRes=600;
15641564
Int selectedResIndex=-1;
1565-
Int defaultResIndex=0; //index of default video mode that should always exist
15661565
if (!selectedResolution.isEmpty())
15671566
{ //try to parse 2 integers out of string
15681567
if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)
@@ -1578,22 +1577,21 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
15781577
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
15791578
str.format(L"%d x %d",xres,yres);
15801579
GadgetComboBoxAddEntry( comboBoxResolution, str, color);
1581-
if (xres == 800 && yres == 600) //keep track of default mode in case we need it.
1582-
defaultResIndex=i;
15831580
if (xres == selectedXRes && yres == selectedYRes)
15841581
selectedResIndex=i;
15851582
}
15861583

15871584
if (selectedResIndex == -1) //check if saved mode no longer available
1588-
{ //pick default resolution
1589-
selectedXRes = 800;
1590-
selectedXRes = 600;
1591-
selectedResIndex = defaultResIndex;
1585+
{
1586+
// TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600.
1587+
// This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences.
1588+
Int xres = TheDisplay->getWidth();
1589+
Int yres = TheDisplay->getHeight();
1590+
str.format(L"%d x %d",xres,yres);
1591+
GadgetComboBoxAddEntry( comboBoxResolution, str, color );
1592+
selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1;
15921593
}
15931594

1594-
TheWritableGlobalData->m_xResolution = selectedXRes;
1595-
TheWritableGlobalData->m_yResolution = selectedYRes;
1596-
15971595
GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex );
15981596

15991597
// set the display detail

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
16281628
AsciiString selectedResolution = (*pref) ["Resolution"];
16291629
Int selectedXRes=800,selectedYRes=600;
16301630
Int selectedResIndex=-1;
1631-
Int defaultResIndex=0; //index of default video mode that should always exist
16321631
if (!selectedResolution.isEmpty())
16331632
{ //try to parse 2 integers out of string
16341633
if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)
@@ -1644,22 +1643,21 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
16441643
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
16451644
str.format(L"%d x %d",xres,yres);
16461645
GadgetComboBoxAddEntry( comboBoxResolution, str, color);
1647-
if (xres == 800 && yres == 600) //keep track of default mode in case we need it.
1648-
defaultResIndex=i;
16491646
if (xres == selectedXRes && yres == selectedYRes)
16501647
selectedResIndex=i;
16511648
}
16521649

16531650
if (selectedResIndex == -1) //check if saved mode no longer available
1654-
{ //pick default resolution
1655-
selectedXRes = 800;
1656-
selectedXRes = 600;
1657-
selectedResIndex = defaultResIndex;
1651+
{
1652+
// TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600.
1653+
// This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences.
1654+
Int xres = TheDisplay->getWidth();
1655+
Int yres = TheDisplay->getHeight();
1656+
str.format(L"%d x %d",xres,yres);
1657+
GadgetComboBoxAddEntry( comboBoxResolution, str, color );
1658+
selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1;
16581659
}
16591660

1660-
TheWritableGlobalData->m_xResolution = selectedXRes;
1661-
TheWritableGlobalData->m_yResolution = selectedYRes;
1662-
16631661
GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex );
16641662

16651663
// set the display detail

0 commit comments

Comments
 (0)