Skip to content

Commit 744568c

Browse files
authored
Merge pull request #152 from cortex-command-community/activity-tech-defaults
Default and locked team techs in Activities.
2 parents 5c457c1 + 3a19235 commit 744568c

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5050

5151
- New `AEmitter` and `PEmitter` INI and Lua (R/W) property `PlayBurstSound` which denotes whether the BurstSound should play when appropriate. This should not be confused for a trigger - it's just a enable/disable toggle to avoid having to remove and add BurstSound altogether.
5252

53+
- New `GameActivity` INI properties `TeamNTechSwitchEnabled` which determine whether activity team factions are configurable by the user. This is most useful for communicating what the player is not intended to change, or what inputs would be ignored otherwise.
54+
5355
- Allow lua scripts to use LuaJIT's BitOp module (see https://bitop.luajit.org/api.html)
5456

5557
</details>
@@ -81,6 +83,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8183

8284
- The `LimbPath` property `NormalTravelSpeed` has been renamed to just `TravelSpeed`.
8385

86+
- `GameActivity` INI properties `TeamNTech` values switched to lazy eval, allowing them to be validated once all modules are loaded.
87+
As well, the scenario menu activity configuration screen now respects defaults set in INI, where possible.
88+
89+
- Internal GUI element `ComboBox` no longer displays dropdown combobutton when disabled, to communicate visually that it's setting is not modifiable.
90+
8491
- Almost all ctrl+* special inputs functionality (i.e restarting activity, world dumps, showing performance stats) are now mapped to right alt, to not interfere with default crouching inputs. The only exception is ctrl+arrow keys for changing console size.
8592

8693
- Gibs and detached Attachables now inherit the parent's angular velocity, as well as velocity derived from the angular velocity of the parent MO and their offset from the parent's centre. On gibs, this is scaled by `InheritsVel`.

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ 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+
m_TeamTechComboBoxes.at(team)->SetEnabled(m_SelectedActivity->GetTeamTechSwitchEnabled(team));
211+
194212
m_TeamAISkillSliders.at(team)->SetVisible(m_SelectedActivity->TeamActive(team));
195213
m_TeamAISkillLabels.at(team)->SetVisible(m_SelectedActivity->TeamActive(team));
196214
}

0 commit comments

Comments
 (0)