@@ -582,6 +582,7 @@ int MetagameGUI::Create(Controller* pController) {
582
582
583
583
// Hide all screens, the appropriate screen will reappear on next update
584
584
HideAllScreens ();
585
+ m_TechAndFlagListFetched = false ;
585
586
return 0 ;
586
587
}
587
588
@@ -717,33 +718,43 @@ void MetagameGUI::SetEnabled(bool enable) {
717
718
g_GUISound.ExitMenuSound ()->Play ();
718
719
}
719
720
720
- // Populate the tech comboboxes with the available tech modules
721
- for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
722
- m_apPlayerTechSelect[team]->GetListPanel ()->AddItem (" -Random-" , " " , nullptr , nullptr , -1 );
723
- m_apPlayerTechSelect[team]->SetSelectedIndex (0 );
724
- }
725
- for (int moduleID = 0 ; moduleID < g_PresetMan.GetTotalModuleCount (); ++moduleID) {
726
- if (const DataModule* dataModule = g_PresetMan.GetDataModule (moduleID)) {
727
- if (dataModule->IsFaction ()) {
728
- for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
729
- m_apPlayerTechSelect[team]->GetListPanel ()->AddItem (dataModule->GetFriendlyName (), " " , nullptr , nullptr , moduleID);
730
- m_apPlayerTechSelect[team]->GetListPanel ()->ScrollToTop ();
721
+ if (!m_TechAndFlagListFetched) {
722
+ m_TechAndFlagListFetched = true ;
723
+ // Populate the tech comboboxes with the available tech modules
724
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
725
+ m_apPlayerTechSelect[player]->GetListPanel ()->AddItem (" -Random-" , " " , nullptr , nullptr , -1 );
726
+ m_apPlayerTechSelect[player]->SetSelectedIndex (0 );
727
+ }
728
+ for (int moduleID = 0 ; moduleID < g_PresetMan.GetTotalModuleCount (); ++moduleID) {
729
+ if (const DataModule* dataModule = g_PresetMan.GetDataModule (moduleID)) {
730
+ if (dataModule->IsFaction ()) {
731
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
732
+ m_apPlayerTechSelect[player]->GetListPanel ()->AddItem (dataModule->GetFriendlyName (), " " , nullptr , nullptr , moduleID);
733
+ }
731
734
}
732
735
}
733
736
}
734
- }
737
+ // Start scrolled to the top.
738
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
739
+ m_apPlayerTechSelect[player]->GetListPanel ()->ScrollToTop ();
740
+ }
735
741
736
- std::list<Entity*> flagList;
737
- g_PresetMan.GetAllOfGroup (flagList, " Flags" , " Icon" );
738
- for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
739
- for (std::list<Entity*>::iterator itr = flagList.begin (); itr != flagList.end (); ++itr) {
740
- if (const Icon* pIcon = dynamic_cast <Icon*>(*itr)) {
741
- m_apPlayerTeamSelect[player]->AddItem (" " , " " , new AllegroBitmap (pIcon->GetBitmaps32 ()[0 ]), pIcon);
742
+ // Populate team selection flags.
743
+ std::list<Entity*> flagList;
744
+ g_PresetMan.GetAllOfGroup (flagList, " Flags" , " Icon" );
745
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
746
+ for (std::list<Entity*>::iterator itr = flagList.begin (); itr != flagList.end (); ++itr) {
747
+ if (const Icon* pIcon = dynamic_cast <Icon*>(*itr)) {
748
+ m_apPlayerTeamSelect[player]->AddItem (" " , " " , new AllegroBitmap (pIcon->GetBitmaps32 ()[0 ]), pIcon);
749
+ }
742
750
}
743
751
}
744
752
}
745
- if (m_apPlayerTeamSelect[Players::PlayerOne]->GetSelectedIndex () < 0 ) {
746
- m_apPlayerTeamSelect[Players::PlayerOne]->SetSelectedIndex (0 );
753
+ // If a player has no team selected, default to the same team as their player index.
754
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
755
+ if (m_apPlayerTeamSelect[player]->GetSelectedIndex () < 0 ) {
756
+ m_apPlayerTeamSelect[player]->SetSelectedIndex (player);
757
+ }
747
758
}
748
759
749
760
m_ScreenChange = true ;
0 commit comments