Skip to content

Commit 0666ff0

Browse files
committed
tweak(gamelod): Simplify game detail setup for options menu
1 parent 48054ec commit 0666ff0

File tree

5 files changed

+26
-96
lines changed

5 files changed

+26
-96
lines changed

GeneralsMD/Code/GameEngine/Include/Common/GameLOD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class GameLODManager
164164

165165
const char *getStaticGameLODLevelName(StaticGameLODLevel level);
166166
const char *getDynamicGameLODLevelName(DynamicGameLODLevel level);
167-
StaticGameLODLevel findStaticLODLevel(void); ///< calculate the optimal static LOD level for this system.
167+
StaticGameLODLevel getRecommendedStaticLODLevel(void); ///< calculate the optimal static LOD level for this system.
168168
Bool setStaticLODLevel(StaticGameLODLevel level); ///< set the current static LOD level.
169169
StaticGameLODLevel getStaticLODLevel(void) { return m_currentStaticLOD;}
170170
DynamicGameLODLevel findDynamicLODLevel(Real averageFPS); ///<given an average fps, return the optimal dynamic LOD.

GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ const char *GameLODManager::getStaticGameLODLevelName(StaticGameLODLevel level)
445445

446446
/**Function which calculates the recommended LOD level for current hardware
447447
configuration.*/
448-
StaticGameLODLevel GameLODManager::findStaticLODLevel(void)
448+
StaticGameLODLevel GameLODManager::getRecommendedStaticLODLevel(void)
449449
{
450450
//Check if we have never done the test on current system
451451
if (m_idealDetailLevel == STATIC_GAME_LOD_UNKNOWN)
@@ -692,15 +692,15 @@ void GameLODManager::applyDynamicLODLevel(DynamicGameLODLevel level)
692692
Int GameLODManager::getRecommendedTextureReduction(void)
693693
{
694694
if (m_idealDetailLevel == STATIC_GAME_LOD_UNKNOWN)
695-
findStaticLODLevel(); //it was never tested, so test now.
695+
getRecommendedStaticLODLevel(); //it was never tested, so test now.
696696

697697
if (!m_memPassed) //if they have < 256 MB, force them to low res textures.
698-
return m_staticGameLODInfo[STATIC_GAME_LOD_LOW].m_textureReduction;
698+
return getLevelTextureReduction(STATIC_GAME_LOD_LOW);
699699

700700
if (m_idealDetailLevel < 0 || m_idealDetailLevel >= STATIC_GAME_LOD_COUNT)
701-
return m_staticGameLODInfo[STATIC_GAME_LOD_LOW].m_textureReduction;
701+
return getLevelTextureReduction(STATIC_GAME_LOD_LOW);
702702

703-
return m_staticGameLODInfo[m_idealDetailLevel].m_textureReduction;
703+
return getLevelTextureReduction(m_idealDetailLevel);
704704
}
705705

706706
Int GameLODManager::getLevelTextureReduction(StaticGameLODLevel level)

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

Lines changed: 15 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@ extern void DoResolutionDialog();
217217
static Bool ignoreSelected = FALSE;
218218
WindowLayout *OptionsLayout = NULL;
219219

220-
enum Detail CPP_11(: Int)
221-
{
222-
HIGHDETAIL = 0,
223-
MEDIUMDETAIL,
224-
LOWDETAIL,
225-
CUSTOMDETAIL,
226-
};
227-
228220

229221
OptionPreferences::OptionPreferences( void )
230222
{
@@ -922,25 +914,9 @@ static void setDefaults( void )
922914

923915
//-------------------------------------------------------------------------------------------------
924916
// LOD
925-
if ((TheGameLogic->isInGame() == FALSE) || (TheGameLogic->isInShellGame() == TRUE)) {
926-
StaticGameLODLevel level=TheGameLODManager->findStaticLODLevel();
927-
switch (level)
928-
{
929-
case STATIC_GAME_LOD_LOW:
930-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
931-
break;
932-
case STATIC_GAME_LOD_MEDIUM:
933-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
934-
break;
935-
case STATIC_GAME_LOD_HIGH:
936-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
937-
break;
938-
case STATIC_GAME_LOD_CUSTOM:
939-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
940-
break;
941-
default:
942-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
943-
};
917+
if ((TheGameLogic->isInGame() == FALSE) || (TheGameLogic->isInShellGame() == TRUE))
918+
{
919+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getRecommendedStaticLODLevel());
944920
}
945921

946922
//-------------------------------------------------------------------------------------------------
@@ -1114,7 +1090,7 @@ static void saveOptions( void )
11141090
//-------------------------------------------------------------------------------------------------
11151091
// Custom game detail settings.
11161092
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
1117-
if (index == CUSTOMDETAIL)
1093+
if (index == STATIC_GAME_LOD_CUSTOM)
11181094
{
11191095
//-------------------------------------------------------------------------------------------------
11201096
// Texture resolution slider
@@ -1186,27 +1162,8 @@ static void saveOptions( void )
11861162
// LOD
11871163
if (comboBoxDetail && comboBoxDetail->winGetEnabled())
11881164
{
1189-
Bool levelChanged=FALSE;
11901165
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
1191-
1192-
//The levels stored by the LOD Manager are inverted compared to GUI so find correct one:
1193-
switch (index) {
1194-
case HIGHDETAIL:
1195-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH);
1196-
break;
1197-
case MEDIUMDETAIL:
1198-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM);
1199-
break;
1200-
case LOWDETAIL:
1201-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW);
1202-
break;
1203-
case CUSTOMDETAIL:
1204-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM);
1205-
break;
1206-
default:
1207-
DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index));
1208-
break;
1209-
}
1166+
const Bool levelChanged = TheGameLODManager->setStaticLODLevel((StaticGameLODLevel)index);
12101167

12111168
if (levelChanged)
12121169
(*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel());
@@ -1534,23 +1491,7 @@ static void acceptAdvancedOptions()
15341491
static void cancelAdvancedOptions()
15351492
{
15361493
//restore the detail selection back to initial state
1537-
switch (TheGameLODManager->getStaticLODLevel())
1538-
{
1539-
case STATIC_GAME_LOD_LOW:
1540-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
1541-
break;
1542-
case STATIC_GAME_LOD_MEDIUM:
1543-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
1544-
break;
1545-
case STATIC_GAME_LOD_HIGH:
1546-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
1547-
break;
1548-
case STATIC_GAME_LOD_CUSTOM:
1549-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
1550-
break;
1551-
default:
1552-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
1553-
};
1494+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getStaticLODLevel());
15541495

15551496
WinAdvancedDisplay->winHide(TRUE);
15561497
}
@@ -1868,35 +1809,22 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
18681809
GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex );
18691810

18701811
// set the display detail
1812+
// TheSuperHackers @tweak xezon 24/09/2025 The Detail Combo Box now has the same value order as StaticGameLODLevel for simplicity.
18711813
GadgetComboBoxReset(comboBoxDetail);
1872-
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:High"), color);
1873-
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Medium"), color);
18741814
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Low"), color);
1815+
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Medium"), color);
1816+
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:High"), color);
18751817
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Custom"), color);
1818+
static_assert(STATIC_GAME_LOD_COUNT == 4, "Wrong combo box count");
18761819

18771820
//Check if level was never set and default to setting most suitable for system.
18781821
if (TheGameLODManager->getStaticLODLevel() == STATIC_GAME_LOD_UNKNOWN)
1879-
TheGameLODManager->setStaticLODLevel(TheGameLODManager->findStaticLODLevel());
1880-
1881-
switch (TheGameLODManager->getStaticLODLevel())
1882-
{
1883-
case STATIC_GAME_LOD_LOW:
1884-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
1885-
break;
1886-
case STATIC_GAME_LOD_MEDIUM:
1887-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
1888-
break;
1889-
case STATIC_GAME_LOD_HIGH:
1890-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
1891-
break;
1892-
case STATIC_GAME_LOD_CUSTOM:
1893-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
1894-
break;
1895-
default:
1896-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
1897-
};
1822+
{
1823+
TheGameLODManager->setStaticLODLevel(TheGameLODManager->getRecommendedStaticLODLevel());
1824+
}
18981825

18991826
Int txtFact=TheGameLODManager->getCurrentTextureReduction();
1827+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getStaticLODLevel());
19001828

19011829
GadgetSliderSetPosition( sliderTextureResolution, 2-txtFact);
19021830

@@ -2217,7 +2145,7 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg,
22172145
{
22182146
Int index;
22192147
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
2220-
if(index != CUSTOMDETAIL)
2148+
if(index != STATIC_GAME_LOD_CUSTOM)
22212149
break;
22222150

22232151
showAdvancedOptions();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ void finishSinglePlayerInit( void )
900900
if (!TheGameLODManager->didMemPass()) {
901901
useLowRes = TRUE;
902902
}
903-
if (TheGameLODManager->findStaticLODLevel()==STATIC_GAME_LOD_LOW) {
903+
if (TheGameLODManager->getRecommendedStaticLODLevel()==STATIC_GAME_LOD_LOW) {
904904
useLowRes = TRUE;
905905
}
906906
if (TheGameLODManager->getStaticLODLevel()==STATIC_GAME_LOD_LOW) {
@@ -1980,7 +1980,7 @@ winName.format("ScoreScreen.wnd:StaticTextScore%d", pos);
19801980
stats.surrenders[ptIdx] += TheGameInfo->haveWeSurrendered() || !TheVictoryConditions->getEndFrame();
19811981

19821982
AsciiString systemSpec;
1983-
systemSpec.format("LOD%d", TheGameLODManager->findStaticLODLevel());
1983+
systemSpec.format("LOD%d", TheGameLODManager->getRecommendedStaticLODLevel());
19841984
stats.systemSpec = systemSpec.str();
19851985

19861986
stats.techCaptured[ptIdx] += s->getTotalTechBuildingsCaptured();

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,9 @@ void W3DDisplay::init( void )
790790

791791
//Check if level was never set and default to setting most suitable for system.
792792
if (TheGameLODManager->getStaticLODLevel() == STATIC_GAME_LOD_UNKNOWN)
793-
TheGameLODManager->setStaticLODLevel(TheGameLODManager->findStaticLODLevel());
793+
{
794+
TheGameLODManager->setStaticLODLevel(TheGameLODManager->getRecommendedStaticLODLevel());
795+
}
794796
else
795797
{ //Static LOD level was applied during GameLOD manager init except for texture reduction
796798
//which needs to be applied here.

0 commit comments

Comments
 (0)