diff --git a/Directory.Build.props b/Directory.Build.props index d8283d3..d2cac91 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,12 @@ + + net8.0 + latest + true + enable + + https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater MIT diff --git a/ModpackUpdater.Apps.AppUpdates/ModpackUpdater.Apps.AppUpdates.csproj b/ModpackUpdater.Apps.AppUpdates/ModpackUpdater.Apps.AppUpdates.csproj deleted file mode 100644 index 7cf82d3..0000000 --- a/ModpackUpdater.Apps.AppUpdates/ModpackUpdater.Apps.AppUpdates.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - diff --git a/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs b/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs index 55aa8f3..6d3f967 100644 --- a/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs +++ b/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs @@ -12,8 +12,6 @@ using MsBox.Avalonia.Enums; using Pilz; using Pilz.Extensions; using Pilz.Runtime; -using Pilz.SymbolPacks.Sets; -using Pilz.UI.AvaloniaUI.Symbols; using Pilz.UI.Symbols; using Pilz.Updating.Client; @@ -39,10 +37,10 @@ public partial class MainForm : Window Closing += MainForm_Closing; Loaded += MainForm_Loaded; - ButtonSearchProfileFolder.ImageSource = Symbols.Fluent.GetImageSource(SymbolsFluent.opened_folder); - ButtonCheckForUpdates.ImageSource = Symbols.Fluent.GetImageSource(SymbolsFluent.update); - ButtonInstall.ImageSource = Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer); - MenuItemRepair.Icon = Symbols.Fluent.GetImage(SymbolsFluent.wrench, SymbolSize.Small); + ButtonSearchProfileFolder.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.opened_folder); + ButtonCheckForUpdates.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.update_done); + ButtonInstall.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.software_installer); + MenuItemRepair.Icon = AppGlobals.Symbols.GetImage(AppSymbols.wrench, SymbolSize.Small); ClearStatus(); LoadProfileToUi(); @@ -66,7 +64,7 @@ public partial class MainForm : Window { loadingData = true; - TextBoxMinecraftProfileFolder.Text = modpackInfo.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text; + TextBoxMinecraftProfileFolder.Text = modpackInfo.LocalPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text; TextBoxModpackConfig.Text = modpackInfo.ConfigUrl ?? TextBoxModpackConfig.Text; TextBoxInstallKey.Text = modpackInfo.ExtrasKey ?? TextBoxInstallKey.Text; @@ -110,36 +108,33 @@ public partial class MainForm : Window // Ignore } - if (modpackInfo != null) + features = new(updateConfig); + modpackInfo.ExtrasKey = TextBoxInstallKey.Text?.Trim(); + if (!features.IsInvalid() && !string.IsNullOrWhiteSpace(TextBoxInstallKey.Text) && !AllowExtras()) { - features = new(updateConfig); - modpackInfo.ExtrasKey = TextBoxInstallKey.Text?.Trim(); - if (!features.IsInvalid() && !string.IsNullOrWhiteSpace(TextBoxInstallKey.Text) && !AllowExtras()) - { - SetStatus(GeneralLangRes.InstallationKeyNotValid, Symbols.Fluent.GetImageSource(SymbolsFluent.warning_shield)); - return false; - } + SetStatus(GeneralLangRes.InstallationKeyNotValid, AppGlobals.Symbols.GetImageSource(AppSymbols.general_warning_sign)); + return false; } LabelInstallKey.IsVisible = TextBoxInstallKey.IsVisible = !string.IsNullOrWhiteSpace(updateConfig.UnleashApiUrl); - if (modpackInfo == null || string.IsNullOrWhiteSpace(TextBoxMinecraftProfileFolder.Text) /*|| modpackInfo.Valid*/) + if (string.IsNullOrWhiteSpace(TextBoxMinecraftProfileFolder.Text) /*|| modpackInfo.Valid*/) { - SetStatus(GeneralLangRes.MinecraftProfileFolderSeemsInvalid, Symbols.Fluent.GetImageSource(SymbolsFluent.warning_shield)); + SetStatus(GeneralLangRes.MinecraftProfileFolderSeemsInvalid, AppGlobals.Symbols.GetImageSource(AppSymbols.general_warning_sign)); ButtonCheckForUpdates.IsEnabled = false; ButtonInstall.IsEnabled = false; return false; } else if (string.IsNullOrWhiteSpace(TextBoxModpackConfig.Text)) { - SetStatus(GeneralLangRes.ConfigIncompleteOrNotLoaded, Symbols.Fluent.GetImageSource(SymbolsFluent.warning_shield)); + SetStatus(GeneralLangRes.ConfigIncompleteOrNotLoaded, AppGlobals.Symbols.GetImageSource(AppSymbols.general_warning_sign)); ButtonCheckForUpdates.IsEnabled = false; ButtonInstall.IsEnabled = false; return false; } else if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance) { - SetStatus(GeneralLangRes.UpdateServerInMaintenance, Symbols.Fluent.GetImageSource(SymbolsFluent.services)); + SetStatus(GeneralLangRes.UpdateServerInMaintenance, AppGlobals.Symbols.GetImageSource(AppSymbols.services)); ButtonCheckForUpdates.IsEnabled = false; ButtonInstall.IsEnabled = false; return false; @@ -161,28 +156,28 @@ public partial class MainForm : Window void error() { - SetStatus(GeneralLangRes.ErrorOnUpdateCheckOrUpdating, Symbols.Fluent.GetImageSource(SymbolsFluent.close)); + SetStatus(GeneralLangRes.ErrorOnUpdateCheckOrUpdating, AppGlobals.Symbols.GetImageSource(AppSymbols.close)); currentUpdating = false; } void installing() { - SetStatus(GeneralLangRes.Installing, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); + SetStatus(GeneralLangRes.Installing, AppGlobals.Symbols.GetImageSource(AppSymbols.software_installer)); currentUpdating = true; } void updatesAvailable() { - SetStatus(GeneralLangRes.AnUpdateIsAvailable, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); + SetStatus(GeneralLangRes.AnUpdateIsAvailable, AppGlobals.Symbols.GetImageSource(AppSymbols.software_installer)); } void everythingOk() { - SetStatus(GeneralLangRes.EverythingIsRightAndUpToDate, Symbols.Fluent.GetImageSource(SymbolsFluent.done)); + SetStatus(GeneralLangRes.EverythingIsRightAndUpToDate, AppGlobals.Symbols.GetImageSource(AppSymbols.done)); currentUpdating = false; } // Check only if not pressed "install", not really needed otherwise. if (lastUpdateCheckResult is null || !doInstall || repair) { - SetStatus(GeneralLangRes.CheckingForUpdates, Symbols.Fluent.GetImageSource(SymbolsFluent.update)); + SetStatus(GeneralLangRes.CheckingForUpdates, AppGlobals.Symbols.GetImageSource(AppSymbols.update_done)); // Check for extras once again updateOptions.IncludeExtras = AllowExtras(); @@ -259,13 +254,13 @@ public partial class MainForm : Window private void Updated_CheckingProgresssUpdated(int toCheck, int processed) { - SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", Symbols.Fluent.GetImageSource(SymbolsFluent.update)); + SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppGlobals.Symbols.GetImageSource(AppSymbols.update_done)); } private void Update_InstallProgessUpdated(UpdateCheckResult result, int processedSyncs) { var actionCount = result.Actions.Count; - SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); + SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppGlobals.Symbols.GetImageSource(AppSymbols.software_installer)); } #endregion @@ -291,7 +286,7 @@ public partial class MainForm : Window if (await updater.CheckForUpdate() is {} packageToInstall && await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, MsgBoxLangRes.UpdateAvailable, ButtonEnum.YesNo, MsBox.Avalonia.Enums.Icon.Info).ShowWindowDialogAsync(this) == ButtonResult.Yes) { - SetStatus(GeneralLangRes.DownloadProgramUpdate, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); + SetStatus(GeneralLangRes.DownloadProgramUpdate, AppGlobals.Symbols.GetImageSource(AppSymbols.software_installer)); IsEnabled = false; if (await updater.DownloadPackageAsync(packageToInstall) && await updater.InstallPackageAsync(packageToInstall, myAppPath)) @@ -314,7 +309,7 @@ public partial class MainForm : Window } catch (Exception ex) { - await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, string.Format(MsgBoxLangRes.UpdateAvailable, ex.Message), ButtonEnum.YesNo, MsBox.Avalonia.Enums.Icon.Info).ShowAsync(); + await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, string.Format(MsgBoxLangRes.UpdateAvailable, ex.Message), ButtonEnum.YesNo, MsBox.Avalonia.Enums.Icon.Info).ShowWindowAsync(); IsEnabled = true; } #endif diff --git a/ModpackUpdater.Apps.Client.Gui/ModpackUpdater.Apps.Client.Gui.csproj b/ModpackUpdater.Apps.Client.Gui/ModpackUpdater.Apps.Client.Gui.csproj index 940077c..456ef75 100644 --- a/ModpackUpdater.Apps.Client.Gui/ModpackUpdater.Apps.Client.Gui.csproj +++ b/ModpackUpdater.Apps.Client.Gui/ModpackUpdater.Apps.Client.Gui.csproj @@ -2,22 +2,13 @@ WinExe - net8.0 Assets\app.ico MinecraftModpackUpdater - true - enable true true true - latest - - - - - @@ -64,10 +55,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - @@ -75,9 +62,8 @@ - - - + + @@ -93,7 +79,7 @@ - + diff --git a/ModpackUpdater.Apps.Client.Gui/Program.cs b/ModpackUpdater.Apps.Client.Gui/Program.cs index ec99e14..e66b401 100644 --- a/ModpackUpdater.Apps.Client.Gui/Program.cs +++ b/ModpackUpdater.Apps.Client.Gui/Program.cs @@ -25,6 +25,7 @@ public static class Program [STAThread] internal static void Main(string[] args) { + AppGlobals.Initialize(); BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); } diff --git a/ModpackUpdater.Apps.Client/Assets/app.ico b/ModpackUpdater.Apps.Client/Assets/app.ico new file mode 100644 index 0000000..57d4be9 Binary files /dev/null and b/ModpackUpdater.Apps.Client/Assets/app.ico differ diff --git a/ModpackUpdater.Apps.Client/Assets/app.svg b/ModpackUpdater.Apps.Client/Assets/app.svg new file mode 100644 index 0000000..882be30 --- /dev/null +++ b/ModpackUpdater.Apps.Client/Assets/app.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Client/ModpackUpdater.Apps.Client.csproj b/ModpackUpdater.Apps.Client/ModpackUpdater.Apps.Client.csproj index 7feb1fb..362b937 100644 --- a/ModpackUpdater.Apps.Client/ModpackUpdater.Apps.Client.csproj +++ b/ModpackUpdater.Apps.Client/ModpackUpdater.Apps.Client.csproj @@ -2,9 +2,7 @@ Exe - net8.0 - enable - enable + Assets\app.ico MinecraftModpackUpdaterCli @@ -12,6 +10,10 @@ + + + + @@ -21,7 +23,6 @@ - diff --git a/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs b/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs index 4350cda..4cc22f3 100644 --- a/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs +++ b/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs @@ -1,14 +1,12 @@ -namespace ModpackUpdater.Apps.Manager.Api.Model; +using Avalonia.Controls; + +namespace ModpackUpdater.Apps.Manager.Api.Model; public interface IMainApi { IWorkspace? CurWorkspace { get; } - IActionSetInfos? CurActionSet { get; } - - Form MainWindow { get; } - + Window MainWindow { get; } void UpdateItem(InstallAction action); - void UpdateItem(IActionSetInfos actionSetInfos); } diff --git a/ModpackUpdater.Apps.Manager/App.axaml b/ModpackUpdater.Apps.Manager/App.axaml new file mode 100644 index 0000000..7d2cc14 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/App.axaml.cs b/ModpackUpdater.Apps.Manager/App.axaml.cs new file mode 100644 index 0000000..9e46992 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/App.axaml.cs @@ -0,0 +1,21 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using ModpackUpdater.Apps.Manager.Ui; + +namespace ModpackUpdater.Apps.Manager; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + desktop.MainWindow = new MainWindow(); + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Assets/app.ico b/ModpackUpdater.Apps.Manager/Assets/app.ico new file mode 100644 index 0000000..57d4be9 Binary files /dev/null and b/ModpackUpdater.Apps.Manager/Assets/app.ico differ diff --git a/ModpackUpdater.Apps.Manager/Assets/app.svg b/ModpackUpdater.Apps.Manager/Assets/app.svg new file mode 100644 index 0000000..882be30 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Assets/app.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj index 51fba62..2081f96 100644 --- a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj +++ b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj @@ -2,26 +2,46 @@ WinExe - net8.0-windows - enable - true - enable - icons8_Windows_Update.ico - Minecraft Modpack Update Manager + Assets\app.ico + MinecraftModpackUpdateManager + true + true + true + + + App.axaml + Code + + + + + + + + + - + + + + - - - - - - - + + + + + + + + + + None + All + @@ -81,4 +101,10 @@ + + + ..\..\..\.nuget\packages\pilz\2.6.1\lib\net8.0\Pilz.dll + + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Program.cs b/ModpackUpdater.Apps.Manager/Program.cs index 4600abb..97b88cf 100644 --- a/ModpackUpdater.Apps.Manager/Program.cs +++ b/ModpackUpdater.Apps.Manager/Program.cs @@ -1,3 +1,4 @@ +using Avalonia; using OfficeOpenXml; using Pilz.Configuration; using Pilz.Features; @@ -20,24 +21,31 @@ public static class Program /// The main entry point for the application. /// [STAThread] - internal static void Main() + internal static void Main(string[] args) { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); AppGlobals.Initialize(); PluginFeatureController.Instance.RegisterAllOwn(); - Application.Run(new Ui.MainForm()); + BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + } + + public static AppBuilder BuildAvaloniaApp() + { + return AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); } private static string GetSettingsPath() { const string AppDataDirectoryName = "MinecraftModpackUpdateManager"; - var SettingsFileName = $"Settings.json"; + const string settingsFileName = "Settings.json"; var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName); Directory.CreateDirectory(settingsPath); - settingsPath = Path.Combine(settingsPath, SettingsFileName); + settingsPath = Path.Combine(settingsPath, settingsFileName); return settingsPath; } diff --git a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml new file mode 100644 index 0000000..9c59c26 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml @@ -0,0 +1,9 @@ + + Welcome to Avalonia! + diff --git a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml.cs b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml.cs new file mode 100644 index 0000000..31356f6 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ModpackUpdater.Apps.Manager.Ui; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs index eae243b..5d8b5d5 100644 --- a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs +++ b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorUi.cs @@ -1,6 +1,5 @@ using ModpackUpdater.Apps.Manager.Api.Model; using ModpackUpdater.Manager; -using Telerik.WinControls.UI; namespace ModpackUpdater.Apps.Manager.Ui; @@ -18,9 +17,7 @@ public partial class UpdatesCollectorUi : RadForm private readonly InstallAction[] actions; public ModUpdates? CurrentUpdates { get; private set; } - public ModUpdateInfo? SelectedUpdate => radListView_Updates.SelectedItem?.Value as ModUpdateInfo; - public int SelectedVersion => radListView_VersionTags.SelectedIndex; public UpdatesCollectorUi(IWorkspace workspace, params InstallAction[] actions) diff --git a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml new file mode 100644 index 0000000..386e82e --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml @@ -0,0 +1,10 @@ + + + diff --git a/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml.cs b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml.cs new file mode 100644 index 0000000..6322a53 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorWindow.axaml.cs @@ -0,0 +1,33 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using ModpackUpdater.Apps.Manager.Api.Model; +using ModpackUpdater.Manager; + +namespace ModpackUpdater.Apps.Manager.Ui; + +public partial class UpdatesCollectorWindow : Window +{ + public record ModUpdateInfo(KeyValuePair[] AvailableVersions, InstallAction Origin) + { + public int NewVersion { get; set; } = 0; + } + + public record ModUpdates(List List); + + private readonly IWorkspace workspace; + private readonly ModpackFactory factory = new(); + private readonly InstallAction[] actions; + + public ModUpdates? CurrentUpdates { get; private set; } + public ModUpdateInfo? SelectedUpdate => radListView_Updates.SelectedItem?.Value as ModUpdateInfo; + public int SelectedVersion => radListView_VersionTags.SelectedIndex; + + public UpdatesCollectorWindow(IWorkspace workspace, params InstallAction[] actions) + { + this.workspace = workspace; + this.actions = actions; + + InitializeComponent(); + } +} \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/app.config b/ModpackUpdater.Apps.Manager/app.config deleted file mode 100644 index 61807c2..0000000 --- a/ModpackUpdater.Apps.Manager/app.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ModpackUpdater.Apps/AppGlobals.cs b/ModpackUpdater.Apps/AppGlobals.cs index 21fb39b..0b82110 100644 --- a/ModpackUpdater.Apps/AppGlobals.cs +++ b/ModpackUpdater.Apps/AppGlobals.cs @@ -1,24 +1,20 @@ -using ModpackUpdater.Apps.Manager; -using Pilz.UI.WinForms.Telerik.Dialogs; -using Pilz.UI.WinForms.Telerik.Symbols; -using Pilz.UI.WinForms.Telerik.Theming; -using Telerik.WinControls.Themes; +using Pilz.UI.AvaloniaUI.Symbols; namespace ModpackUpdater.Apps; public static class AppGlobals { - public static IRadSymbolFactory Symbols { get; } = new AppSymbolFactory(); + public static ISymbolFactory Symbols { get; } = new AppSymbolFactory(); public static void Initialize() { - ThemeHelper.ApplyApplicationTheme(new ThemeDefinition(ApplicationTheme.Auto, HighContrastMode.Auto), n => n.Theme switch - { - ApplicationTheme.Light => new Windows11CompactTheme(), - ApplicationTheme.Gray or ApplicationTheme.Dark => new Windows11CompactDarkTheme(), - _ => throw new NotImplementedException(), - }); - RadFlyoutBase.ConfirmSvg = Symbols.GetSvgImage(AppSymbols.checkmark, Pilz.UI.Symbols.SymbolSize.Small); - RadFlyoutBase.CancelSvg = Symbols.GetSvgImage(AppSymbols.cancel, Pilz.UI.Symbols.SymbolSize.Small); + // ThemeHelper.ApplyApplicationTheme(new ThemeDefinition(ApplicationTheme.Auto, HighContrastMode.Auto), n => n.Theme switch + // { + // ApplicationTheme.Light => new Windows11CompactTheme(), + // ApplicationTheme.Gray or ApplicationTheme.Dark => new Windows11CompactDarkTheme(), + // _ => throw new NotImplementedException(), + // }); + // RadFlyoutBase.ConfirmSvg = Symbols.GetSvgImage(AppSymbols.checkmark, Pilz.UI.Symbols.SymbolSize.Small); + // RadFlyoutBase.CancelSvg = Symbols.GetSvgImage(AppSymbols.cancel, Pilz.UI.Symbols.SymbolSize.Small); } } diff --git a/ModpackUpdater.Apps/AppSymbolFactory.cs b/ModpackUpdater.Apps/AppSymbolFactory.cs index 77ab514..7f43b31 100644 --- a/ModpackUpdater.Apps/AppSymbolFactory.cs +++ b/ModpackUpdater.Apps/AppSymbolFactory.cs @@ -1,9 +1,9 @@ -using Pilz.UI.WinForms.Telerik.Symbols; -using System.Reflection; +using System.Reflection; +using Pilz.UI.AvaloniaUI.Symbols; -namespace ModpackUpdater.Apps.Manager; +namespace ModpackUpdater.Apps; -internal class AppSymbolFactory : RadSymbolFactory +internal class AppSymbolFactory : SymbolFactory { public override Assembly GetImageResourceAssembly() { diff --git a/ModpackUpdater.Apps/ModpackUpdater.Apps.csproj b/ModpackUpdater.Apps/ModpackUpdater.Apps.csproj index 3196552..87d8763 100644 --- a/ModpackUpdater.Apps/ModpackUpdater.Apps.csproj +++ b/ModpackUpdater.Apps/ModpackUpdater.Apps.csproj @@ -1,20 +1,33 @@  - net8.0-windows - enable - enable + true + true + true + + + + + - - - + + + + + + + + + None + All + diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 18c857d..1999a99 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -58,7 +58,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf return result; } - if (modpackInfo == null || !Directory.Exists(modpackInfo.LocaLPath)) + if (modpackInfo == null || !Directory.Exists(modpackInfo.LocalPath)) { result.HasError = true; return result; @@ -168,7 +168,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf foreach (InstallAction iaction in checkResult.Actions) { - var destFilePath = iaction.GetDestPath(modpackInfo.LocaLPath); + var destFilePath = iaction.GetDestPath(modpackInfo.LocalPath); var sourceUrl = updateConfig.PreferDirectLinks && !string.IsNullOrWhiteSpace(iaction.SourceUrl) ? iaction.GetSourceUrl(checkResult.LatestVersion, overwriteVersion: OverwriteVersion) : await factory.ResolveSourceUrl(iaction, targetVersion: checkResult.LatestVersion, overwriteVersion: OverwriteVersion); @@ -194,7 +194,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf break; case UpdateActionType.Copy: { - var srcFilePath = Path.Combine(modpackInfo.LocaLPath, uaction.SrcPath); + var srcFilePath = Path.Combine(modpackInfo.LocalPath, uaction.SrcPath); if (uaction.IsDirectory) { if (Directory.Exists(srcFilePath)) @@ -209,7 +209,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf break; case UpdateActionType.Move: { - var srcFilePath = Path.Combine(modpackInfo.LocaLPath, uaction.SrcPath); + var srcFilePath = Path.Combine(modpackInfo.LocalPath, uaction.SrcPath); if (uaction.IsDirectory) { if (Directory.Exists(srcFilePath)) diff --git a/ModpackUpdater.sln b/ModpackUpdater.sln index 54645c8..90cea92 100644 --- a/ModpackUpdater.sln +++ b/ModpackUpdater.sln @@ -19,8 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps", "Modp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.Client", "ModpackUpdater.Apps.Client\ModpackUpdater.Apps.Client.csproj", "{415A7854-C358-4DCD-8C9E-D8413097A06D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.AppUpdates", "ModpackUpdater.Apps.AppUpdates\ModpackUpdater.Apps.AppUpdates.csproj", "{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,10 +49,6 @@ Global {415A7854-C358-4DCD-8C9E-D8413097A06D}.Debug|Any CPU.Build.0 = Debug|Any CPU {415A7854-C358-4DCD-8C9E-D8413097A06D}.Release|Any CPU.ActiveCfg = Release|Any CPU {415A7854-C358-4DCD-8C9E-D8413097A06D}.Release|Any CPU.Build.0 = Release|Any CPU - {7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -66,7 +60,6 @@ Global {227A37AA-73F0-431D-B976-B9B3A8ADD8C2} = {743892CF-E482-4FBD-9BAB-02920C140F2B} {EF2EAFAF-01CD-46BD-BE45-0125B51316A4} = {743892CF-E482-4FBD-9BAB-02920C140F2B} {415A7854-C358-4DCD-8C9E-D8413097A06D} = {743892CF-E482-4FBD-9BAB-02920C140F2B} - {7D8F9265-7BAC-4541-A6A8-168F45D0EA56} = {743892CF-E482-4FBD-9BAB-02920C140F2B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {322E6A6B-9F3E-4E88-8945-C98A9EF613BF} diff --git a/ModpackUpdater/ModpackConfig.cs b/ModpackUpdater/ModpackConfig.cs index 9d53935..c95841e 100644 --- a/ModpackUpdater/ModpackConfig.cs +++ b/ModpackUpdater/ModpackConfig.cs @@ -6,25 +6,25 @@ namespace ModpackUpdater; public class ModpackConfig { public bool Maintenance { get; set; } - public string Name { get; set; } - public string UpdateUrl { get; set; } - public string InstallUrl { get; set; } - public string UnleashApiUrl { get; set; } - public string UnleashInstanceId { get; set; } + public string? Name { get; set; } + public string? UpdateUrl { get; set; } + public string? InstallUrl { get; set; } + public string? UnleashApiUrl { get; set; } + public string? UnleashInstanceId { get; set; } public bool PreferDirectLinks { get; set; } - public string MinecraftVersion { get; set; } - public string RefTag { get; set; } + public string? MinecraftVersion { get; set; } + public string? RefTag { get; set; } [JsonConverter(typeof(StringEnumConverter))] public ModLoader ModLoader { get; set; } [JsonIgnore] - public string ConfigUrl { get; private set; } + public string? ConfigUrl { get; private set; } - public static ModpackConfig LoadFromUrl(string url) + public static ModpackConfig LoadFromUrl(string? url) { var result = new HttpClient().GetStringAsync(url).Result; - var config = JsonConvert.DeserializeObject(result); + var config = JsonConvert.DeserializeObject(result) ?? new(); config.ConfigUrl = url; return config; } diff --git a/ModpackUpdater/ModpackInfo.cs b/ModpackUpdater/ModpackInfo.cs index bfa9a80..c749056 100644 --- a/ModpackUpdater/ModpackInfo.cs +++ b/ModpackUpdater/ModpackInfo.cs @@ -9,41 +9,42 @@ public class ModpackInfo private const string FILENAME_MODPACKINFO = "modpack-info.json"; [JsonConverter(typeof(VersionConverter))] - public Version Version { get; set; } - public string ConfigUrl { get; set; } - public string ExtrasKey { get; set; } + public Version? Version { get; set; } + public string? ConfigUrl { get; set; } + public string? ExtrasKey { get; set; } public InstallOptionValueDictionary Options { get; } = []; [JsonIgnore] - public string LocaLPath { get; private set; } + public string? LocalPath { get; private set; } [JsonIgnore] - public bool Exists => File.Exists(GetFilePath(LocaLPath)); + public bool Exists => LocalPath != null && File.Exists(GetFilePath(LocalPath)); public void Save() { - File.WriteAllText(GetFilePath(LocaLPath), JsonConvert.SerializeObject(this)); + if (LocalPath != null) + File.WriteAllText(GetFilePath(LocalPath), JsonConvert.SerializeObject(this)); } public void Save(string mcRoot) { - LocaLPath = mcRoot; + LocalPath = mcRoot; Save(); } - public static ModpackInfo TryLoad(string mcRoot) + public static ModpackInfo TryLoad(string? mcRoot) { - if (HasModpackInfo(mcRoot)) + if (mcRoot != null && HasModpackInfo(mcRoot)) return Load(mcRoot); return new() { - LocaLPath = mcRoot + LocalPath = mcRoot }; } public static ModpackInfo Load(string mcRoot) { - var info = JsonConvert.DeserializeObject(File.ReadAllText(GetFilePath(mcRoot))); - info.LocaLPath = mcRoot; + var info = JsonConvert.DeserializeObject(File.ReadAllText(GetFilePath(mcRoot))) ?? new(); + info.LocalPath = mcRoot; return info; }