Skip to content

Commit d076771

Browse files
authored
Merge branch 'development' into activity-scene-compatibility
2 parents 7141acb + e59a996 commit d076771

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5454
New `GAScripted` INI enumerating property `AddRequiredArea`, replacing Lua file scanning, to allow Activities to explicitly state which areas are strictly required.
5555
As before, these work in tandem. Both the required areas, if defined, and script conditional method, if defined, must pass for the scene to qualify.
5656

57+
- 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.
58+
5759
- Allow lua scripts to use LuaJIT's BitOp module (see https://bitop.luajit.org/api.html)
5860

5961
</details>
@@ -85,6 +87,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8587

8688
- The `LimbPath` property `NormalTravelSpeed` has been renamed to just `TravelSpeed`.
8789

90+
- `GameActivity` INI properties `TeamNTech` values switched to lazy eval, allowing them to be validated once all modules are loaded.
91+
As well, the scenario menu activity configuration screen now respects defaults set in INI, where possible.
92+
93+
- Internal GUI element `ComboBox` no longer displays dropdown combobutton when disabled, to communicate visually that it's setting is not modifiable.
94+
8895
- 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.
8996

9097
- 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`.
@@ -105,6 +112,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
105112

106113
- Fixed an issue where an `Actor`'s MovementState wasn't correctly accessible from script.
107114

115+
- Fixed an issue where internal Lua functions OriginalDoFile, OriginalLoadFile, and OriginalRequire were polluting the global namespace. They have now been made inaccessible.
116+
108117
</details>
109118

110119
<details><summary><b>Removed</b></summary>

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/Managers/LuaMan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ void LuaStateWrapper::Initialize() {
249249
// Override "math.random" in the lua state to use RTETools MT19937 implementation. Preserve return types of original to not break all the things.
250250
"math.random = function(lower, upper) if lower ~= nil and upper ~= nil then return LuaMan:SelectRand(lower, upper); elseif lower ~= nil then return LuaMan:SelectRand(1, lower); else return LuaMan:PosRand(); end end\n"
251251
// Override "dofile"/"loadfile" to be able to account for Data/ or Mods/ directory.
252-
"OriginalDoFile = dofile; dofile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalDoFile(filePath); end end;\n"
253-
"OriginalLoadFile = loadfile; loadfile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalLoadFile(filePath); end end;\n"
252+
"do local OriginalDoFile = dofile; dofile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalDoFile(filePath); end end; end\n"
253+
"do local OriginalLoadFile = loadfile; loadfile = function(filePath) filePath = PresetMan:GetFullModulePath(filePath); if filePath ~= '' then return OriginalLoadFile(filePath); end end; end\n"
254254
// Override "require" to be able to track loaded packages so we can clear them when scripts are reloaded.
255255
"_RequiredPackages = {};\n"
256-
"OriginalRequire = require; require = function(filePath) _RequiredPackages[filePath] = true; return OriginalRequire(filePath); end;\n"
256+
"do local OriginalRequire = require; require = function(filePath) _RequiredPackages[filePath] = true; return OriginalRequire(filePath); end; end\n"
257257
"_ClearRequiredPackages = function() for k, v in pairs(_RequiredPackages) do package.loaded[k] = nil; end; _RequiredPackages = {}; end;\n"
258258
// Internal helper functions to add callbacks for async pathing requests
259259
"_AsyncPathCallbacks = {};\n"

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)