Skip to content

Commit 9e42e59

Browse files
authored
tweak(gamelod): Simplify game detail setup for Options Menu (#1628)
1 parent 6c9a975 commit 9e42e59

File tree

10 files changed

+52
-192
lines changed

10 files changed

+52
-192
lines changed

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

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

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

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

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

442442
/**Function which calculates the recommended LOD level for current hardware
443443
configuration.*/
444-
StaticGameLODLevel GameLODManager::findStaticLODLevel(void)
444+
StaticGameLODLevel GameLODManager::getRecommendedStaticLODLevel(void)
445445
{
446446
//Check if we have never done the test on current system
447447
if (m_idealDetailLevel == STATIC_GAME_LOD_UNKNOWN)
@@ -687,15 +687,15 @@ void GameLODManager::applyDynamicLODLevel(DynamicGameLODLevel level)
687687
Int GameLODManager::getRecommendedTextureReduction(void)
688688
{
689689
if (m_idealDetailLevel == STATIC_GAME_LOD_UNKNOWN)
690-
findStaticLODLevel(); //it was never tested, so test now.
690+
getRecommendedStaticLODLevel(); //it was never tested, so test now.
691691

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

695695
if (m_idealDetailLevel < 0 || m_idealDetailLevel >= STATIC_GAME_LOD_COUNT)
696-
return m_staticGameLODInfo[STATIC_GAME_LOD_LOW].m_textureReduction;
696+
return getLevelTextureReduction(STATIC_GAME_LOD_LOW);
697697

698-
return m_staticGameLODInfo[m_idealDetailLevel].m_textureReduction;
698+
return getLevelTextureReduction(m_idealDetailLevel);
699699
}
700700

701701
Int GameLODManager::getLevelTextureReduction(StaticGameLODLevel level)

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

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

211-
enum Detail CPP_11(: Int)
212-
{
213-
HIGHDETAIL = 0,
214-
MEDIUMDETAIL,
215-
LOWDETAIL,
216-
CUSTOMDETAIL,
217-
};
218-
219211

220212
OptionPreferences::OptionPreferences( void )
221213
{
@@ -946,25 +938,9 @@ static void setDefaults( void )
946938

947939
//-------------------------------------------------------------------------------------------------
948940
// LOD
949-
if ((TheGameLogic->isInGame() == FALSE) || (TheGameLogic->isInShellGame() == TRUE)) {
950-
TheGameLODManager->setStaticLODLevel(TheGameLODManager->findStaticLODLevel());
951-
switch (TheGameLODManager->getStaticLODLevel())
952-
{
953-
case STATIC_GAME_LOD_LOW:
954-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
955-
break;
956-
case STATIC_GAME_LOD_MEDIUM:
957-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
958-
break;
959-
case STATIC_GAME_LOD_HIGH:
960-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
961-
break;
962-
case STATIC_GAME_LOD_CUSTOM:
963-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
964-
break;
965-
default:
966-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
967-
};
941+
if ((TheGameLogic->isInGame() == FALSE) || (TheGameLogic->isInShellGame() == TRUE))
942+
{
943+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getRecommendedStaticLODLevel());
968944
}
969945

970946
//-------------------------------------------------------------------------------------------------
@@ -1131,7 +1107,7 @@ static void saveOptions( void )
11311107
//-------------------------------------------------------------------------------------------------
11321108
// Custom game detail settings.
11331109
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
1134-
if (index == CUSTOMDETAIL)
1110+
if (index == STATIC_GAME_LOD_CUSTOM)
11351111
{
11361112
//-------------------------------------------------------------------------------------------------
11371113
// Texture resolution slider
@@ -1200,27 +1176,8 @@ static void saveOptions( void )
12001176
// LOD
12011177
if (comboBoxDetail && comboBoxDetail->winGetEnabled())
12021178
{
1203-
Bool levelChanged=FALSE;
12041179
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
1205-
1206-
//The levels stored by the LOD Manager are inverted compared to GUI so find correct one:
1207-
switch (index) {
1208-
case HIGHDETAIL:
1209-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_HIGH);
1210-
break;
1211-
case MEDIUMDETAIL:
1212-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_MEDIUM);
1213-
break;
1214-
case LOWDETAIL:
1215-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_LOW);
1216-
break;
1217-
case CUSTOMDETAIL:
1218-
levelChanged=TheGameLODManager->setStaticLODLevel(STATIC_GAME_LOD_CUSTOM);
1219-
break;
1220-
default:
1221-
DEBUG_ASSERTCRASH(FALSE,("LOD passed in was %d, %d is not a supported LOD",index,index));
1222-
break;
1223-
}
1180+
const Bool levelChanged = TheGameLODManager->setStaticLODLevel((StaticGameLODLevel)index);
12241181

12251182
if (levelChanged)
12261183
(*pref)["StaticGameLOD"] = TheGameLODManager->getStaticGameLODLevelName(TheGameLODManager->getStaticLODLevel());
@@ -1567,23 +1524,7 @@ static void acceptAdvancedOptions()
15671524
static void cancelAdvancedOptions()
15681525
{
15691526
//restore the detail selection back to initial state
1570-
switch (TheGameLODManager->getStaticLODLevel())
1571-
{
1572-
case STATIC_GAME_LOD_LOW:
1573-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
1574-
break;
1575-
case STATIC_GAME_LOD_MEDIUM:
1576-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
1577-
break;
1578-
case STATIC_GAME_LOD_HIGH:
1579-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
1580-
break;
1581-
case STATIC_GAME_LOD_CUSTOM:
1582-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
1583-
break;
1584-
default:
1585-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
1586-
};
1527+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getStaticLODLevel());
15871528

15881529
WinAdvancedDisplay->winHide(TRUE);
15891530
}
@@ -1894,35 +1835,22 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
18941835
GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex );
18951836

18961837
// set the display detail
1838+
// TheSuperHackers @tweak xezon 24/09/2025 The Detail Combo Box now has the same value order as StaticGameLODLevel for simplicity.
18971839
GadgetComboBoxReset(comboBoxDetail);
1898-
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:High"), color);
1899-
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Medium"), color);
19001840
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Low"), color);
1841+
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Medium"), color);
1842+
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:High"), color);
19011843
GadgetComboBoxAddEntry(comboBoxDetail, TheGameText->fetch("GUI:Custom"), color);
1844+
static_assert(STATIC_GAME_LOD_COUNT == 4, "Wrong combo box count");
19021845

19031846
//Check if level was never set and default to setting most suitable for system.
19041847
if (TheGameLODManager->getStaticLODLevel() == STATIC_GAME_LOD_UNKNOWN)
1905-
TheGameLODManager->setStaticLODLevel(TheGameLODManager->findStaticLODLevel());
1906-
1907-
switch (TheGameLODManager->getStaticLODLevel())
1908-
{
1909-
case STATIC_GAME_LOD_LOW:
1910-
GadgetComboBoxSetSelectedPos(comboBoxDetail, LOWDETAIL);
1911-
break;
1912-
case STATIC_GAME_LOD_MEDIUM:
1913-
GadgetComboBoxSetSelectedPos(comboBoxDetail, MEDIUMDETAIL);
1914-
break;
1915-
case STATIC_GAME_LOD_HIGH:
1916-
GadgetComboBoxSetSelectedPos(comboBoxDetail, HIGHDETAIL);
1917-
break;
1918-
case STATIC_GAME_LOD_CUSTOM:
1919-
GadgetComboBoxSetSelectedPos(comboBoxDetail, CUSTOMDETAIL);
1920-
break;
1921-
default:
1922-
DEBUG_ASSERTCRASH(FALSE,("Tried to set comboBoxDetail to a value of %d ", TheGameLODManager->getStaticLODLevel()) );
1923-
};
1848+
{
1849+
TheGameLODManager->setStaticLODLevel(TheGameLODManager->getRecommendedStaticLODLevel());
1850+
}
19241851

19251852
Int txtFact=TheGameLODManager->getCurrentTextureReduction();
1853+
GadgetComboBoxSetSelectedPos(comboBoxDetail, (Int)TheGameLODManager->getStaticLODLevel());
19261854

19271855
GadgetSliderSetPosition( sliderTextureResolution, 2-txtFact);
19281856

@@ -2239,7 +2167,7 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg,
22392167
{
22402168
Int index;
22412169
GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );
2242-
if(index != CUSTOMDETAIL)
2170+
if(index != STATIC_GAME_LOD_CUSTOM)
22432171
break;
22442172

22452173
showAdvancedOptions();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void finishSinglePlayerInit( void )
741741
if (!TheGameLODManager->didMemPass()) {
742742
useLowRes = TRUE;
743743
}
744-
if (TheGameLODManager->findStaticLODLevel()==STATIC_GAME_LOD_LOW) {
744+
if (TheGameLODManager->getRecommendedStaticLODLevel()==STATIC_GAME_LOD_LOW) {
745745
useLowRes = TRUE;
746746
}
747747
if (TheGameLODManager->getStaticLODLevel()==STATIC_GAME_LOD_LOW) {
@@ -1715,7 +1715,7 @@ winName.format("ScoreScreen.wnd:StaticTextScore%d", pos);
17151715
stats.surrenders[ptIdx] += TheGameInfo->haveWeSurrendered() || !TheVictoryConditions->getEndFrame();
17161716

17171717
AsciiString systemSpec;
1718-
systemSpec.format("LOD%d", TheGameLODManager->findStaticLODLevel());
1718+
systemSpec.format("LOD%d", TheGameLODManager->getRecommendedStaticLODLevel());
17191719
stats.systemSpec = systemSpec.str();
17201720

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

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

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

742742
//Check if level was never set and default to setting most suitable for system.
743743
if (TheGameLODManager->getStaticLODLevel() == STATIC_GAME_LOD_UNKNOWN)
744-
TheGameLODManager->setStaticLODLevel(TheGameLODManager->findStaticLODLevel());
744+
{
745+
TheGameLODManager->setStaticLODLevel(TheGameLODManager->getRecommendedStaticLODLevel());
746+
}
745747
else
746748
{ //Static LOD level was applied during GameLOD manager init except for texture reduction
747749
//which needs to be applied here.

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)

0 commit comments

Comments
 (0)