Skip to content

Commit 37b73d7

Browse files
authored
[GEN][ZH] Fix incorrect default Resolution selection in the Options Menu when the loaded Resolution does not match the active Display Resolution (#1056)
1 parent e83038f commit 37b73d7

File tree

2 files changed

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

2 files changed

+20
-8
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,21 +1578,27 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
15781578
// populate resolution modes
15791579
GadgetComboBoxReset(comboBoxResolution);
15801580
Int numResolutions = TheDisplay->getDisplayModeCount();
1581+
UnsignedInt displayWidth = TheDisplay->getWidth();
1582+
UnsignedInt displayHeight = TheDisplay->getHeight();
1583+
15811584
for( i = 0; i < numResolutions; ++i )
15821585
{ Int xres,yres,bitDepth;
15831586
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
15841587
str.format(L"%d x %d",xres,yres);
15851588
GadgetComboBoxAddEntry( comboBoxResolution, str, color);
1586-
if (xres == selectedXRes && yres == selectedYRes)
1589+
// TheSuperHackers @bugfix xezon 12/06/2025 Now makes a selection with the active display resolution
1590+
// instead of the resolution read from the Option Preferences, because the active display resolution
1591+
// is the most relevant to make a selection with and the Option Preferences could be wrong.
1592+
if ( xres == displayWidth && yres == displayHeight )
15871593
selectedResIndex=i;
15881594
}
15891595

1590-
if (selectedResIndex == -1) //check if saved mode no longer available
1596+
if (selectedResIndex == -1)
15911597
{
15921598
// TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600.
15931599
// This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences.
1594-
Int xres = TheDisplay->getWidth();
1595-
Int yres = TheDisplay->getHeight();
1600+
Int xres = displayWidth;
1601+
Int yres = displayHeight;
15961602
str.format(L"%d x %d",xres,yres);
15971603
GadgetComboBoxAddEntry( comboBoxResolution, str, color );
15981604
selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1;

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,21 +1644,27 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
16441644
// populate resolution modes
16451645
GadgetComboBoxReset(comboBoxResolution);
16461646
Int numResolutions = TheDisplay->getDisplayModeCount();
1647+
UnsignedInt displayWidth = TheDisplay->getWidth();
1648+
UnsignedInt displayHeight = TheDisplay->getHeight();
1649+
16471650
for( i = 0; i < numResolutions; ++i )
16481651
{ Int xres,yres,bitDepth;
16491652
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
16501653
str.format(L"%d x %d",xres,yres);
16511654
GadgetComboBoxAddEntry( comboBoxResolution, str, color);
1652-
if (xres == selectedXRes && yres == selectedYRes)
1655+
// TheSuperHackers @bugfix xezon 12/06/2025 Now makes a selection with the active display resolution
1656+
// instead of the resolution read from the Option Preferences, because the active display resolution
1657+
// is the most relevant to make a selection with and the Option Preferences could be wrong.
1658+
if ( xres == displayWidth && yres == displayHeight )
16531659
selectedResIndex=i;
16541660
}
16551661

1656-
if (selectedResIndex == -1) //check if saved mode no longer available
1662+
if (selectedResIndex == -1)
16571663
{
16581664
// TheSuperHackers @bugfix xezon 08/06/2025 Now adds the current resolution instead of defaulting to 800 x 600.
16591665
// This avoids force changing the resolution when the user has set a custom resolution in the Option Preferences.
1660-
Int xres = TheDisplay->getWidth();
1661-
Int yres = TheDisplay->getHeight();
1666+
Int xres = displayWidth;
1667+
Int yres = displayHeight;
16621668
str.format(L"%d x %d",xres,yres);
16631669
GadgetComboBoxAddEntry( comboBoxResolution, str, color );
16641670
selectedResIndex = GadgetComboBoxGetLength( comboBoxResolution ) - 1;

0 commit comments

Comments
 (0)