Skip to content

Commit

Permalink
changed autoload mods enabling behaviour, updated to 0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Nov 24, 2024
1 parent 96cc7a8 commit d7fff0d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.27.1</Version>
<Version>0.28.0</Version>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
44 changes: 37 additions & 7 deletions src/Addons/Providers/InstalledAddonsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,19 @@ await Task.Run(async () =>


//grpinfo
List<string> foldersGrpInfos = [];
List<string> foldersWithGrpInfos = [];

var dirs2 = Directory.GetDirectories(_game.CampaignsFolderPath, "*", SearchOption.TopDirectoryOnly);

foreach (var dir in dirs2)
foreach (var dir in dirs)
{
if (File.Exists(Path.Combine(dir, "addons.grpinfo")))
{
foldersGrpInfos.Add(dir);
foldersWithGrpInfos.Add(dir);
}
}

if (foldersGrpInfos.Count > 0)
if (foldersWithGrpInfos.Count > 0)
{
var grpInfoAddons = GrpInfoProvider.GetAddonsFromGrpInfo(foldersGrpInfos);
var grpInfoAddons = GrpInfoProvider.GetAddonsFromGrpInfo(foldersWithGrpInfos);

if (grpInfoAddons.Count > 0)
{
Expand All @@ -171,6 +169,38 @@ await Task.Run(async () =>
//mods
var filesMods = Directory.GetFiles(_game.ModsFolderPath, "*.zip");
var mods = await GetAddonsFromFilesAsync(filesMods).ConfigureAwait(false);


//enabling/disabling addons
foreach (var mod in mods)
{
if (((AutoloadMod)mod.Value).IsEnabled)
{
var dependants = mods.Where(x => x.Value.DependentAddons?.ContainsKey(mod.Key.Id) ?? false);

foreach (var depMod in dependants)
{
((AutoloadMod)depMod.Value).IsEnabled = true;
}

var incompatibles = mods.Where(x => x.Value.IncompatibleAddons?.ContainsKey(mod.Key.Id) ?? false);

foreach (var incMod in incompatibles)
{
((AutoloadMod)incMod.Value).IsEnabled = false;
}
}
else if (!((AutoloadMod)mod.Value).IsEnabled)
{
var dependants = mods.Where(x => x.Value.DependentAddons?.ContainsKey(mod.Key.Id) ?? false);

foreach (var depMod in dependants)
{
((AutoloadMod)depMod.Value).IsEnabled = false;
}
}
}

_cache.Add(AddonTypeEnum.Mod, mods);

}).WaitAsync(CancellationToken.None).ConfigureAwait(false);
Expand Down

0 comments on commit d7fff0d

Please sign in to comment.