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

@@ -41,7 +41,9 @@ namespace ModpackUpdater.Apps.Client
RadLabel_Status = new Telerik.WinControls.UI.RadLabel(); RadLabel_Status = new Telerik.WinControls.UI.RadLabel();
RadTextBox_MinecraftProfileFolder = new Telerik.WinControls.UI.RadTextBox(); RadTextBox_MinecraftProfileFolder = new Telerik.WinControls.UI.RadTextBox();
RadTextBox_ModpackConfig = new Telerik.WinControls.UI.RadTextBox(); RadTextBox_ModpackConfig = new Telerik.WinControls.UI.RadTextBox();
RadButton_Install = new Telerik.WinControls.UI.RadButton(); RadButton_Install = new Telerik.WinControls.UI.RadSplitButton();
radMenuItem_Install = new Telerik.WinControls.UI.RadMenuItem();
radMenuItem_Repair = new Telerik.WinControls.UI.RadMenuItem();
RadButton_CheckForUpdates = new Telerik.WinControls.UI.RadButton(); RadButton_CheckForUpdates = new Telerik.WinControls.UI.RadButton();
RadButton_PasteModpackConfig = new Telerik.WinControls.UI.RadButton(); RadButton_PasteModpackConfig = new Telerik.WinControls.UI.RadButton();
RadButton_SearchMinecraftProfileFolder = new Telerik.WinControls.UI.RadButton(); RadButton_SearchMinecraftProfileFolder = new Telerik.WinControls.UI.RadButton();
@@ -137,6 +139,7 @@ namespace ModpackUpdater.Apps.Client
RadButton_Install.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; RadButton_Install.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_Install, 2); tableLayoutPanel1.SetColumnSpan(RadButton_Install, 2);
RadButton_Install.ImageAlignment = ContentAlignment.MiddleRight; RadButton_Install.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_Install.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem_Install, radMenuItem_Repair });
RadButton_Install.Location = new Point(325, 213); RadButton_Install.Location = new Point(325, 213);
RadButton_Install.Name = "RadButton_Install"; RadButton_Install.Name = "RadButton_Install";
RadButton_Install.Size = new Size(94, 24); RadButton_Install.Size = new Size(94, 24);
@@ -146,14 +149,26 @@ namespace ModpackUpdater.Apps.Client
RadButton_Install.TextImageRelation = TextImageRelation.ImageBeforeText; RadButton_Install.TextImageRelation = TextImageRelation.ImageBeforeText;
RadButton_Install.Click += ButtonX_StartUpdate_Click; RadButton_Install.Click += ButtonX_StartUpdate_Click;
// //
// radMenuItem_Install
//
radMenuItem_Install.Name = "radMenuItem_Install";
radMenuItem_Install.Text = "Install";
radMenuItem_Install.Click += RadMenuItem_Install_Click;
//
// radMenuItem_Repair
//
radMenuItem_Repair.Name = "radMenuItem_Repair";
radMenuItem_Repair.Text = "Repair";
radMenuItem_Repair.Click += RadMenuItem_Repair_Click;
//
// RadButton_CheckForUpdates // RadButton_CheckForUpdates
// //
RadButton_CheckForUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; RadButton_CheckForUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_CheckForUpdates, 3); tableLayoutPanel1.SetColumnSpan(RadButton_CheckForUpdates, 4);
RadButton_CheckForUpdates.ImageAlignment = ContentAlignment.MiddleRight; RadButton_CheckForUpdates.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_CheckForUpdates.Location = new Point(175, 213); RadButton_CheckForUpdates.Location = new Point(153, 213);
RadButton_CheckForUpdates.Name = "RadButton_CheckForUpdates"; RadButton_CheckForUpdates.Name = "RadButton_CheckForUpdates";
RadButton_CheckForUpdates.Size = new Size(144, 24); RadButton_CheckForUpdates.Size = new Size(166, 24);
RadButton_CheckForUpdates.TabIndex = 0; RadButton_CheckForUpdates.TabIndex = 0;
RadButton_CheckForUpdates.Text = "Check for Updates"; RadButton_CheckForUpdates.Text = "Check for Updates";
RadButton_CheckForUpdates.TextAlignment = ContentAlignment.MiddleLeft; RadButton_CheckForUpdates.TextAlignment = ContentAlignment.MiddleLeft;
@@ -200,7 +215,6 @@ namespace ModpackUpdater.Apps.Client
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.Controls.Add(RadButton_CheckForUpdates, 2, 7);
tableLayoutPanel1.Controls.Add(RadLabel1, 0, 0); tableLayoutPanel1.Controls.Add(RadLabel1, 0, 0);
tableLayoutPanel1.Controls.Add(RadLabel2, 0, 2); tableLayoutPanel1.Controls.Add(RadLabel2, 0, 2);
tableLayoutPanel1.Controls.Add(RadTextBox_MinecraftProfileFolder, 1, 0); tableLayoutPanel1.Controls.Add(RadTextBox_MinecraftProfileFolder, 1, 0);
@@ -214,6 +228,7 @@ namespace ModpackUpdater.Apps.Client
tableLayoutPanel1.Controls.Add(radButton_PasteInstallKey, 5, 5); tableLayoutPanel1.Controls.Add(radButton_PasteInstallKey, 5, 5);
tableLayoutPanel1.Controls.Add(RadButton_PasteModpackConfig, 5, 3); tableLayoutPanel1.Controls.Add(RadButton_PasteModpackConfig, 5, 3);
tableLayoutPanel1.Controls.Add(radButton_RefreshConfig, 4, 3); tableLayoutPanel1.Controls.Add(radButton_RefreshConfig, 4, 3);
tableLayoutPanel1.Controls.Add(RadButton_CheckForUpdates, 1, 7);
tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0); tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1"; tableLayoutPanel1.Name = "tableLayoutPanel1";
@@ -321,7 +336,7 @@ namespace ModpackUpdater.Apps.Client
internal Telerik.WinControls.UI.RadLabel RadLabel_Status; internal Telerik.WinControls.UI.RadLabel RadLabel_Status;
internal Telerik.WinControls.UI.RadTextBox RadTextBox_MinecraftProfileFolder; internal Telerik.WinControls.UI.RadTextBox RadTextBox_MinecraftProfileFolder;
internal Telerik.WinControls.UI.RadTextBox RadTextBox_ModpackConfig; internal Telerik.WinControls.UI.RadTextBox RadTextBox_ModpackConfig;
internal Telerik.WinControls.UI.RadButton RadButton_Install; internal Telerik.WinControls.UI.RadSplitButton RadButton_Install;
internal Telerik.WinControls.UI.RadButton RadButton_CheckForUpdates; internal Telerik.WinControls.UI.RadButton RadButton_CheckForUpdates;
internal Telerik.WinControls.UI.RadButton RadButton_SearchMinecraftProfileFolder; internal Telerik.WinControls.UI.RadButton RadButton_SearchMinecraftProfileFolder;
internal Telerik.WinControls.UI.RadButton RadButton_PasteModpackConfig; internal Telerik.WinControls.UI.RadButton RadButton_PasteModpackConfig;
@@ -330,5 +345,7 @@ namespace ModpackUpdater.Apps.Client
internal Telerik.WinControls.UI.RadLabel radLabel4; internal Telerik.WinControls.UI.RadLabel radLabel4;
internal Telerik.WinControls.UI.RadTextBox radTextBox_InstallKey; internal Telerik.WinControls.UI.RadTextBox radTextBox_InstallKey;
internal Telerik.WinControls.UI.RadButton radButton_PasteInstallKey; internal Telerik.WinControls.UI.RadButton radButton_PasteInstallKey;
private Telerik.WinControls.UI.RadMenuItem radMenuItem_Repair;
private Telerik.WinControls.UI.RadMenuItem radMenuItem_Install;
} }
} }

View File

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

View File

@@ -64,10 +64,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
} }
installInfos = await DownloadInstallInfos(); installInfos = await DownloadInstallInfos();
result.CurrentVersion = modpackInfo.Version ?? new Version("0.0.0.0"); if (options.IgnoreInstalledVersion || modpackInfo.Version == null)
result.CurrentVersion = new Version("0.0.0.0");
else
result.CurrentVersion = modpackInfo.Version;
// Check install actions // Check install actions
if (!exists) if (!exists || options.IgnoreInstalledVersion)
{ {
result.IsInstalled = false; result.IsInstalled = false;

View File

@@ -7,4 +7,5 @@ public class UpdateCheckOptions
public bool AllowUpdaterAfterInstall { get; set; } = true; public bool AllowUpdaterAfterInstall { get; set; } = true;
public Side Side { get; set; } = Side.Client; public Side Side { get; set; } = Side.Client;
public bool IncludeExtras { get; set; } public bool IncludeExtras { get; set; }
public bool IgnoreInstalledVersion { get; set; }
} }