diff --git a/ModpackUpdater.Apps.Manager/App.axaml b/ModpackUpdater.Apps.Manager/App.axaml index 7d2cc14..58d3f76 100644 --- a/ModpackUpdater.Apps.Manager/App.axaml +++ b/ModpackUpdater.Apps.Manager/App.axaml @@ -8,5 +8,6 @@ + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Assets/Styles/StylesEnhancedDefaults.axaml b/ModpackUpdater.Apps.Manager/Assets/Styles/StylesEnhancedDefaults.axaml new file mode 100644 index 0000000..d998721 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Assets/Styles/StylesEnhancedDefaults.axaml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/ModpackUpdater.Apps.Manager/FodyWeavers.xml b/ModpackUpdater.Apps.Manager/FodyWeavers.xml new file mode 100644 index 0000000..51e2003 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ 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 4d10fac..deb4ce8 100644 --- a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj +++ b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj @@ -3,7 +3,6 @@ WinExe Assets\app.ico - MinecraftModpackUpdateManager true true true @@ -22,6 +21,7 @@ + @@ -42,6 +42,7 @@ None All + diff --git a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml index 0f847ac..75a8626 100644 --- a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml +++ b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml @@ -6,8 +6,10 @@ xmlns:modpackUpdater="clr-namespace:ModpackUpdater;assembly=ModpackUpdater" xmlns:local="clr-namespace:ModpackUpdater.Apps.Manager.Ui" xmlns:manager="clr-namespace:ModpackUpdater.Apps.Manager" + xmlns:vm="clr-namespace:ModpackUpdater.Apps.Manager.Ui.Models" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow" + x:DataType="vm:MainWindowViewModel" Title="Minecraft Modpack Manager" Padding="3"> @@ -47,19 +49,51 @@ Grid.Column="0" Margin="3"/> - + + + + + + + + + + + + + + - + + Spacing="6" + IsVisible="{Binding IsUpdate}"> @@ -69,7 +103,9 @@ @@ -100,11 +135,15 @@ @@ -134,12 +172,13 @@ - + @@ -155,37 +194,48 @@ ItemsSource="{x:Static local:MainWindow.SourceTypes}" DisplayMemberBinding="{Binding Value}" SelectedValueBinding="{Binding Key}" - SelectedValue="{Binding SourceType, DataType=modpackUpdater:InstallAction}"/> + SelectedValue="{Binding SourceType}"/> + IsChecked="{Binding IsZip}"/> diff --git a/ModpackUpdater.Apps.Manager/Ui/Models/InstallActionViewModel.cs b/ModpackUpdater.Apps.Manager/Ui/Models/InstallActionViewModel.cs new file mode 100644 index 0000000..9a37cbe --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/Models/InstallActionViewModel.cs @@ -0,0 +1,180 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace ModpackUpdater.Apps.Manager.Ui.Models; + +public class InstallActionViewModel(InstallAction action, IActionSet baseActions) : INotifyPropertyChanged +{ + #region Implementation of INotifyPropertyChanged + + public event PropertyChangedEventHandler? PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion Implementation of INotifyPropertyChanged + + public static Dictionary SourceTypes { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); + public static Dictionary Sides { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); + public static Dictionary UpdateActionTypes { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); + + public InstallAction Action => action; + private InstallAction? Base => action is UpdateAction ua ? baseActions.Actions.FirstOrDefault(n => n.Id == ua.InheritFrom) : null; + private InstallAction Inherited => Base ?? action; + + public bool IsUpdate => action is UpdateAction; + + public string InheritedId => action is UpdateAction ua && !string.IsNullOrWhiteSpace(ua.InheritFrom) ? ua.InheritFrom : action.Id; + public string InheritedSide => Sides[Inherited.Side]; + public string InheritedUpdateType => action is UpdateAction ua ? UpdateActionTypes[ua.Type] : string.Empty; + public string InheritedSourceType => SourceTypes[Inherited.SourceType]; + public string InheritedDestPath => Inherited.DestPath; + + public string Id + { + get => action.Id; + set + { + action.Id = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(InheritedId)); + } + } + + public string Name + { + get => action.Name; + set => action.Name = value; + } + + public string Website + { + get => action.Website; + set => action.Website = value; + } + + public bool IsZip + { + get => action.IsZip; + set => action.IsZip = value; + } + + public string ZipPath + { + get => action.ZipPath; + set => action.ZipPath = value; + } + + public string DestPath + { + get => action.DestPath; + set + { + action.DestPath = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(InheritedDestPath)); + } + } + + public string SourceUrl + { + get => action.SourceUrl; + set => action.SourceUrl = value; + } + + public SourceType SourceType + { + get => action.SourceType; + set + { + action.SourceType = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(InheritedSourceType)); + } + } + + public string SourceOwner + { + get => action.SourceOwner; + set => action.SourceOwner = value; + } + + public string SourceName + { + get => action.SourceName; + set => action.SourceName = value; + } + + public string SourceRegex + { + get => action.SourceRegex; + set => action.SourceRegex = value; + } + + public string SourceTag + { + get => action.SourceTag; + set => action.SourceTag = value; + } + + public Side Side + { + get => action.Side; + set + { + action.Side = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(InheritedSide)); + } + } + + public bool IsExtra + { + get => action.IsExtra; + set => action.IsExtra = value; + } + + public UpdateActionType Type + { + get => action is UpdateAction ua ? ua.Type : default; + set + { + if (action is UpdateAction ua) + ua.Type = value; + } + } + + public string SrcPath + { + get => action is UpdateAction ua ? ua.SrcPath : string.Empty; + set + { + if (action is UpdateAction ua) + ua.SrcPath = value; + } + } + + public bool IsDirectory + { + get => action is UpdateAction ua && ua.IsDirectory; + set + { + if (action is UpdateAction ua) + ua.IsDirectory = value; + } + } + + public string InheritFrom + { + get => action is UpdateAction ua ? ua.InheritFrom : string.Empty; + set + { + if (action is UpdateAction ua) + ua.InheritFrom = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(InheritedId)); + } + } +} \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowViewModel.cs b/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowViewModel.cs new file mode 100644 index 0000000..5f60ae2 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowViewModel.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace ModpackUpdater.Apps.Manager.Ui.Models; + +public class MainWindowViewModel : INotifyPropertyChanged +{ + #region Implementation of INotifyPropertyChanged + + public event PropertyChangedEventHandler? PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion Implementation of INotifyPropertyChanged + + public bool IsUpdate { get; set; } + + public List Actions { get; } = []; + + public InstallActionViewModel? SelectedAction { get; set; } +} \ No newline at end of file diff --git a/ModpackUpdater/InstallAction.cs b/ModpackUpdater/InstallAction.cs index bca679e..9aaabad 100644 --- a/ModpackUpdater/InstallAction.cs +++ b/ModpackUpdater/InstallAction.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.ComponentModel; +using System.Runtime.CompilerServices; namespace ModpackUpdater;