@@ -63,29 +63,35 @@ namespace RTE {
63
63
m_CPULockLabel = dynamic_cast <GUILabel *>(m_GUIControlManager->GetControl (" LabelCPUTeamLock" ));
64
64
m_StartErrorLabel = dynamic_cast <GUILabel *>(m_GUIControlManager->GetControl (" LabelStartError" ));
65
65
m_StartGameButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonStartGame" ));
66
-
67
- m_TechListFetched = false ;
68
66
}
69
67
70
68
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71
69
72
70
void ScenarioActivityConfigGUI::PopulateTechComboBoxes () {
71
+ static constexpr int allTechIndex = -2 ;
72
+ static constexpr int randomTechIndex = -1 ;
73
+
74
+ std::array<int , Activity::Teams::MaxTeamCount> lastSelectedIndices = {};
75
+ lastSelectedIndices.fill (allTechIndex);
76
+
73
77
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
74
- m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (" -All-" , " " , nullptr , nullptr , -2 );
75
- m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (" -Random-" , " " , nullptr , nullptr , -1 );
78
+ lastSelectedIndices[team] = m_TeamTechComboBoxes[team]->GetSelectedIndex ();
79
+ m_TeamTechComboBoxes[team]->ClearList ();
80
+ m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (" -All-" , " " , nullptr , nullptr , allTechIndex);
81
+ m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (" -Random-" , " " , nullptr , nullptr , randomTechIndex);
76
82
}
77
- for (int moduleID = 0 ; moduleID < g_ModuleMan.GetTotalModuleCount (); ++moduleID) {
78
- if (const DataModule *dataModule = g_ModuleMan.GetDataModule (moduleID)) {
79
- if (dataModule->IsFaction ()) {
80
- for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
81
- m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (dataModule->GetFriendlyName (), " " , nullptr , nullptr , moduleID);
82
- m_TeamTechComboBoxes[team]->GetListPanel ()->ScrollToTop ();
83
- m_TeamTechComboBoxes[team]->SetSelectedIndex (0 );
84
- }
83
+ for (const auto &[moduleID, dataModule] : g_ModuleMan.GetLoadedDataModules ()) {
84
+ if (dataModule->IsFaction ()) {
85
+ for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
86
+ m_TeamTechComboBoxes[team]->GetListPanel ()->AddItem (dataModule->GetFriendlyName (), " " , nullptr , nullptr , moduleID);
87
+ m_TeamTechComboBoxes[team]->GetListPanel ()->ScrollToTop ();
88
+ m_TeamTechComboBoxes[team]->SetSelectedIndex (0 );
85
89
}
86
90
}
87
91
}
88
- m_TechListFetched = true ;
92
+ for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
93
+ m_TeamTechComboBoxes[team]->SetSelectedIndex (lastSelectedIndices[team] < m_TeamTechComboBoxes[team]->GetCount () ? lastSelectedIndices[team] : allTechIndex);
94
+ }
89
95
}
90
96
91
97
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,7 +121,7 @@ namespace RTE {
115
121
m_TeamTechComboBoxes[team]->SetVisible (enable);
116
122
}
117
123
if (enable && m_SelectedActivity && m_SelectedScene) {
118
- if (!m_TechListFetched) { PopulateTechComboBoxes (); }
124
+ PopulateTechComboBoxes ();
119
125
120
126
int startingGoldOverride = selectingPreviousActivityWithManuallyAdjustedGold ? m_StartingGoldSlider->GetValue () : -1 ;
121
127
ResetActivityConfigBox ();
0 commit comments