Skip to content

Commit 4e0fe8e

Browse files
committed
Added Activity .ini properties TeamNTechSwitchEnabled, updated TeamNTech to not safety check for installed mods, as the code actually can not know which mods are installed until after loading. Updated ComboBox code to not display the ComboButton while disabled, and display content at full width when disabled. Updated the ScenarioActivityConfigGUI to respect which team is selected and whether the team's faction. Now an activity may specify default factions and lock the important ones.
1 parent 5c457c1 commit 4e0fe8e

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

Source/Activities/GameActivity.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ void GameActivity::Clear() {
7070
m_ReadyToStart[player] = false;
7171
m_PurchaseOverride[player].clear();
7272
m_BrainLZWidth[player] = BRAINLZWIDTHDEFAULT;
73-
m_TeamTech[player] = "";
7473
m_NetworkPlayerNames[player] = "";
7574
}
7675

@@ -95,6 +94,8 @@ void GameActivity::Clear() {
9594

9695
for (int team = Teams::TeamOne; team < Teams::MaxTeamCount; ++team) {
9796
m_Deliveries[team].clear();
97+
m_TeamTech[team] = "";
98+
m_TeamTechSwitchEnabled[team] = true;
9899
m_LandingZoneArea[team].Reset();
99100
m_aLZCursor[team].clear();
100101
m_aObjCursor[team].clear();
@@ -158,6 +159,7 @@ int GameActivity::Create(const GameActivity& reference) {
158159
for (int team = Teams::TeamOne; team < Teams::MaxTeamCount; ++team) {
159160
m_LandingZoneArea[team] = reference.m_LandingZoneArea[team];
160161
m_TeamTech[team] = reference.m_TeamTech[team];
162+
m_TeamTechSwitchEnabled[team] = reference.m_TeamTechSwitchEnabled[team];
161163
m_TeamIsCPU[team] = reference.m_TeamIsCPU[team];
162164
}
163165

@@ -220,7 +222,19 @@ int GameActivity::ReadProperty(const std::string_view& propName, Reader& reader)
220222
if (propName == "Team" + std::to_string(team + 1) + "Tech") {
221223
std::string techName;
222224
reader >> techName;
223-
SetTeamTech(team, techName);
225+
m_TeamTech[team] = techName;
226+
}
227+
});
228+
MatchForwards("Team1TechSwitchEnabled")
229+
MatchForwards("Team2TechSwitchEnabled")
230+
MatchForwards("Team3TechSwitchEnabled")
231+
MatchProperty(
232+
"Team4TechSwitchEnabled",
233+
for (int team = Teams::TeamOne; team < Teams::MaxTeamCount; team++) {
234+
if (propName == "Team" + std::to_string(team + 1) + "TechSwitchEnabled") {
235+
bool switchEnabled;
236+
reader >> switchEnabled;
237+
m_TeamTechSwitchEnabled[team] = switchEnabled;
224238
}
225239
});
226240
MatchProperty("SpecialBehaviour_StartingGold", { reader >> m_StartingGold; });

Source/Activities/GameActivity.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ namespace RTE {
423423

424424
bool GetRequireClearPathToOrbitSwitchEnabled() const { return m_RequireClearPathToOrbitSwitchEnabled; }
425425

426+
bool GetTeamTechSwitchEnabled(int team) const { return m_TeamTechSwitchEnabled[team]; }
427+
426428
/// Returns CrabToHumanSpawnRatio for specified module
427429
/// @return Crab-To-Human spawn ratio value set for specified module, 0.25 is default.
428430
float GetCrabToHumanSpawnRatio(int moduleid);
@@ -583,6 +585,7 @@ namespace RTE {
583585

584586
// Tech of player
585587
std::string m_TeamTech[Teams::MaxTeamCount];
588+
bool m_TeamTechSwitchEnabled[Teams::MaxTeamCount];
586589

587590
// Initial gold amount selected by player in scenario setup dialog
588591
int m_StartingGold;

Source/GUI/GUIComboBox.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void GUIComboBox::Create(const std::string& Name, int X, int Y, int Width, int H
5353
m_Width = std::max(m_Width, m_MinWidth);
5454
m_Height = std::max(m_Height, m_MinHeight);
5555

56-
m_TextPanel->Create(0, 0, m_Width - 12, m_Height);
56+
m_TextPanel->Create(0, 0, m_Width - 4, m_Height);
5757
m_TextPanel->_SetVisible(true);
5858
m_TextPanel->SetLocked((m_DropDownStyle == DropDownList));
5959
m_TextPanel->SetSignalTarget(this);
@@ -89,7 +89,7 @@ void GUIComboBox::Create(GUIProperties* Props) {
8989
m_Width = std::max(m_Width, m_MinWidth);
9090
m_Height = std::max(m_Height, m_MinHeight);
9191

92-
m_TextPanel->Create(0, 0, m_Width - 12, m_Height);
92+
m_TextPanel->Create(0, 0, m_Width - 4, m_Height);
9393
m_TextPanel->_SetVisible(true);
9494
m_TextPanel->SetSignalTarget(this);
9595
GUIPanel::AddChild(m_TextPanel);
@@ -331,7 +331,7 @@ void GUIComboBox::Resize(int Width, int Height) {
331331

332332
GUIPanel::SetSize(Width, Height);
333333

334-
m_TextPanel->SetSize(m_Width - 12, m_Height);
334+
m_TextPanel->SetSize(m_Width - 4, m_Height);
335335
m_TextPanel->SetPositionAbs(m_X, m_Y);
336336

337337
m_Button->SetPositionAbs(m_X + m_Width - 13, m_Y + 1);
@@ -442,6 +442,13 @@ bool GUIComboBox::GetVisible() {
442442

443443
void GUIComboBox::SetEnabled(bool Enabled) {
444444
_SetEnabled(Enabled);
445+
if (m_Button) {
446+
if (Enabled) {
447+
m_Button->_SetVisible(Enabled);
448+
} else {
449+
m_Button->_SetVisible(Enabled && _GetVisible());
450+
}
451+
}
445452
if (m_ListPanel) {
446453
m_ListPanel->_SetEnabled(Enabled);
447454
}

Source/Menus/ScenarioActivityConfigGUI.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ void ScenarioActivityConfigGUI::ResetActivityConfigBox() {
191191
}
192192

193193
m_TeamTechComboBoxes.at(team)->SetVisible(m_SelectedActivity->TeamActive(team));
194+
195+
std::string teamModule = m_SelectedActivity->GetTeamTech(team);
196+
int teamModuleID = g_PresetMan.GetModuleID(teamModule);
197+
198+
if (teamModuleID != -1) {
199+
auto items = m_TeamTechComboBoxes.at(team)->GetListPanel()->GetItemList();
200+
for (int i = 0; i < items->size(); i++) {
201+
if (teamModuleID == items->at(i)->m_ExtraIndex) {
202+
teamModuleID = i;
203+
}
204+
}
205+
m_TeamTechComboBoxes.at(team)->SetSelectedIndex(teamModuleID);
206+
} else {
207+
m_TeamTechComboBoxes.at(team)->SetSelectedIndex(0);
208+
}
209+
210+
if (!m_SelectedActivity->GetTeamTechSwitchEnabled(team)) {
211+
m_TeamTechComboBoxes.at(team)->SetEnabled(false);
212+
m_TeamTechComboBoxes.at(team)->SetEnabled(false);
213+
}
214+
194215
m_TeamAISkillSliders.at(team)->SetVisible(m_SelectedActivity->TeamActive(team));
195216
m_TeamAISkillLabels.at(team)->SetVisible(m_SelectedActivity->TeamActive(team));
196217
}

0 commit comments

Comments
 (0)