Skip to content

Commit abbb191

Browse files
authored
[GEN][ZH] Prevent IP options from changing when changing the Display Resolution in the Options Menu (#1060)
1 parent 3c9397c commit abbb191

File tree

2 files changed

+112
-100
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus

2 files changed

+112
-100
lines changed

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

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,56 +1031,6 @@ static void saveOptions( void )
10311031
(*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel());
10321032
}
10331033

1034-
//-------------------------------------------------------------------------------------------------
1035-
// Resolution
1036-
GadgetComboBoxGetSelectedPos( comboBoxResolution, &index );
1037-
Int xres, yres, bitDepth;
1038-
1039-
oldDispSettings.xRes = TheDisplay->getWidth();
1040-
oldDispSettings.yRes = TheDisplay->getHeight();
1041-
oldDispSettings.bitDepth = TheDisplay->getBitDepth();
1042-
oldDispSettings.windowed = TheDisplay->getWindowed();
1043-
1044-
if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0)
1045-
{
1046-
TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth);
1047-
if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres)
1048-
{
1049-
if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed()))
1050-
{
1051-
dispChanged = TRUE;
1052-
TheWritableGlobalData->m_xResolution = xres;
1053-
TheWritableGlobalData->m_yResolution = yres;
1054-
1055-
TheHeaderTemplateManager->headerNotifyResolutionChange();
1056-
TheMouse->mouseNotifyResolutionChange();
1057-
1058-
//Save new settings for a dialog box confirmation after options are accepted
1059-
newDispSettings.xRes = xres;
1060-
newDispSettings.yRes = yres;
1061-
newDispSettings.bitDepth = bitDepth;
1062-
newDispSettings.windowed = TheDisplay->getWindowed();
1063-
1064-
AsciiString prefString;
1065-
prefString.format("%d %d", xres, yres );
1066-
(*pref)["Resolution"] = prefString;
1067-
1068-
// delete the shell
1069-
delete TheShell;
1070-
TheShell = NULL;
1071-
1072-
// create the shell
1073-
TheShell = MSGNEW("GameClientSubsystem") Shell;
1074-
if( TheShell )
1075-
TheShell->init();
1076-
1077-
TheInGameUI->recreateControlBar();
1078-
1079-
TheShell->push( AsciiString("Menus/MainMenu.wnd") );
1080-
}
1081-
}
1082-
}
1083-
10841034
//-------------------------------------------------------------------------------------------------
10851035
// IP address
10861036
if (comboBoxLANIP && comboBoxLANIP->winGetEnabled())
@@ -1252,6 +1202,62 @@ static void saveOptions( void )
12521202
}
12531203
}
12541204

1205+
//-------------------------------------------------------------------------------------------------
1206+
// Resolution
1207+
//
1208+
// TheSuperHackers @bugfix xezon 12/06/2025 Now performs the resolution change at the very end of
1209+
// processing all the options. This is necessary, because recreating the Shell will destroy the
1210+
// Options Menu and therefore prevent any further ui gadget interactions afterwards.
1211+
1212+
GadgetComboBoxGetSelectedPos( comboBoxResolution, &index );
1213+
Int xres, yres, bitDepth;
1214+
1215+
oldDispSettings.xRes = TheDisplay->getWidth();
1216+
oldDispSettings.yRes = TheDisplay->getHeight();
1217+
oldDispSettings.bitDepth = TheDisplay->getBitDepth();
1218+
oldDispSettings.windowed = TheDisplay->getWindowed();
1219+
1220+
if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0)
1221+
{
1222+
TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth);
1223+
if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres)
1224+
{
1225+
if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed()))
1226+
{
1227+
dispChanged = TRUE;
1228+
TheWritableGlobalData->m_xResolution = xres;
1229+
TheWritableGlobalData->m_yResolution = yres;
1230+
1231+
TheHeaderTemplateManager->headerNotifyResolutionChange();
1232+
TheMouse->mouseNotifyResolutionChange();
1233+
1234+
//Save new settings for a dialog box confirmation after options are accepted
1235+
newDispSettings.xRes = xres;
1236+
newDispSettings.yRes = yres;
1237+
newDispSettings.bitDepth = bitDepth;
1238+
newDispSettings.windowed = TheDisplay->getWindowed();
1239+
1240+
AsciiString prefString;
1241+
prefString.format("%d %d", xres, yres );
1242+
(*pref)["Resolution"] = prefString;
1243+
1244+
// delete the shell
1245+
delete TheShell;
1246+
TheShell = NULL;
1247+
1248+
// create the shell
1249+
TheShell = MSGNEW("GameClientSubsystem") Shell;
1250+
if( TheShell )
1251+
TheShell->init();
1252+
1253+
TheInGameUI->recreateControlBar();
1254+
1255+
TheShell->push( AsciiString("Menus/MainMenu.wnd") );
1256+
}
1257+
}
1258+
}
1259+
1260+
// MUST NEVER ADD ANOTHER OPTION HERE AT THE END !
12551261
}
12561262

12571263
static void DestroyOptionsLayout() {

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

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,56 +1085,6 @@ static void saveOptions( void )
10851085
(*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel());
10861086
}
10871087

1088-
//-------------------------------------------------------------------------------------------------
1089-
// Resolution
1090-
GadgetComboBoxGetSelectedPos( comboBoxResolution, &index );
1091-
Int xres, yres, bitDepth;
1092-
1093-
oldDispSettings.xRes = TheDisplay->getWidth();
1094-
oldDispSettings.yRes = TheDisplay->getHeight();
1095-
oldDispSettings.bitDepth = TheDisplay->getBitDepth();
1096-
oldDispSettings.windowed = TheDisplay->getWindowed();
1097-
1098-
if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0)
1099-
{
1100-
TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth);
1101-
if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres)
1102-
{
1103-
if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed()))
1104-
{
1105-
dispChanged = TRUE;
1106-
TheWritableGlobalData->m_xResolution = xres;
1107-
TheWritableGlobalData->m_yResolution = yres;
1108-
1109-
TheHeaderTemplateManager->headerNotifyResolutionChange();
1110-
TheMouse->mouseNotifyResolutionChange();
1111-
1112-
//Save new settings for a dialog box confirmation after options are accepted
1113-
newDispSettings.xRes = xres;
1114-
newDispSettings.yRes = yres;
1115-
newDispSettings.bitDepth = bitDepth;
1116-
newDispSettings.windowed = TheDisplay->getWindowed();
1117-
1118-
AsciiString prefString;
1119-
prefString.format("%d %d", xres, yres );
1120-
(*pref)["Resolution"] = prefString;
1121-
1122-
// delete the shell
1123-
delete TheShell;
1124-
TheShell = NULL;
1125-
1126-
// create the shell
1127-
TheShell = MSGNEW("GameClientSubsystem") Shell;
1128-
if( TheShell )
1129-
TheShell->init();
1130-
1131-
TheInGameUI->recreateControlBar();
1132-
1133-
TheShell->push( AsciiString("Menus/MainMenu.wnd") );
1134-
}
1135-
}
1136-
}
1137-
11381088
//-------------------------------------------------------------------------------------------------
11391089
// IP address
11401090
if (comboBoxLANIP && comboBoxLANIP->winGetEnabled())
@@ -1312,6 +1262,62 @@ static void saveOptions( void )
13121262
}
13131263
}
13141264

1265+
//-------------------------------------------------------------------------------------------------
1266+
// Resolution
1267+
//
1268+
// TheSuperHackers @bugfix xezon 12/06/2025 Now performs the resolution change at the very end of
1269+
// processing all the options. This is necessary, because recreating the Shell will destroy the
1270+
// Options Menu and therefore prevent any further ui gadget interactions afterwards.
1271+
1272+
GadgetComboBoxGetSelectedPos( comboBoxResolution, &index );
1273+
Int xres, yres, bitDepth;
1274+
1275+
oldDispSettings.xRes = TheDisplay->getWidth();
1276+
oldDispSettings.yRes = TheDisplay->getHeight();
1277+
oldDispSettings.bitDepth = TheDisplay->getBitDepth();
1278+
oldDispSettings.windowed = TheDisplay->getWindowed();
1279+
1280+
if (comboBoxResolution && comboBoxResolution->winGetEnabled() && index < TheDisplay->getDisplayModeCount() && index >= 0)
1281+
{
1282+
TheDisplay->getDisplayModeDescription(index,&xres,&yres,&bitDepth);
1283+
if (TheGlobalData->m_xResolution != xres || TheGlobalData->m_yResolution != yres)
1284+
{
1285+
if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheDisplay->getWindowed()))
1286+
{
1287+
dispChanged = TRUE;
1288+
TheWritableGlobalData->m_xResolution = xres;
1289+
TheWritableGlobalData->m_yResolution = yres;
1290+
1291+
TheHeaderTemplateManager->headerNotifyResolutionChange();
1292+
TheMouse->mouseNotifyResolutionChange();
1293+
1294+
//Save new settings for a dialog box confirmation after options are accepted
1295+
newDispSettings.xRes = xres;
1296+
newDispSettings.yRes = yres;
1297+
newDispSettings.bitDepth = bitDepth;
1298+
newDispSettings.windowed = TheDisplay->getWindowed();
1299+
1300+
AsciiString prefString;
1301+
prefString.format("%d %d", xres, yres );
1302+
(*pref)["Resolution"] = prefString;
1303+
1304+
// delete the shell
1305+
delete TheShell;
1306+
TheShell = NULL;
1307+
1308+
// create the shell
1309+
TheShell = MSGNEW("GameClientSubsystem") Shell;
1310+
if( TheShell )
1311+
TheShell->init();
1312+
1313+
TheInGameUI->recreateControlBar();
1314+
1315+
TheShell->push( AsciiString("Menus/MainMenu.wnd") );
1316+
}
1317+
}
1318+
}
1319+
1320+
// MUST NEVER ADD ANOTHER OPTION HERE AT THE END !
13151321
}
13161322

13171323
static void DestroyOptionsLayout() {

0 commit comments

Comments
 (0)