From 9694ba56fdfe0ec234c98e74729490278f386000 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 3 Oct 2024 11:36:29 +0200 Subject: [PATCH] use modpack config for finding updates --- .../Features/SharedFunctions.cs | 2 +- ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs | 11 ++++++++--- ModpackUpdater.Manager/ModpackFactory.cs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ModpackUpdater.Apps.Manager/Features/SharedFunctions.cs b/ModpackUpdater.Apps.Manager/Features/SharedFunctions.cs index f939f3b..492fce4 100644 --- a/ModpackUpdater.Apps.Manager/Features/SharedFunctions.cs +++ b/ModpackUpdater.Apps.Manager/Features/SharedFunctions.cs @@ -73,7 +73,7 @@ internal static class SharedFunctions return false; // Collect updates - var ucDialog = new UpdatesCollectorUi(actions); + var ucDialog = new UpdatesCollectorUi(api.CurWorkspace, actions); if (!ucDialog.ShowDialog(api.MainWindow).IsOk() || ucDialog.CurrentUpdates is null) return false; diff --git a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs index c347144..b8d4fd1 100644 --- a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs +++ b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs @@ -1,4 +1,5 @@ -using ModpackUpdater.Manager; +using ModpackUpdater.Apps.Manager.Api.Model; +using ModpackUpdater.Manager; using Telerik.WinControls.UI; namespace ModpackUpdater.Apps.Manager.Ui; @@ -12,6 +13,7 @@ public partial class UpdatesCollectorUi : RadForm public record ModUpdates(IEnumerable List); + private readonly IWorkspace workspace; private readonly ModpackFactory factory = new(); private readonly InstallAction[] actions; @@ -21,10 +23,13 @@ public partial class UpdatesCollectorUi : RadForm public int SelectedVersion => radListView_VersionTags.SelectedIndex; - public UpdatesCollectorUi(params InstallAction[] actions) + public UpdatesCollectorUi(IWorkspace workspace, params InstallAction[] actions) { + this.workspace = workspace; this.actions = actions; + InitializeComponent(); + radListView_Updates.AutoSizeColumnsMode = ListViewAutoSizeColumnsMode.Fill; radListView_VersionTags.AutoSizeColumnsMode = ListViewAutoSizeColumnsMode.Fill; } @@ -35,7 +40,7 @@ public partial class UpdatesCollectorUi : RadForm foreach (var action in actions) { - var updates = await factory.FindUpdates(action); + var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any); if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag) continue; diff --git a/ModpackUpdater.Manager/ModpackFactory.cs b/ModpackUpdater.Manager/ModpackFactory.cs index 01e6ad1..fbd927f 100644 --- a/ModpackUpdater.Manager/ModpackFactory.cs +++ b/ModpackUpdater.Manager/ModpackFactory.cs @@ -56,7 +56,7 @@ public class ModpackFactory return action.SourceUrl; } - public async Task[]> FindUpdates(InstallAction action, ModLoader modLoader = ModLoader.Any, string? gameVersion = null) + public async Task[]> FindUpdates(InstallAction action, string? gameVersion, ModLoader modLoader) { if (action.SourceType == SourceType.GitHub) {