Skip to content

Commit

Permalink
read all XComEngine.ini files from the Config folder when reading MCOs
Browse files Browse the repository at this point in the history
  • Loading branch information
remcoros committed Aug 14, 2023
1 parent eb1a4ed commit ad07bbd
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions xcom2-launcher/xcom2-launcher/Classes/Mod/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,24 @@ private IEnumerable<ModClassOverride> GetUIScreenListenerOverrides()

private IEnumerable<ModClassOverride> GetClassOverrides()
{
var file = FilePath.Combine(Path, "Config", "XComEngine.ini");

if (!File.Exists(file))
return new ModClassOverride[0];
var result = new List<ModClassOverride>();
var configPath = FilePath.Combine(Path, "Config");
if (!Directory.Exists(configPath))
{
return Array.Empty<ModClassOverride>();
}

foreach (var file in Directory.GetFiles(configPath, "XComEngine.ini", SearchOption.AllDirectories))
{
var modClassOverrides = from line in File.ReadLines(file)
select (l: line, match: s_classOverridesRegex.Match(s_whitespaceRegex.Replace(line, "")))
into m
where m.match.Success
select new ModClassOverride(this, m.match.Groups[2].Value, m.match.Groups[1].Value, ModClassOverrideType.Class, m.l);
result.AddRange(modClassOverrides);
}

return from line in File.ReadLines(file)
select (l: line, match: s_classOverridesRegex.Match(s_whitespaceRegex.Replace(line, "")))
into m
where m.match.Success
select new ModClassOverride(this, m.match.Groups[2].Value, m.match.Groups[1].Value, ModClassOverrideType.Class, m.l);
return result;
}

public void ShowOnSteam()
Expand Down

0 comments on commit ad07bbd

Please sign in to comment.