Make reinstall functional

This commit is contained in:
Megalon 2020-05-08 23:23:04 -07:00
parent e69ab66062
commit 49e8c04441
3 changed files with 13 additions and 9 deletions

View file

@ -226,8 +226,8 @@
Width="15"
Height="40"
HorizontalAlignment="Right" >
<MenuItem Header="^" Height="40">
<MenuItem Header="Reinstall All" Click="ReinstallAllButton_Click"/>
<MenuItem Header="V" Height="40">
<MenuItem Header="Reinstall and Update" Click="ReinstallAllButton_Click"/>
</MenuItem>
</Menu>
</StackPanel>

View file

@ -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);
}
}
}

View file

@ -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;
}
}