From 49e8c04441363f15741e0787d8216ed1bc84fc87 Mon Sep 17 00:00:00 2001 From: Megalon Date: Fri, 8 May 2020 23:23:04 -0700 Subject: [PATCH] Make reinstall functional --- ModAssistant/MainWindow.xaml | 4 ++-- ModAssistant/MainWindow.xaml.cs | 4 ++-- ModAssistant/Pages/Mods.xaml.cs | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ModAssistant/MainWindow.xaml b/ModAssistant/MainWindow.xaml index e95cd79..863059a 100644 --- a/ModAssistant/MainWindow.xaml +++ b/ModAssistant/MainWindow.xaml @@ -226,8 +226,8 @@ Width="15" Height="40" HorizontalAlignment="Right" > - - + + diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index 7e34708..5803185 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -254,7 +254,7 @@ namespace ModAssistant private void InstallButton_Click(object sender, RoutedEventArgs e) { - Mods.Instance.InstallMods(); + Mods.Instance.InstallMods(false); } private void InfoButton_Click(object sender, RoutedEventArgs e) @@ -322,7 +322,7 @@ namespace ModAssistant private void ReinstallAllButton_Click(object sender, RoutedEventArgs e) { - + Mods.Instance.InstallMods(true); } } } diff --git a/ModAssistant/Pages/Mods.xaml.cs b/ModAssistant/Pages/Mods.xaml.cs index 59945cd..e9c2555 100644 --- a/ModAssistant/Pages/Mods.xaml.cs +++ b/ModAssistant/Pages/Mods.xaml.cs @@ -309,7 +309,7 @@ namespace ModAssistant.Pages } } - public async void InstallMods() + public async void InstallMods(bool reinstallInstalledMods) { MainWindow.Instance.InstallButton.IsEnabled = false; string installDirectory = App.BeatSaberInstallDirectory; @@ -317,7 +317,10 @@ namespace ModAssistant.Pages foreach (Mod mod in ModsList) { // Ignore mods that are newer than installed version - if (mod.ListItem.IsNewerVersionInstalled) continue; + if (mod.ListItem.GetVersionComparison > 0) continue; + + // Ignore mods that are on current version if we aren't reinstalling mods + if (mod.ListItem.GetVersionComparison == 0 && !reinstallInstalledMods) continue; if (mod.name.ToLower() == "bsipa") { @@ -573,12 +576,13 @@ namespace ModAssistant.Pages } } - public bool IsNewerVersionInstalled + public int GetVersionComparison { get { - if (!IsInstalled) return false; - return _installedVersion > ModVersion; + if (!IsInstalled || _installedVersion < ModVersion) return -1; + if (_installedVersion > ModVersion) return 1; + return 0; } }