load modpack info before modpack installer

This commit is contained in:
2024-06-20 15:05:01 +02:00
parent 604d35856f
commit c97a04c4ce
6 changed files with 64 additions and 33 deletions

View File

@@ -10,6 +10,7 @@ namespace ModpackUpdater;
public partial class Form1
{
private ModpackInfo modpackInfo = null;
private ModpackConfig updateConfig = new();
private bool currentUpdating = false;
private UpdateCheckResult lastUpdateCheckResult = null;
@@ -65,7 +66,7 @@ public partial class Form1
{
bool CheckStatusRet;
if (!IsMinecaftProfileLoaded() || !MinecraftProfileChecker.CheckProfile(GetMinecraftProfilePath()))
if (!IsMinecaftProfileLoaded())
{
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SvgImageSize.Small));
CheckStatusRet = false;
@@ -98,7 +99,21 @@ public partial class Form1
RadTextBoxControl_MinecraftProfileFolder.Text = folderPath;
if (IsUpdateConfigLoaded())
RadButton_CheckForUpdates.PerformClick();
{
try
{
modpackInfo = ModpackInfo.TryLoad(folderPath);
}
catch
{
RadTextBoxControl_MinecraftProfileFolder.Text = string.Empty;
}
if (string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text) && !string.IsNullOrWhiteSpace(modpackInfo?.ConfigUrl))
LoadUpdateConfigFile(modpackInfo.ConfigUrl);
else
RadButton_CheckForUpdates.PerformClick();
}
else
ClearStatus();
}
@@ -127,7 +142,7 @@ public partial class Form1
private async Task ExecuteUpdate(bool doInstall)
{
var updater = new ModpackInstaller(updateConfig, GetMinecraftProfilePath());
var updater = new ModpackInstaller(updateConfig, modpackInfo);
updater.InstallProgessUpdated += Update_InstallProgessUpdated;
updater.CheckingProgressUpdated += Updated_CheckingProgresssUpdated;