Skip to content

Commit

Permalink
auto enable/disable dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Jun 17, 2024
1 parent 8b9ee14 commit 52006e9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Avalonia/Core/ViewModels/ModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Mods.Providers;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;

namespace BuildLauncher.ViewModels
{
Expand Down Expand Up @@ -146,12 +147,29 @@ private void ModCheckboxPressed(object? obj)

if (!mod.IsEnabled)
{
var deps = ModsList.Where(x => x.DependentAddons?.ContainsKey(mod.Id) ?? false);

_installedAddonsProvider.DisableAddon(new(mod.Id, mod.Version));

foreach (var depMod in deps)
{
_installedAddonsProvider.DisableAddon(new(depMod.Id, depMod.Version));
}
}
else if (mod.IsEnabled)
{
var dependencies = mod.DependentAddons;
var depMods = dependencies is null ? [] : ModsList.Where(x => dependencies.ContainsKey(x.Id));

_installedAddonsProvider.EnableAddon(new(mod.Id, mod.Version));

foreach (var depMod in depMods)
{
_installedAddonsProvider.EnableAddon(new(depMod.Id, depMod.Version));
}
}

OnPropertyChanged(nameof(ModsList));
}

#endregion
Expand Down

0 comments on commit 52006e9

Please sign in to comment.