add repair mode

This commit is contained in:
2025-04-23 14:45:22 +02:00
parent e14dedc924
commit f19974599f
4 changed files with 55 additions and 15 deletions

View File

@@ -33,13 +33,16 @@ public partial class Form1
InitializeComponent();
Text = $"{Text} (v{Assembly.GetExecutingAssembly().GetAppVersion()})";
RadButton_Install.DefaultItem = radMenuItem_Install;
RadButton_Install.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
RadButton_CheckForUpdates.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.update_done, SymbolSize.Small);
radButton_RefreshConfig.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.refresh, SymbolSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.opened_folder, SymbolSize.Small);
radButton_PasteInstallKey.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_Install.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
radMenuItem_Install.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
radMenuItem_Repair.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.wrench, SymbolSize.Small);
}
private void LoadMinecraftProfile(string folderPath)
@@ -142,7 +145,7 @@ public partial class Form1
return true;
}
private async Task ExecuteUpdate(bool doInstall)
private async Task ExecuteUpdate(bool doInstall, bool repair)
{
var updater = new ModpackInstaller(updateConfig, modpackInfo)
{
@@ -173,18 +176,21 @@ public partial class Form1
}
// Check only if not pressed "install", not really needed otherwise.
if (lastUpdateCheckResult is null || !doInstall)
if (lastUpdateCheckResult is null || !doInstall || repair)
{
SetStatus(LangRes.StatusText_CheckingForUpdates, AppGlobals.Symbols.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
// Check for extras once again
updateOptions.IncludeExtras = features.IsEnabled(ModpackFeatures.FeatureAllowExtas, new AllowExtrasFeatureContext(modpackInfo));
// Force re-install on repair
updateOptions.IgnoreInstalledVersion = repair;
try
{
lastUpdateCheckResult = await updater.Check(updateOptions);
}
catch(Exception)
catch (Exception)
{
error();
if (Debugger.IsAttached)
@@ -201,7 +207,7 @@ public partial class Form1
error();
return;
}
// No updates available
if (!lastUpdateCheckResult.HasUpdates)
{
@@ -277,15 +283,28 @@ public partial class Form1
private async void ButtonX_CheckForUpdates_Click(object sender, EventArgs e)
{
ClearStatus();
await ExecuteUpdate(false);
await ExecuteUpdate(false, false);
}
private async void ButtonX_StartUpdate_Click(object sender, EventArgs e)
{
}
private async void RadMenuItem_Install_Click(object sender, EventArgs e)
{
if (!currentUpdating)
{
ClearStatus();
await ExecuteUpdate(true);
await ExecuteUpdate(true, false);
}
}
private async void RadMenuItem_Repair_Click(object sender, EventArgs e)
{
if (!currentUpdating)
{
ClearStatus();
await ExecuteUpdate(true, true);
}
}