From 9ecb6394a3edf68840197d28ed0275f6ee0bb2ed Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:43:23 +1000 Subject: [PATCH 01/23] Add HUDMerger.Core --- src/HUDMerger.Core/HUDMerger.Core.csproj | 13 +++++++++++++ src/HUDMerger.sln | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/HUDMerger.Core/HUDMerger.Core.csproj diff --git a/src/HUDMerger.Core/HUDMerger.Core.csproj b/src/HUDMerger.Core/HUDMerger.Core.csproj new file mode 100644 index 0000000..04f9f98 --- /dev/null +++ b/src/HUDMerger.Core/HUDMerger.Core.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + HUDMerger.Core + enable + + + + + + + diff --git a/src/HUDMerger.sln b/src/HUDMerger.sln index 06b276e..2cfd572 100644 --- a/src/HUDMerger.sln +++ b/src/HUDMerger.sln @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HUDAnimations", "HUDAnimati EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HUDAnimationsTests", "HUDAnimationsTests\HUDAnimationsTests.csproj", "{4E30AF72-1594-41C3-9732-4CD3F4494112}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HUDMerger.Core", "HUDMerger.Core\HUDMerger.Core.csproj", "{BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -83,6 +85,18 @@ Global {4E30AF72-1594-41C3-9732-4CD3F4494112}.Release|x64.Build.0 = Release|Any CPU {4E30AF72-1594-41C3-9732-4CD3F4494112}.Release|x86.ActiveCfg = Release|Any CPU {4E30AF72-1594-41C3-9732-4CD3F4494112}.Release|x86.Build.0 = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|x64.ActiveCfg = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|x64.Build.0 = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|x86.ActiveCfg = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Debug|x86.Build.0 = Debug|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|Any CPU.Build.0 = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|x64.ActiveCfg = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|x64.Build.0 = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|x86.ActiveCfg = Release|Any CPU + {BCD71204-8FEC-4B6C-A264-FBB6AB5C6CDB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 8bb25a4f1a3b68a2670b3c6464b9bcb9211c53aa Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:46:11 +1000 Subject: [PATCH 02/23] Move Models to HUDMerger.Core --- src/HUDMerger.Core/HUDMerger.Core.csproj | 5 +++++ src/{HUDMerger => HUDMerger.Core}/Models/Dependencies.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/FilesHashSet.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/HUD.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/HUDLayout.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/HUDPanel.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/KeyValueLocation.cs | 2 +- .../Models/Scheme/ClientScheme.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/Scheme/IScheme.cs | 2 +- .../Models/Scheme/SchemeBase.cs | 2 +- .../Models/Scheme/SourceScheme.cs | 2 +- .../Models/SchemeDependencies.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/Settings.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Models/VPK.cs | 2 +- 14 files changed, 18 insertions(+), 13 deletions(-) rename src/{HUDMerger => HUDMerger.Core}/Models/Dependencies.cs (99%) rename src/{HUDMerger => HUDMerger.Core}/Models/FilesHashSet.cs (96%) rename src/{HUDMerger => HUDMerger.Core}/Models/HUD.cs (99%) rename src/{HUDMerger => HUDMerger.Core}/Models/HUDLayout.cs (98%) rename src/{HUDMerger => HUDMerger.Core}/Models/HUDPanel.cs (90%) rename src/{HUDMerger => HUDMerger.Core}/Models/KeyValueLocation.cs (91%) rename src/{HUDMerger => HUDMerger.Core}/Models/Scheme/ClientScheme.cs (91%) rename src/{HUDMerger => HUDMerger.Core}/Models/Scheme/IScheme.cs (93%) rename src/{HUDMerger => HUDMerger.Core}/Models/Scheme/SchemeBase.cs (99%) rename src/{HUDMerger => HUDMerger.Core}/Models/Scheme/SourceScheme.cs (91%) rename src/{HUDMerger => HUDMerger.Core}/Models/SchemeDependencies.cs (94%) rename src/{HUDMerger => HUDMerger.Core}/Models/Settings.cs (81%) rename src/{HUDMerger => HUDMerger.Core}/Models/VPK.cs (99%) diff --git a/src/HUDMerger.Core/HUDMerger.Core.csproj b/src/HUDMerger.Core/HUDMerger.Core.csproj index 04f9f98..0eacaf4 100644 --- a/src/HUDMerger.Core/HUDMerger.Core.csproj +++ b/src/HUDMerger.Core/HUDMerger.Core.csproj @@ -10,4 +10,9 @@ + + + + + diff --git a/src/HUDMerger/Models/Dependencies.cs b/src/HUDMerger.Core/Models/Dependencies.cs similarity index 99% rename from src/HUDMerger/Models/Dependencies.cs rename to src/HUDMerger.Core/Models/Dependencies.cs index fe620c1..69d9767 100644 --- a/src/HUDMerger/Models/Dependencies.cs +++ b/src/HUDMerger.Core/Models/Dependencies.cs @@ -8,7 +8,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public class Dependencies { diff --git a/src/HUDMerger/Models/FilesHashSet.cs b/src/HUDMerger.Core/Models/FilesHashSet.cs similarity index 96% rename from src/HUDMerger/Models/FilesHashSet.cs rename to src/HUDMerger.Core/Models/FilesHashSet.cs index 2372b0c..b300dd9 100644 --- a/src/HUDMerger/Models/FilesHashSet.cs +++ b/src/HUDMerger.Core/Models/FilesHashSet.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public class FilesHashSet : HashSet { diff --git a/src/HUDMerger/Models/HUD.cs b/src/HUDMerger.Core/Models/HUD.cs similarity index 99% rename from src/HUDMerger/Models/HUD.cs rename to src/HUDMerger.Core/Models/HUD.cs index 3de6777..6409742 100644 --- a/src/HUDMerger/Models/HUD.cs +++ b/src/HUDMerger.Core/Models/HUD.cs @@ -15,7 +15,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; /// /// Represents a custom HUD diff --git a/src/HUDMerger/Models/HUDLayout.cs b/src/HUDMerger.Core/Models/HUDLayout.cs similarity index 98% rename from src/HUDMerger/Models/HUDLayout.cs rename to src/HUDMerger.Core/Models/HUDLayout.cs index 36bbe5d..7bcc413 100644 --- a/src/HUDMerger/Models/HUDLayout.cs +++ b/src/HUDMerger.Core/Models/HUDLayout.cs @@ -7,7 +7,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public class HUDLayout { diff --git a/src/HUDMerger/Models/HUDPanel.cs b/src/HUDMerger.Core/Models/HUDPanel.cs similarity index 90% rename from src/HUDMerger/Models/HUDPanel.cs rename to src/HUDMerger.Core/Models/HUDPanel.cs index e1a3170..5d329b4 100644 --- a/src/HUDMerger/Models/HUDPanel.cs +++ b/src/HUDMerger.Core/Models/HUDPanel.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public record class HUDPanel { diff --git a/src/HUDMerger/Models/KeyValueLocation.cs b/src/HUDMerger.Core/Models/KeyValueLocation.cs similarity index 91% rename from src/HUDMerger/Models/KeyValueLocation.cs rename to src/HUDMerger.Core/Models/KeyValueLocation.cs index dde3501..b23c50c 100644 --- a/src/HUDMerger/Models/KeyValueLocation.cs +++ b/src/HUDMerger.Core/Models/KeyValueLocation.cs @@ -1,6 +1,6 @@ using System; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; /// /// Stores a file and key path to a Key/Value diff --git a/src/HUDMerger/Models/Scheme/ClientScheme.cs b/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs similarity index 91% rename from src/HUDMerger/Models/Scheme/ClientScheme.cs rename to src/HUDMerger.Core/Models/Scheme/ClientScheme.cs index 775dbc7..4f2b7e3 100644 --- a/src/HUDMerger/Models/Scheme/ClientScheme.cs +++ b/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs @@ -2,7 +2,7 @@ using HUDMerger.Services; using VDF.Models; -namespace HUDMerger.Models.Scheme; +namespace HUDMerger.Core.Models.Scheme; public class ClientScheme : SchemeBase { diff --git a/src/HUDMerger/Models/Scheme/IScheme.cs b/src/HUDMerger.Core/Models/Scheme/IScheme.cs similarity index 93% rename from src/HUDMerger/Models/Scheme/IScheme.cs rename to src/HUDMerger.Core/Models/Scheme/IScheme.cs index a36fe79..031f077 100644 --- a/src/HUDMerger/Models/Scheme/IScheme.cs +++ b/src/HUDMerger.Core/Models/Scheme/IScheme.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using VDF.Models; -namespace HUDMerger.Models.Scheme; +namespace HUDMerger.Core.Models.Scheme; public interface IScheme { diff --git a/src/HUDMerger/Models/Scheme/SchemeBase.cs b/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs similarity index 99% rename from src/HUDMerger/Models/Scheme/SchemeBase.cs rename to src/HUDMerger.Core/Models/Scheme/SchemeBase.cs index c0b13d3..446fac1 100644 --- a/src/HUDMerger/Models/Scheme/SchemeBase.cs +++ b/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs @@ -7,7 +7,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Models.Scheme; +namespace HUDMerger.Core.Models.Scheme; public abstract class SchemeBase : IScheme { diff --git a/src/HUDMerger/Models/Scheme/SourceScheme.cs b/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs similarity index 91% rename from src/HUDMerger/Models/Scheme/SourceScheme.cs rename to src/HUDMerger.Core/Models/Scheme/SourceScheme.cs index 9cd2ebb..14d4658 100644 --- a/src/HUDMerger/Models/Scheme/SourceScheme.cs +++ b/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs @@ -2,7 +2,7 @@ using HUDMerger.Services; using VDF.Models; -namespace HUDMerger.Models.Scheme; +namespace HUDMerger.Core.Models.Scheme; public class SourceScheme : SchemeBase { diff --git a/src/HUDMerger/Models/SchemeDependencies.cs b/src/HUDMerger.Core/Models/SchemeDependencies.cs similarity index 94% rename from src/HUDMerger/Models/SchemeDependencies.cs rename to src/HUDMerger.Core/Models/SchemeDependencies.cs index df0eaca..07225cb 100644 --- a/src/HUDMerger/Models/SchemeDependencies.cs +++ b/src/HUDMerger.Core/Models/SchemeDependencies.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public class SchemeDependencies { diff --git a/src/HUDMerger/Models/Settings.cs b/src/HUDMerger.Core/Models/Settings.cs similarity index 81% rename from src/HUDMerger/Models/Settings.cs rename to src/HUDMerger.Core/Models/Settings.cs index 9081698..fc37317 100644 --- a/src/HUDMerger/Models/Settings.cs +++ b/src/HUDMerger.Core/Models/Settings.cs @@ -1,6 +1,6 @@ using System; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; public class Settings { diff --git a/src/HUDMerger/Models/VPK.cs b/src/HUDMerger.Core/Models/VPK.cs similarity index 99% rename from src/HUDMerger/Models/VPK.cs rename to src/HUDMerger.Core/Models/VPK.cs index 28b4b8d..38d7522 100644 --- a/src/HUDMerger/Models/VPK.cs +++ b/src/HUDMerger.Core/Models/VPK.cs @@ -5,7 +5,7 @@ using System.Text.RegularExpressions; using HUDMerger.Extensions; -namespace HUDMerger.Models; +namespace HUDMerger.Core.Models; /// /// https://developer.valvesoftware.com/wiki/VPK_(file_format) From 0baa23826d2a5a27edac9ada51c727026f539c78 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:47:30 +1000 Subject: [PATCH 03/23] Move ViewModels to HUDMerger.Core --- .../ViewModels/AboutWindowViewModel.cs | 2 +- .../ViewModels/HUDInfoViewModel.cs | 2 +- .../ViewModels/HUDPanelViewModel.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 2 +- .../ViewModels/SelectHUDViewModel.cs | 2 +- .../ViewModels/SettingsWindowViewModel.cs | 2 +- .../ViewModels/SourceHUDPanelsListViewModel.cs | 2 +- .../ViewModels/TargetHUDPanelsListViewModel.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/ViewModels/ViewModelBase.cs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/AboutWindowViewModel.cs (94%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/HUDInfoViewModel.cs (93%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/HUDPanelViewModel.cs (93%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/MainWindowViewModel.cs (99%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/SelectHUDViewModel.cs (83%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/SettingsWindowViewModel.cs (97%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/SourceHUDPanelsListViewModel.cs (96%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/TargetHUDPanelsListViewModel.cs (93%) rename src/{HUDMerger => HUDMerger.Core}/ViewModels/ViewModelBase.cs (94%) diff --git a/src/HUDMerger/ViewModels/AboutWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/AboutWindowViewModel.cs similarity index 94% rename from src/HUDMerger/ViewModels/AboutWindowViewModel.cs rename to src/HUDMerger.Core/ViewModels/AboutWindowViewModel.cs index a0cb492..b1f8c84 100644 --- a/src/HUDMerger/ViewModels/AboutWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/AboutWindowViewModel.cs @@ -3,7 +3,7 @@ using System.Windows.Input; using Microsoft.Toolkit.Mvvm.Input; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class AboutWindowViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/HUDInfoViewModel.cs b/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs similarity index 93% rename from src/HUDMerger/ViewModels/HUDInfoViewModel.cs rename to src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs index 447ad58..e558e3e 100644 --- a/src/HUDMerger/ViewModels/HUDInfoViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs @@ -1,7 +1,7 @@ using System; using HUDMerger.Models; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class HUDInfoViewModel(string locationType, HUD? hud) : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/HUDPanelViewModel.cs b/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs similarity index 93% rename from src/HUDMerger/ViewModels/HUDPanelViewModel.cs rename to src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs index e68b187..225b879 100644 --- a/src/HUDMerger/ViewModels/HUDPanelViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs @@ -3,7 +3,7 @@ using HUDMerger.Models; using Microsoft.Toolkit.Mvvm.Input; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class HUDPanelViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs similarity index 99% rename from src/HUDMerger/ViewModels/MainWindowViewModel.cs rename to src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index b5f3bc2..83a7014 100644 --- a/src/HUDMerger/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -13,7 +13,7 @@ using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Win32; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class MainWindowViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/SelectHUDViewModel.cs b/src/HUDMerger.Core/ViewModels/SelectHUDViewModel.cs similarity index 83% rename from src/HUDMerger/ViewModels/SelectHUDViewModel.cs rename to src/HUDMerger.Core/ViewModels/SelectHUDViewModel.cs index 5422533..017526a 100644 --- a/src/HUDMerger/ViewModels/SelectHUDViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SelectHUDViewModel.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Input; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class SelectHUDViewModel(ICommand selectHUDCommand) : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/SettingsWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs similarity index 97% rename from src/HUDMerger/ViewModels/SettingsWindowViewModel.cs rename to src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs index 541185f..6b4b27c 100644 --- a/src/HUDMerger/ViewModels/SettingsWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs @@ -4,7 +4,7 @@ using HUDMerger.Models; using Microsoft.Toolkit.Mvvm.Input; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class SettingsWindowViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/SourceHUDPanelsListViewModel.cs b/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs similarity index 96% rename from src/HUDMerger/ViewModels/SourceHUDPanelsListViewModel.cs rename to src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs index 641bf00..df092bd 100644 --- a/src/HUDMerger/ViewModels/SourceHUDPanelsListViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using System.Windows.Data; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class SourceHUDPanelsListViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/TargetHUDPanelsListViewModel.cs b/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs similarity index 93% rename from src/HUDMerger/ViewModels/TargetHUDPanelsListViewModel.cs rename to src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs index b0a2237..95de40d 100644 --- a/src/HUDMerger/ViewModels/TargetHUDPanelsListViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using System.Windows.Data; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public class TargetHUDPanelsListViewModel : ViewModelBase { diff --git a/src/HUDMerger/ViewModels/ViewModelBase.cs b/src/HUDMerger.Core/ViewModels/ViewModelBase.cs similarity index 94% rename from src/HUDMerger/ViewModels/ViewModelBase.cs rename to src/HUDMerger.Core/ViewModels/ViewModelBase.cs index ab990c2..2d90ac2 100644 --- a/src/HUDMerger/ViewModels/ViewModelBase.cs +++ b/src/HUDMerger.Core/ViewModels/ViewModelBase.cs @@ -2,7 +2,7 @@ using System.ComponentModel; using System.Runtime.CompilerServices; -namespace HUDMerger.ViewModels; +namespace HUDMerger.Core.ViewModels; public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable { From 0ce1d66f2f59e0e875212f40fad9e1af0c1a45ea Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:48:59 +1000 Subject: [PATCH 04/23] Move Commands to HUDMerger.Core --- src/{HUDMerger => HUDMerger.Core}/Commands/CommandBase.cs | 2 +- src/{HUDMerger => HUDMerger.Core}/Commands/MergeCommand.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{HUDMerger => HUDMerger.Core}/Commands/CommandBase.cs (94%) rename src/{HUDMerger => HUDMerger.Core}/Commands/MergeCommand.cs (98%) diff --git a/src/HUDMerger/Commands/CommandBase.cs b/src/HUDMerger.Core/Commands/CommandBase.cs similarity index 94% rename from src/HUDMerger/Commands/CommandBase.cs rename to src/HUDMerger.Core/Commands/CommandBase.cs index 8d24d2b..1ed2c1a 100644 --- a/src/HUDMerger/Commands/CommandBase.cs +++ b/src/HUDMerger.Core/Commands/CommandBase.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Input; -namespace HUDMerger.Commands; +namespace HUDMerger.Core.Commands; public abstract class CommandBase : ICommand, IDisposable { diff --git a/src/HUDMerger/Commands/MergeCommand.cs b/src/HUDMerger.Core/Commands/MergeCommand.cs similarity index 98% rename from src/HUDMerger/Commands/MergeCommand.cs rename to src/HUDMerger.Core/Commands/MergeCommand.cs index 3a88718..d148e82 100644 --- a/src/HUDMerger/Commands/MergeCommand.cs +++ b/src/HUDMerger.Core/Commands/MergeCommand.cs @@ -7,7 +7,7 @@ using HUDMerger.Models; using HUDMerger.ViewModels; -namespace HUDMerger.Commands; +namespace HUDMerger.Core.Commands; public class MergeCommand : CommandBase { From 49735e61b809ec3d84c5c756bd71d0feeaa864e8 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:51:32 +1000 Subject: [PATCH 05/23] Move Exceptions to HUDMerger.Core --- src/{HUDMerger => HUDMerger.Core}/Exceptions/FileException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/{HUDMerger => HUDMerger.Core}/Exceptions/FileException.cs (88%) diff --git a/src/HUDMerger/Exceptions/FileException.cs b/src/HUDMerger.Core/Exceptions/FileException.cs similarity index 88% rename from src/HUDMerger/Exceptions/FileException.cs rename to src/HUDMerger.Core/Exceptions/FileException.cs index a220869..fc4fb43 100644 --- a/src/HUDMerger/Exceptions/FileException.cs +++ b/src/HUDMerger.Core/Exceptions/FileException.cs @@ -2,7 +2,7 @@ using HUDMerger.Models; using VDF.Exceptions; -namespace HUDMerger.Exceptions; +namespace HUDMerger.Core.Exceptions; public class FileException(HUD hud, string relativePath, VDFSyntaxException innerException) : Exception($"{hud.Name}: {App.PathSeparatorRegex().Replace(relativePath, "/")}: {innerException.Message}") { From 9dba941522dcc1bec417835f5c252a37eebe4ec9 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:52:15 +1000 Subject: [PATCH 06/23] Move Extensions to HUDMerger.Core --- .../Extensions/BinaryReaderExtensions.cs | 2 +- .../Extensions/HashSetExtensions.cs | 2 +- .../Extensions/KeyValuesExtensions.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/{HUDMerger => HUDMerger.Core}/Extensions/BinaryReaderExtensions.cs (90%) rename src/{HUDMerger => HUDMerger.Core}/Extensions/HashSetExtensions.cs (95%) rename src/{HUDMerger => HUDMerger.Core}/Extensions/KeyValuesExtensions.cs (98%) diff --git a/src/HUDMerger/Extensions/BinaryReaderExtensions.cs b/src/HUDMerger.Core/Extensions/BinaryReaderExtensions.cs similarity index 90% rename from src/HUDMerger/Extensions/BinaryReaderExtensions.cs rename to src/HUDMerger.Core/Extensions/BinaryReaderExtensions.cs index 975fe4f..e686117 100644 --- a/src/HUDMerger/Extensions/BinaryReaderExtensions.cs +++ b/src/HUDMerger.Core/Extensions/BinaryReaderExtensions.cs @@ -3,7 +3,7 @@ using System.IO; using System.Text; -namespace HUDMerger.Extensions; +namespace HUDMerger.Core.Extensions; public static class BinaryReaderExtensions { diff --git a/src/HUDMerger/Extensions/HashSetExtensions.cs b/src/HUDMerger.Core/Extensions/HashSetExtensions.cs similarity index 95% rename from src/HUDMerger/Extensions/HashSetExtensions.cs rename to src/HUDMerger.Core/Extensions/HashSetExtensions.cs index 98bb0da..f2d4211 100644 --- a/src/HUDMerger/Extensions/HashSetExtensions.cs +++ b/src/HUDMerger.Core/Extensions/HashSetExtensions.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using VDF.Models; -namespace HUDMerger.Extensions; +namespace HUDMerger.Core.Extensions; public static class HashSetExtensions { diff --git a/src/HUDMerger/Extensions/KeyValuesExtensions.cs b/src/HUDMerger.Core/Extensions/KeyValuesExtensions.cs similarity index 98% rename from src/HUDMerger/Extensions/KeyValuesExtensions.cs rename to src/HUDMerger.Core/Extensions/KeyValuesExtensions.cs index 667d66c..4d5999c 100644 --- a/src/HUDMerger/Extensions/KeyValuesExtensions.cs +++ b/src/HUDMerger.Core/Extensions/KeyValuesExtensions.cs @@ -4,7 +4,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Extensions; +namespace HUDMerger.Core.Extensions; public static class KeyValuesExtensions { From 226f230e6f48b41e95c3b8c30dd11d1127eb980a Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 14:58:52 +1000 Subject: [PATCH 07/23] Move Services to HUDMerger.Core --- .../Services/HUDFileReaderService.cs | 2 +- .../Services/HUDFileWriterService.cs | 2 +- .../Services/IHUDFileReaderService.cs | 2 +- .../Services/IHUDFileWriterService.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename src/{HUDMerger => HUDMerger.Core}/Services/HUDFileReaderService.cs (99%) rename src/{HUDMerger => HUDMerger.Core}/Services/HUDFileWriterService.cs (97%) rename src/{HUDMerger => HUDMerger.Core}/Services/IHUDFileReaderService.cs (93%) rename src/{HUDMerger => HUDMerger.Core}/Services/IHUDFileWriterService.cs (91%) diff --git a/src/HUDMerger/Services/HUDFileReaderService.cs b/src/HUDMerger.Core/Services/HUDFileReaderService.cs similarity index 99% rename from src/HUDMerger/Services/HUDFileReaderService.cs rename to src/HUDMerger.Core/Services/HUDFileReaderService.cs index 4af7ee8..b4c1998 100644 --- a/src/HUDMerger/Services/HUDFileReaderService.cs +++ b/src/HUDMerger.Core/Services/HUDFileReaderService.cs @@ -13,7 +13,7 @@ using VDF.Exceptions; using VDF.Models; -namespace HUDMerger.Services; +namespace HUDMerger.Core.Services; public enum FileType : byte { diff --git a/src/HUDMerger/Services/HUDFileWriterService.cs b/src/HUDMerger.Core/Services/HUDFileWriterService.cs similarity index 97% rename from src/HUDMerger/Services/HUDFileWriterService.cs rename to src/HUDMerger.Core/Services/HUDFileWriterService.cs index 545ceff..4236f62 100644 --- a/src/HUDMerger/Services/HUDFileWriterService.cs +++ b/src/HUDMerger.Core/Services/HUDFileWriterService.cs @@ -7,7 +7,7 @@ using VDF; using VDF.Models; -namespace HUDMerger.Services; +namespace HUDMerger.Core.Services; public class HUDFileWriterService(string folderPath) : IHUDFileWriterService { diff --git a/src/HUDMerger/Services/IHUDFileReaderService.cs b/src/HUDMerger.Core/Services/IHUDFileReaderService.cs similarity index 93% rename from src/HUDMerger/Services/IHUDFileReaderService.cs rename to src/HUDMerger.Core/Services/IHUDFileReaderService.cs index f8a47c5..9473846 100644 --- a/src/HUDMerger/Services/IHUDFileReaderService.cs +++ b/src/HUDMerger.Core/Services/IHUDFileReaderService.cs @@ -4,7 +4,7 @@ using HUDMerger.Models; using VDF.Models; -namespace HUDMerger.Services; +namespace HUDMerger.Core.Services; public interface IHUDFileReaderService { diff --git a/src/HUDMerger/Services/IHUDFileWriterService.cs b/src/HUDMerger.Core/Services/IHUDFileWriterService.cs similarity index 91% rename from src/HUDMerger/Services/IHUDFileWriterService.cs rename to src/HUDMerger.Core/Services/IHUDFileWriterService.cs index a405daf..7d6a192 100644 --- a/src/HUDMerger/Services/IHUDFileWriterService.cs +++ b/src/HUDMerger.Core/Services/IHUDFileWriterService.cs @@ -4,7 +4,7 @@ using HUDMerger.Models; using VDF.Models; -namespace HUDMerger.Services; +namespace HUDMerger.Core.Services; public interface IHUDFileWriterService { From 70c49da5c83d25d7802f74923a34a8f3e21389a9 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:04:45 +1000 Subject: [PATCH 08/23] Move Resources to HUDMerger.Core --- src/HUDMerger.Core/HUDMerger.Core.csproj | 6 ++++++ .../Resources/Dependencies.json | 0 src/{HUDMerger => HUDMerger.Core}/Resources/Panels.json | 0 3 files changed, 6 insertions(+) rename src/{HUDMerger => HUDMerger.Core}/Resources/Dependencies.json (100%) rename src/{HUDMerger => HUDMerger.Core}/Resources/Panels.json (100%) diff --git a/src/HUDMerger.Core/HUDMerger.Core.csproj b/src/HUDMerger.Core/HUDMerger.Core.csproj index 0eacaf4..b904748 100644 --- a/src/HUDMerger.Core/HUDMerger.Core.csproj +++ b/src/HUDMerger.Core/HUDMerger.Core.csproj @@ -15,4 +15,10 @@ + + + Always + + + diff --git a/src/HUDMerger/Resources/Dependencies.json b/src/HUDMerger.Core/Resources/Dependencies.json similarity index 100% rename from src/HUDMerger/Resources/Dependencies.json rename to src/HUDMerger.Core/Resources/Dependencies.json diff --git a/src/HUDMerger/Resources/Panels.json b/src/HUDMerger.Core/Resources/Panels.json similarity index 100% rename from src/HUDMerger/Resources/Panels.json rename to src/HUDMerger.Core/Resources/Panels.json From 60a36ff03f873232527863e91104b73e9c6afd36 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:08:55 +1000 Subject: [PATCH 09/23] Update Commands imports --- src/HUDMerger.Core/Commands/MergeCommand.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HUDMerger.Core/Commands/MergeCommand.cs b/src/HUDMerger.Core/Commands/MergeCommand.cs index d148e82..0751947 100644 --- a/src/HUDMerger.Core/Commands/MergeCommand.cs +++ b/src/HUDMerger.Core/Commands/MergeCommand.cs @@ -4,8 +4,8 @@ using System.IO; using System.Linq; using System.Windows; -using HUDMerger.Models; -using HUDMerger.ViewModels; +using HUDMerger.Core.Models; +using HUDMerger.Core.ViewModels; namespace HUDMerger.Core.Commands; From b5102f1a91a37a633a3df67963fb27638bfe2db0 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:09:08 +1000 Subject: [PATCH 10/23] Update Exceptions imports --- src/HUDMerger.Core/Exceptions/FileException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HUDMerger.Core/Exceptions/FileException.cs b/src/HUDMerger.Core/Exceptions/FileException.cs index fc4fb43..134038b 100644 --- a/src/HUDMerger.Core/Exceptions/FileException.cs +++ b/src/HUDMerger.Core/Exceptions/FileException.cs @@ -1,5 +1,5 @@ using System; -using HUDMerger.Models; +using HUDMerger.Core.Models; using VDF.Exceptions; namespace HUDMerger.Core.Exceptions; From 96ddbf4e13af5023a53de7c877efb1abb432f4af Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:10:31 +1000 Subject: [PATCH 11/23] Update Models imports --- src/HUDMerger.Core/Models/Dependencies.cs | 4 ++-- src/HUDMerger.Core/Models/HUD.cs | 8 ++++---- src/HUDMerger.Core/Models/HUDLayout.cs | 4 ++-- src/HUDMerger.Core/Models/Scheme/ClientScheme.cs | 2 +- src/HUDMerger.Core/Models/Scheme/SchemeBase.cs | 6 +++--- src/HUDMerger.Core/Models/Scheme/SourceScheme.cs | 2 +- src/HUDMerger.Core/Models/VPK.cs | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/HUDMerger.Core/Models/Dependencies.cs b/src/HUDMerger.Core/Models/Dependencies.cs index 69d9767..1eb664b 100644 --- a/src/HUDMerger.Core/Models/Dependencies.cs +++ b/src/HUDMerger.Core/Models/Dependencies.cs @@ -3,8 +3,8 @@ using System.IO; using System.Linq; using System.Text.Json; -using HUDMerger.Extensions; -using HUDMerger.Services; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Services; using VDF; using VDF.Models; diff --git a/src/HUDMerger.Core/Models/HUD.cs b/src/HUDMerger.Core/Models/HUD.cs index 6409742..4d48ef5 100644 --- a/src/HUDMerger.Core/Models/HUD.cs +++ b/src/HUDMerger.Core/Models/HUD.cs @@ -8,10 +8,10 @@ using System.Windows; using HUDAnimations.Models; using HUDAnimations.Models.Animations; -using HUDMerger.Exceptions; -using HUDMerger.Extensions; -using HUDMerger.Models.Scheme; -using HUDMerger.Services; +using HUDMerger.Core.Exceptions; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Models.Scheme; +using HUDMerger.Core.Services; using VDF; using VDF.Models; diff --git a/src/HUDMerger.Core/Models/HUDLayout.cs b/src/HUDMerger.Core/Models/HUDLayout.cs index 7bcc413..432c6a5 100644 --- a/src/HUDMerger.Core/Models/HUDLayout.cs +++ b/src/HUDMerger.Core/Models/HUDLayout.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using HUDMerger.Extensions; -using HUDMerger.Services; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Services; using VDF; using VDF.Models; diff --git a/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs b/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs index 4f2b7e3..e74c243 100644 --- a/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs +++ b/src/HUDMerger.Core/Models/Scheme/ClientScheme.cs @@ -1,5 +1,5 @@ using System; -using HUDMerger.Services; +using HUDMerger.Core.Services; using VDF.Models; namespace HUDMerger.Core.Models.Scheme; diff --git a/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs b/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs index 446fac1..84c72d6 100644 --- a/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs +++ b/src/HUDMerger.Core/Models/Scheme/SchemeBase.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using HUDMerger.Extensions; -using HUDMerger.Services; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Services; using VDF; using VDF.Models; @@ -326,7 +326,7 @@ static KeyValues ConvertSchemeToKeyValues(Dictionary dictionary) if (CustomFontFiles.Count != 0) { - List customFontFilesList = [..CustomFontFiles]; + List customFontFilesList = [.. CustomFontFiles]; customFontFilesList.Sort((a, b) => { if (int.TryParse(a.Key, out int first) && int.TryParse(b.Key, out int second)) diff --git a/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs b/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs index 14d4658..1253804 100644 --- a/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs +++ b/src/HUDMerger.Core/Models/Scheme/SourceScheme.cs @@ -1,5 +1,5 @@ using System; -using HUDMerger.Services; +using HUDMerger.Core.Services; using VDF.Models; namespace HUDMerger.Core.Models.Scheme; diff --git a/src/HUDMerger.Core/Models/VPK.cs b/src/HUDMerger.Core/Models/VPK.cs index 38d7522..3c182e3 100644 --- a/src/HUDMerger.Core/Models/VPK.cs +++ b/src/HUDMerger.Core/Models/VPK.cs @@ -3,7 +3,7 @@ using System.IO; using System.Text; using System.Text.RegularExpressions; -using HUDMerger.Extensions; +using HUDMerger.Core.Extensions; namespace HUDMerger.Core.Models; From 2f8481903a990fa07c5743472a10d700b8394ab0 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:11:07 +1000 Subject: [PATCH 12/23] Update Services imports --- src/HUDMerger.Core/Services/HUDFileReaderService.cs | 6 +++--- src/HUDMerger.Core/Services/HUDFileWriterService.cs | 2 +- src/HUDMerger.Core/Services/IHUDFileReaderService.cs | 2 +- src/HUDMerger.Core/Services/IHUDFileWriterService.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HUDMerger.Core/Services/HUDFileReaderService.cs b/src/HUDMerger.Core/Services/HUDFileReaderService.cs index b4c1998..2ac970a 100644 --- a/src/HUDMerger.Core/Services/HUDFileReaderService.cs +++ b/src/HUDMerger.Core/Services/HUDFileReaderService.cs @@ -6,9 +6,9 @@ using System.Windows; using HUDAnimations; using HUDAnimations.Models; -using HUDMerger.Exceptions; -using HUDMerger.Extensions; -using HUDMerger.Models; +using HUDMerger.Core.Exceptions; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Models; using VDF; using VDF.Exceptions; using VDF.Models; diff --git a/src/HUDMerger.Core/Services/HUDFileWriterService.cs b/src/HUDMerger.Core/Services/HUDFileWriterService.cs index 4236f62..f142964 100644 --- a/src/HUDMerger.Core/Services/HUDFileWriterService.cs +++ b/src/HUDMerger.Core/Services/HUDFileWriterService.cs @@ -3,7 +3,7 @@ using System.Text; using HUDAnimations; using HUDAnimations.Models; -using HUDMerger.Models; +using HUDMerger.Core.Models; using VDF; using VDF.Models; diff --git a/src/HUDMerger.Core/Services/IHUDFileReaderService.cs b/src/HUDMerger.Core/Services/IHUDFileReaderService.cs index 9473846..72b2fde 100644 --- a/src/HUDMerger.Core/Services/IHUDFileReaderService.cs +++ b/src/HUDMerger.Core/Services/IHUDFileReaderService.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using HUDAnimations.Models; -using HUDMerger.Models; +using HUDMerger.Core.Models; using VDF.Models; namespace HUDMerger.Core.Services; diff --git a/src/HUDMerger.Core/Services/IHUDFileWriterService.cs b/src/HUDMerger.Core/Services/IHUDFileWriterService.cs index 7d6a192..c6a2bab 100644 --- a/src/HUDMerger.Core/Services/IHUDFileWriterService.cs +++ b/src/HUDMerger.Core/Services/IHUDFileWriterService.cs @@ -1,7 +1,7 @@ using System; using System.Text; using HUDAnimations.Models; -using HUDMerger.Models; +using HUDMerger.Core.Models; using VDF.Models; namespace HUDMerger.Core.Services; From e14203c613bdd7940f784ecd3557a93d39d6c7d3 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:12:26 +1000 Subject: [PATCH 13/23] Update ViewModels imports --- src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs | 2 +- src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs | 2 +- src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs | 4 ++-- src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs b/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs index e558e3e..fbc06a3 100644 --- a/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/HUDInfoViewModel.cs @@ -1,5 +1,5 @@ using System; -using HUDMerger.Models; +using HUDMerger.Core.Models; namespace HUDMerger.Core.ViewModels; diff --git a/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs b/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs index 225b879..64f0fd7 100644 --- a/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/HUDPanelViewModel.cs @@ -1,6 +1,6 @@ using System; using System.Windows.Input; -using HUDMerger.Models; +using HUDMerger.Core.Models; using Microsoft.Toolkit.Mvvm.Input; namespace HUDMerger.Core.ViewModels; diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index 83a7014..c4ae35b 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -8,8 +8,8 @@ using System.Windows; using System.Windows.Input; using Discord; -using HUDMerger.Commands; -using HUDMerger.Models; +using HUDMerger.Core.Commands; +using HUDMerger.Core.Models; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Win32; diff --git a/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs index 6b4b27c..7a3c0d6 100644 --- a/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs @@ -1,7 +1,7 @@ using System; using System.Windows; using System.Windows.Input; -using HUDMerger.Models; +using HUDMerger.Core.Models; using Microsoft.Toolkit.Mvvm.Input; namespace HUDMerger.Core.ViewModels; From e190fe72b6b4d5bd0487d3bd1c6e97473896e71b Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sat, 6 Jul 2024 15:20:51 +1000 Subject: [PATCH 14/23] Update HUDMerger imports --- src/HUDMerger/App.xaml.cs | 6 +++--- src/HUDMerger/HUDMerger.csproj | 3 +-- src/HUDMerger/Views/AboutWindowView.xaml | 2 +- src/HUDMerger/Views/HUDInfoView.xaml | 2 +- src/HUDMerger/Views/HUDPanelView.xaml | 2 +- src/HUDMerger/Views/MainWindowView.xaml | 2 +- src/HUDMerger/Views/SettingsWindowView.xaml | 2 +- src/HUDMerger/Views/SourceHUDPanelsListView.xaml | 2 +- src/HUDMerger/Views/TargetHUDPanelsListView.xaml | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 792ffd8..35976e5 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -3,9 +3,9 @@ using System.Linq; using System.Text.RegularExpressions; using System.Windows; -using HUDMerger.Extensions; -using HUDMerger.Models; -using HUDMerger.ViewModels; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Models; +using HUDMerger.Core.ViewModels; using Microsoft.Win32; using VDF; using VDF.Models; diff --git a/src/HUDMerger/HUDMerger.csproj b/src/HUDMerger/HUDMerger.csproj index b6644c5..6793da2 100644 --- a/src/HUDMerger/HUDMerger.csproj +++ b/src/HUDMerger/HUDMerger.csproj @@ -13,9 +13,8 @@ + - - diff --git a/src/HUDMerger/Views/AboutWindowView.xaml b/src/HUDMerger/Views/AboutWindowView.xaml index f2a7557..1fb31ee 100644 --- a/src/HUDMerger/Views/AboutWindowView.xaml +++ b/src/HUDMerger/Views/AboutWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:AboutWindowViewModel}}"> diff --git a/src/HUDMerger/Views/HUDInfoView.xaml b/src/HUDMerger/Views/HUDInfoView.xaml index 9c1dd0d..0ec81c7 100644 --- a/src/HUDMerger/Views/HUDInfoView.xaml +++ b/src/HUDMerger/Views/HUDInfoView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" mc:Ignorable="d" d:DesignHeight="74" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:HUDInfoViewModel}}"> diff --git a/src/HUDMerger/Views/HUDPanelView.xaml b/src/HUDMerger/Views/HUDPanelView.xaml index cabab09..09e2172 100644 --- a/src/HUDMerger/Views/HUDPanelView.xaml +++ b/src/HUDMerger/Views/HUDPanelView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="31" d:DesignWidth="355" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:HUDPanelViewModel}}"> diff --git a/src/HUDMerger/Views/MainWindowView.xaml b/src/HUDMerger/Views/MainWindowView.xaml index fdcdb62..d811b9d 100644 --- a/src/HUDMerger/Views/MainWindowView.xaml +++ b/src/HUDMerger/Views/MainWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:MainWindowViewModel}}"> diff --git a/src/HUDMerger/Views/SettingsWindowView.xaml b/src/HUDMerger/Views/SettingsWindowView.xaml index acc2802..c8f4d2a 100644 --- a/src/HUDMerger/Views/SettingsWindowView.xaml +++ b/src/HUDMerger/Views/SettingsWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:SettingsWindowViewModel}}"> diff --git a/src/HUDMerger/Views/SourceHUDPanelsListView.xaml b/src/HUDMerger/Views/SourceHUDPanelsListView.xaml index 3f18304..af590b6 100644 --- a/src/HUDMerger/Views/SourceHUDPanelsListView.xaml +++ b/src/HUDMerger/Views/SourceHUDPanelsListView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="240" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:SourceHUDPanelsListViewModel}}"> diff --git a/src/HUDMerger/Views/TargetHUDPanelsListView.xaml b/src/HUDMerger/Views/TargetHUDPanelsListView.xaml index 7773ad9..5297b1a 100644 --- a/src/HUDMerger/Views/TargetHUDPanelsListView.xaml +++ b/src/HUDMerger/Views/TargetHUDPanelsListView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="240" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:TargetHUDPanelsListViewModel}}"> From e16193f6d581cd5a74efd3850bc872ef056d6e68 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sun, 7 Jul 2024 00:28:16 +1000 Subject: [PATCH 15/23] Move PathSeparatorRegex to HUDMerger.Core --- src/HUDMerger.Core/App.cs | 10 ++++++++++ src/HUDMerger/App.xaml.cs | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/HUDMerger.Core/App.cs diff --git a/src/HUDMerger.Core/App.cs b/src/HUDMerger.Core/App.cs new file mode 100644 index 0000000..b3aaa50 --- /dev/null +++ b/src/HUDMerger.Core/App.cs @@ -0,0 +1,10 @@ +using System; +using System.Text.RegularExpressions; + +namespace HUDMerger.Core; + +public partial class App +{ + [GeneratedRegex(@"[/\\]+", RegexOptions.Compiled)] + public static partial Regex PathSeparatorRegex(); +} diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 35976e5..9cabe2a 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -17,9 +17,6 @@ namespace HUDMerger; /// public partial class App : Application { - [GeneratedRegex(@"[/\\]+")] - public static partial Regex PathSeparatorRegex(); - public Lazy Settings = new(() => { string? teamFortress2Folder = null; From 609a1772b7fa2a6a2a82e8087d78f397b439eceb Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sun, 7 Jul 2024 00:43:21 +1000 Subject: [PATCH 16/23] Add FolderPickerService --- .../Services/IFolderPickerService.cs | 9 +++ .../ViewModels/MainWindowViewModel.cs | 69 ++++++++++--------- src/HUDMerger/App.xaml.cs | 3 +- src/HUDMerger/Services/FolderPickerService.cs | 30 ++++++++ 4 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 src/HUDMerger.Core/Services/IFolderPickerService.cs create mode 100644 src/HUDMerger/Services/FolderPickerService.cs diff --git a/src/HUDMerger.Core/Services/IFolderPickerService.cs b/src/HUDMerger.Core/Services/IFolderPickerService.cs new file mode 100644 index 0000000..4dd399d --- /dev/null +++ b/src/HUDMerger.Core/Services/IFolderPickerService.cs @@ -0,0 +1,9 @@ +using System; +using System.Threading.Tasks; + +namespace HUDMerger.Core.Services; + +public interface IFolderPickerService +{ + public Task PickFolderAsync(); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index c4ae35b..1827b14 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -10,17 +10,14 @@ using Discord; using HUDMerger.Core.Commands; using HUDMerger.Core.Models; +using HUDMerger.Core.Services; using Microsoft.Toolkit.Mvvm.Input; -using Microsoft.Win32; namespace HUDMerger.Core.ViewModels; public class MainWindowViewModel : ViewModelBase { - private static readonly OpenFolderDialog OpenFolderDialog = new() - { - InitialDirectory = Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf\\custom\\") - }; + private readonly IFolderPickerService FolderPickerService; private static readonly Channel<(string? sourceName, string? targetName)> DiscordChannel = Channel.CreateBounded<(string? sourceName, string? targetName)>(new BoundedChannelOptions(1) { FullMode = BoundedChannelFullMode.DropOldest }); @@ -86,10 +83,12 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel() + public MainWindowViewModel(IFolderPickerService folderPickerService) { - LoadSourceHUDCommand = new RelayCommand(LoadSourceHUD); - LoadTargetHUDCommand = new RelayCommand(LoadTargetHUD); + FolderPickerService = folderPickerService; + + LoadSourceHUDCommand = new AsyncRelayCommand(LoadSourceHUD); + LoadTargetHUDCommand = new AsyncRelayCommand(LoadTargetHUD); ShowSettingsWindowCommand = new RelayCommand(ShowSettingsWindow); QuitCommand = new RelayCommand(Application.Current.Shutdown); @@ -141,42 +140,48 @@ private void ShowAboutWindow() aboutWindow.Show(); } - private void LoadSourceHUD() + private async Task LoadSourceHUD() { - if (OpenFolderDialog.ShowDialog(Application.Current.MainWindow) == true) + string? folderName = await FolderPickerService.PickFolderAsync(); + if (folderName == null) { - SourceHUD = new HUD(OpenFolderDialog.FolderName); - SourceHUDInfoViewModel.HUD = SourceHUD; + return; + } - HUDPanelViewModels.Clear(); + SourceHUD = new HUD(folderName); + SourceHUDInfoViewModel.HUD = SourceHUD; - foreach (HUDPanel hudPanel in SourceHUD.Panels) - { - HUDPanelViewModel hudPanelViewModel = new(hudPanel); - hudPanelViewModel.PropertyChanged += HudPanelViewModel_PropertyChanged; - HUDPanelViewModels.Add(hudPanelViewModel); - } + HUDPanelViewModels.Clear(); - SourceHUDPanelsListViewModel?.Dispose(); - SourceHUDPanelsListViewModel = new SourceHUDPanelsListViewModel(HUDPanelViewModels); + foreach (HUDPanel hudPanel in SourceHUD.Panels) + { + HUDPanelViewModel hudPanelViewModel = new(hudPanel); + hudPanelViewModel.PropertyChanged += HudPanelViewModel_PropertyChanged; + HUDPanelViewModels.Add(hudPanelViewModel); + } - if (TargetHUDPanelsListViewModel is TargetHUDPanelsListViewModel targetHUDPanelsListViewModel) - { - targetHUDPanelsListViewModel.HUDPanelsCollectionView.Refresh(); - } + SourceHUDPanelsListViewModel?.Dispose(); + SourceHUDPanelsListViewModel = new SourceHUDPanelsListViewModel(HUDPanelViewModels); + + if (TargetHUDPanelsListViewModel is TargetHUDPanelsListViewModel targetHUDPanelsListViewModel) + { + targetHUDPanelsListViewModel.HUDPanelsCollectionView.Refresh(); } } - private void LoadTargetHUD() + private async Task LoadTargetHUD() { - if (OpenFolderDialog.ShowDialog(Application.Current.MainWindow) == true) + string? folderName = await FolderPickerService.PickFolderAsync(); + if (folderName == null) { - TargetHUD = new HUD(OpenFolderDialog.FolderName); - TargetHUDInfoViewModel.HUD = TargetHUD; - - TargetHUDPanelsListViewModel?.Dispose(); - TargetHUDPanelsListViewModel = new TargetHUDPanelsListViewModel(HUDPanelViewModels); + return; } + + TargetHUD = new HUD(folderName); + TargetHUDInfoViewModel.HUD = TargetHUD; + + TargetHUDPanelsListViewModel?.Dispose(); + TargetHUDPanelsListViewModel = new TargetHUDPanelsListViewModel(HUDPanelViewModels); } private void HudPanelViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 9cabe2a..1b22f2d 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -6,6 +6,7 @@ using HUDMerger.Core.Extensions; using HUDMerger.Core.Models; using HUDMerger.Core.ViewModels; +using HUDMerger.Services; using Microsoft.Win32; using VDF; using VDF.Models; @@ -111,7 +112,7 @@ protected override void OnStartup(StartupEventArgs e) MainWindow = new MainWindow { - DataContext = new MainWindowViewModel() + DataContext = new MainWindowViewModel(new FolderPickerService(HUDMerger.Properties.Settings.Default.TeamFortress2Folder)) }; MainWindow.Show(); diff --git a/src/HUDMerger/Services/FolderPickerService.cs b/src/HUDMerger/Services/FolderPickerService.cs new file mode 100644 index 0000000..88c2d13 --- /dev/null +++ b/src/HUDMerger/Services/FolderPickerService.cs @@ -0,0 +1,30 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using System.Windows; +using HUDMerger.Core.Services; +using Microsoft.Win32; + +namespace HUDMerger.Services; + +public class FolderPickerService : IFolderPickerService +{ + private readonly OpenFolderDialog OpenFolderDialog; + + public FolderPickerService(string teamFortress2Folder) + { + OpenFolderDialog = new OpenFolderDialog + { + InitialDirectory = Path.Join(teamFortress2Folder, "tf\\custom\\") + }; + } + + public async Task PickFolderAsync() + { + return await Task.Run(() => + OpenFolderDialog.ShowDialog(Application.Current.MainWindow) == true + ? OpenFolderDialog.FolderName + : null + ); + } +} From 3c72b9ac8de141820603a01804e5783002a558e3 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Sun, 7 Jul 2024 10:58:15 +1000 Subject: [PATCH 17/23] Add Window services --- .../Services/IAboutWindowService.cs | 9 +++++ .../Services/ISettingsWindowService.cs | 9 +++++ .../ViewModels/MainWindowViewModel.cs | 34 ++++--------------- src/HUDMerger/App.xaml.cs | 6 +++- src/HUDMerger/Services/AboutWindowService.cs | 20 +++++++++++ .../Services/SettingsWindowService.cs | 27 +++++++++++++++ 6 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 src/HUDMerger.Core/Services/IAboutWindowService.cs create mode 100644 src/HUDMerger.Core/Services/ISettingsWindowService.cs create mode 100644 src/HUDMerger/Services/AboutWindowService.cs create mode 100644 src/HUDMerger/Services/SettingsWindowService.cs diff --git a/src/HUDMerger.Core/Services/IAboutWindowService.cs b/src/HUDMerger.Core/Services/IAboutWindowService.cs new file mode 100644 index 0000000..04c41cb --- /dev/null +++ b/src/HUDMerger.Core/Services/IAboutWindowService.cs @@ -0,0 +1,9 @@ +using System; +using HUDMerger.Core.ViewModels; + +namespace HUDMerger.Core.Services; + +public interface IAboutWindowService +{ + public void Show(AboutWindowViewModel aboutWindowViewModel); +} diff --git a/src/HUDMerger.Core/Services/ISettingsWindowService.cs b/src/HUDMerger.Core/Services/ISettingsWindowService.cs new file mode 100644 index 0000000..8e898b5 --- /dev/null +++ b/src/HUDMerger.Core/Services/ISettingsWindowService.cs @@ -0,0 +1,9 @@ +using System; +using HUDMerger.Core.ViewModels; + +namespace HUDMerger.Core.Services; + +public interface ISettingsWindowService +{ + public void Show(SettingsWindowViewModel settingsWindowViewModel); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index 1827b14..a07e5a3 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -18,6 +18,8 @@ namespace HUDMerger.Core.ViewModels; public class MainWindowViewModel : ViewModelBase { private readonly IFolderPickerService FolderPickerService; + private readonly ISettingsWindowService SettingsWindowService; + private readonly IAboutWindowService AboutWindowService; private static readonly Channel<(string? sourceName, string? targetName)> DiscordChannel = Channel.CreateBounded<(string? sourceName, string? targetName)>(new BoundedChannelOptions(1) { FullMode = BoundedChannelFullMode.DropOldest }); @@ -83,9 +85,11 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel(IFolderPickerService folderPickerService) + public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService) { FolderPickerService = folderPickerService; + SettingsWindowService = settingsWindowService; + AboutWindowService = aboutWindowService; LoadSourceHUDCommand = new AsyncRelayCommand(LoadSourceHUD); LoadTargetHUDCommand = new AsyncRelayCommand(LoadTargetHUD); @@ -108,36 +112,12 @@ public MainWindowViewModel(IFolderPickerService folderPickerService) private void ShowSettingsWindow() { - using SettingsWindowViewModel settingsWindowViewModel = new(); - - SettingsWindow settingsWindow = new() - { - DataContext = settingsWindowViewModel, - Owner = Application.Current.MainWindow - }; - - void OnClose(object? sender, EventArgs args) - { - settingsWindowViewModel.Close -= OnClose; - settingsWindow.Close(); - } - - settingsWindowViewModel.Close += OnClose; - - settingsWindow.Show(); + SettingsWindowService.Show(new SettingsWindowViewModel()); } private void ShowAboutWindow() { - using AboutWindowViewModel aboutWindowViewModel = new(); - - AboutWindow aboutWindow = new() - { - DataContext = aboutWindowViewModel, - Owner = Application.Current.MainWindow - }; - - aboutWindow.Show(); + AboutWindowService.Show(new AboutWindowViewModel()); } private async Task LoadSourceHUD() diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 1b22f2d..b79db81 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -112,7 +112,11 @@ protected override void OnStartup(StartupEventArgs e) MainWindow = new MainWindow { - DataContext = new MainWindowViewModel(new FolderPickerService(HUDMerger.Properties.Settings.Default.TeamFortress2Folder)) + DataContext = new MainWindowViewModel( + new FolderPickerService(HUDMerger.Properties.Settings.Default.TeamFortress2Folder), + new SettingsWindowService(), + new AboutWindowService() + ) }; MainWindow.Show(); diff --git a/src/HUDMerger/Services/AboutWindowService.cs b/src/HUDMerger/Services/AboutWindowService.cs new file mode 100644 index 0000000..5d3ea39 --- /dev/null +++ b/src/HUDMerger/Services/AboutWindowService.cs @@ -0,0 +1,20 @@ +using System; +using System.Windows; +using HUDMerger.Core.Services; +using HUDMerger.Core.ViewModels; + +namespace HUDMerger.Services; + +public class AboutWindowService : IAboutWindowService +{ + public void Show(AboutWindowViewModel aboutWindowViewModel) + { + AboutWindow aboutWindow = new() + { + DataContext = aboutWindowViewModel, + Owner = Application.Current.MainWindow + }; + + aboutWindow.Show(); + } +} diff --git a/src/HUDMerger/Services/SettingsWindowService.cs b/src/HUDMerger/Services/SettingsWindowService.cs new file mode 100644 index 0000000..e10f537 --- /dev/null +++ b/src/HUDMerger/Services/SettingsWindowService.cs @@ -0,0 +1,27 @@ +using System; +using System.Windows; +using HUDMerger.Core.Services; +using HUDMerger.Core.ViewModels; + +namespace HUDMerger.Services; + +public class SettingsWindowService : ISettingsWindowService +{ + public void Show(SettingsWindowViewModel settingsWindowViewModel) + { + SettingsWindow settingsWindow = new() + { + DataContext = settingsWindowViewModel, + Owner = Application.Current.MainWindow + }; + + void OnClose(object? sender, EventArgs args) + { + settingsWindowViewModel.Close -= OnClose; + settingsWindow.Close(); + } + + settingsWindowViewModel.Close += OnClose; + settingsWindow.Show(); + } +} From 907429a9299874d757c11d6175d71e979201dc6e Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 14:31:09 +1000 Subject: [PATCH 18/23] Add HUDMerger.Core assembly --- src/HUDMerger/Views/AboutWindowView.xaml | 2 +- src/HUDMerger/Views/HUDInfoView.xaml | 2 +- src/HUDMerger/Views/HUDPanelView.xaml | 2 +- src/HUDMerger/Views/MainWindowView.xaml | 2 +- src/HUDMerger/Views/SettingsWindowView.xaml | 2 +- src/HUDMerger/Views/SourceHUDPanelsListView.xaml | 2 +- src/HUDMerger/Views/TargetHUDPanelsListView.xaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/HUDMerger/Views/AboutWindowView.xaml b/src/HUDMerger/Views/AboutWindowView.xaml index 1fb31ee..ec975e7 100644 --- a/src/HUDMerger/Views/AboutWindowView.xaml +++ b/src/HUDMerger/Views/AboutWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:AboutWindowViewModel}}"> diff --git a/src/HUDMerger/Views/HUDInfoView.xaml b/src/HUDMerger/Views/HUDInfoView.xaml index 0ec81c7..c1780cb 100644 --- a/src/HUDMerger/Views/HUDInfoView.xaml +++ b/src/HUDMerger/Views/HUDInfoView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" mc:Ignorable="d" d:DesignHeight="74" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:HUDInfoViewModel}}"> diff --git a/src/HUDMerger/Views/HUDPanelView.xaml b/src/HUDMerger/Views/HUDPanelView.xaml index 09e2172..9513044 100644 --- a/src/HUDMerger/Views/HUDPanelView.xaml +++ b/src/HUDMerger/Views/HUDPanelView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="31" d:DesignWidth="355" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:HUDPanelViewModel}}"> diff --git a/src/HUDMerger/Views/MainWindowView.xaml b/src/HUDMerger/Views/MainWindowView.xaml index d811b9d..d9354ae 100644 --- a/src/HUDMerger/Views/MainWindowView.xaml +++ b/src/HUDMerger/Views/MainWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:MainWindowViewModel}}"> diff --git a/src/HUDMerger/Views/SettingsWindowView.xaml b/src/HUDMerger/Views/SettingsWindowView.xaml index c8f4d2a..682300b 100644 --- a/src/HUDMerger/Views/SettingsWindowView.xaml +++ b/src/HUDMerger/Views/SettingsWindowView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:SettingsWindowViewModel}}"> diff --git a/src/HUDMerger/Views/SourceHUDPanelsListView.xaml b/src/HUDMerger/Views/SourceHUDPanelsListView.xaml index af590b6..4325e78 100644 --- a/src/HUDMerger/Views/SourceHUDPanelsListView.xaml +++ b/src/HUDMerger/Views/SourceHUDPanelsListView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="240" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:SourceHUDPanelsListViewModel}}"> diff --git a/src/HUDMerger/Views/TargetHUDPanelsListView.xaml b/src/HUDMerger/Views/TargetHUDPanelsListView.xaml index 5297b1a..ce04caa 100644 --- a/src/HUDMerger/Views/TargetHUDPanelsListView.xaml +++ b/src/HUDMerger/Views/TargetHUDPanelsListView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:HUDMerger.Views" - xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels" + xmlns:viewmodels="clr-namespace:HUDMerger.Core.ViewModels;assembly=HUDMerger.Core" xmlns:converters="clr-namespace:HUDMerger.Converters" mc:Ignorable="d" d:DesignHeight="240" d:DesignWidth="377" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:TargetHUDPanelsListViewModel}}"> From ac55d0b2957d7286039dd12bf141111792d03afc Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 14:54:49 +1000 Subject: [PATCH 19/23] Add MessageBoxService --- src/HUDMerger.Core/Commands/MergeCommand.cs | 11 +++++++---- .../Services/IMessageBoxService.cs | 9 +++++++++ .../ViewModels/MainWindowViewModel.cs | 6 +++--- src/HUDMerger/App.xaml.cs | 3 ++- src/HUDMerger/Services/MessageBoxService.cs | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 src/HUDMerger.Core/Services/IMessageBoxService.cs create mode 100644 src/HUDMerger/Services/MessageBoxService.cs diff --git a/src/HUDMerger.Core/Commands/MergeCommand.cs b/src/HUDMerger.Core/Commands/MergeCommand.cs index 0751947..af4f190 100644 --- a/src/HUDMerger.Core/Commands/MergeCommand.cs +++ b/src/HUDMerger.Core/Commands/MergeCommand.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Windows; using HUDMerger.Core.Models; +using HUDMerger.Core.Services; using HUDMerger.Core.ViewModels; namespace HUDMerger.Core.Commands; @@ -13,11 +14,13 @@ public class MergeCommand : CommandBase { private bool _disposed; private readonly MainWindowViewModel _mainWindowViewModel; + private readonly IMessageBoxService MessageBoxService; - public MergeCommand(MainWindowViewModel mainWindowViewModel) + public MergeCommand(MainWindowViewModel mainWindowViewModel, IMessageBoxService messageBoxService) { _mainWindowViewModel = mainWindowViewModel; _mainWindowViewModel.PropertyChanged += _mainWindowViewModel_PropertyChanged; + MessageBoxService = messageBoxService; } private void _mainWindowViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -63,7 +66,7 @@ static bool PathContainsPath(string parentDir, string subDir) if (teamFortress2FolderContainsTarget && processes.Length != 0) { - MessageBox.Show("TF2 process open, cannot merge!", "TF2 Open Error", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBoxService.ShowException(new Exception("TF2 process open, cannot merge!"), "TF2 Open Error"); return; } #endif @@ -77,11 +80,11 @@ static bool PathContainsPath(string parentDir, string subDir) .ToArray() ); - MessageBox.Show("Done!"); + MessageBoxService.Show("Done!"); } catch (Exception e) { - MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBoxService.ShowException(e, "Error"); } } diff --git a/src/HUDMerger.Core/Services/IMessageBoxService.cs b/src/HUDMerger.Core/Services/IMessageBoxService.cs new file mode 100644 index 0000000..6e8bf60 --- /dev/null +++ b/src/HUDMerger.Core/Services/IMessageBoxService.cs @@ -0,0 +1,9 @@ +using System; + +namespace HUDMerger.Core.Services; + +public interface IMessageBoxService +{ + public void Show(string messageBoxText); + public void ShowException(Exception exception, string caption); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index a07e5a3..aa8f2be 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -85,7 +85,7 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService) + public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IMessageBoxService messageBoxService) { FolderPickerService = folderPickerService; SettingsWindowService = settingsWindowService; @@ -104,7 +104,7 @@ public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWi _sourceHUDPanelsListViewModel = new SelectHUDViewModel(LoadSourceHUDCommand); _targetHUDPanelsListViewModel = new SelectHUDViewModel(LoadTargetHUDCommand); - MergeCommand = new MergeCommand(this); + MergeCommand = new MergeCommand(this, messageBoxService); ChannelReader<(string? sourceName, string? targetName)> reader = DiscordChannel.Reader; Task.Run(async () => await DiscordRichPresence(reader)); diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index b79db81..098c8e4 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -115,7 +115,8 @@ protected override void OnStartup(StartupEventArgs e) DataContext = new MainWindowViewModel( new FolderPickerService(HUDMerger.Properties.Settings.Default.TeamFortress2Folder), new SettingsWindowService(), - new AboutWindowService() + new AboutWindowService(), + new MessageBoxService() ) }; diff --git a/src/HUDMerger/Services/MessageBoxService.cs b/src/HUDMerger/Services/MessageBoxService.cs new file mode 100644 index 0000000..9716a2b --- /dev/null +++ b/src/HUDMerger/Services/MessageBoxService.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows; +using HUDMerger.Core.Services; + +namespace HUDMerger.Services; + +public class MessageBoxService : IMessageBoxService +{ + public void Show(string messageBoxText) + { + MessageBox.Show(messageBoxText); + } + + public void ShowException(Exception exception, string caption) + { + MessageBox.Show(exception.Message, caption, MessageBoxButton.OK, MessageBoxImage.Error); + } +} From 7a7c08131b5822510d66d2a355c113d8df7c232a Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 16:24:10 +1000 Subject: [PATCH 20/23] Add SettingsService --- src/HUDMerger.Core/Commands/MergeCommand.cs | 9 +- src/HUDMerger.Core/Models/HUD.cs | 34 +++--- .../Services/HUDFileReaderService.cs | 17 ++- .../Services/ISettingsService.cs | 10 ++ .../ViewModels/MainWindowViewModel.cs | 8 +- .../ViewModels/SettingsWindowViewModel.cs | 20 ++-- src/HUDMerger/App.xaml.cs | 90 +-------------- src/HUDMerger/Services/FolderPickerService.cs | 4 +- src/HUDMerger/Services/SettingsService.cs | 108 ++++++++++++++++++ 9 files changed, 175 insertions(+), 125 deletions(-) create mode 100644 src/HUDMerger.Core/Services/ISettingsService.cs create mode 100644 src/HUDMerger/Services/SettingsService.cs diff --git a/src/HUDMerger.Core/Commands/MergeCommand.cs b/src/HUDMerger.Core/Commands/MergeCommand.cs index af4f190..b8bd243 100644 --- a/src/HUDMerger.Core/Commands/MergeCommand.cs +++ b/src/HUDMerger.Core/Commands/MergeCommand.cs @@ -14,12 +14,14 @@ public class MergeCommand : CommandBase { private bool _disposed; private readonly MainWindowViewModel _mainWindowViewModel; + private readonly ISettingsService SettingsService; private readonly IMessageBoxService MessageBoxService; - public MergeCommand(MainWindowViewModel mainWindowViewModel, IMessageBoxService messageBoxService) + public MergeCommand(MainWindowViewModel mainWindowViewModel, ISettingsService settingsService, IMessageBoxService messageBoxService) { _mainWindowViewModel = mainWindowViewModel; _mainWindowViewModel.PropertyChanged += _mainWindowViewModel_PropertyChanged; + SettingsService = settingsService; MessageBoxService = messageBoxService; } @@ -47,7 +49,7 @@ static bool PathContainsPath(string parentDir, string subDir) return !relativeDirectory.StartsWith("..") && !Path.IsPathRooted(relativeDirectory); } - bool teamFortress2FolderContainsTarget = PathContainsPath(Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf\\custom"), _mainWindowViewModel.TargetHUD!.FolderPath); + bool teamFortress2FolderContainsTarget = PathContainsPath(Path.Join(SettingsService.Settings.TeamFortress2Folder, "tf\\custom"), _mainWindowViewModel.TargetHUD!.FolderPath); Process[] processes; @@ -77,7 +79,8 @@ static bool PathContainsPath(string parentDir, string subDir) _mainWindowViewModel.HUDPanelViewModels .Where((hudPanelViewModel) => hudPanelViewModel.Selected) .Select((hudPanelViewModel) => hudPanelViewModel.HUDPanel) - .ToArray() + .ToArray(), + SettingsService ); MessageBoxService.Show("Done!"); diff --git a/src/HUDMerger.Core/Models/HUD.cs b/src/HUDMerger.Core/Models/HUD.cs index 4d48ef5..61f3a2e 100644 --- a/src/HUDMerger.Core/Models/HUD.cs +++ b/src/HUDMerger.Core/Models/HUD.cs @@ -118,7 +118,7 @@ bool TestKeyValues(KeyValues keyValues) /// HUD to merge panels from /// HUD to merge panels to /// Panels - public static void Merge(HUD source, HUD target, HUDPanel[] panels) + public static void Merge(HUD source, HUD target, HUDPanel[] panels, ISettingsService settingsService) { Dependencies dependencies = new(panels.Select((panel) => panel.Dependencies).OfType()); dependencies.Files.UnionWith(panels.Select((panel) => panel.Main).Where((main) => !string.IsNullOrEmpty(main))); @@ -129,9 +129,9 @@ public static void Merge(HUD source, HUD target, HUDPanel[] panels) .SelectMany((files) => files) ); - IHUDFileReaderService reader = new HUDFileReaderService(); + IHUDFileReaderService reader = new HUDFileReaderService(settingsService); - Func?>[] actions = + Func?>[] actions = [ AddDependencies, MergeHUDLayout, @@ -149,11 +149,11 @@ public static void Merge(HUD source, HUD target, HUDPanel[] panels) List> commitActions = []; List exceptions = []; - foreach (Func?> action in actions) + foreach (Func?> action in actions) { try { - Action? result = action(reader, source, target, dependencies); + Action? result = action(reader, source, target, dependencies, settingsService); if (result != null) { commitActions.Add(result); @@ -186,13 +186,13 @@ public static void Merge(HUD source, HUD target, HUDPanel[] panels) } } - private static Action? AddDependencies(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? AddDependencies(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { dependencies.Add(reader, source); return null; } - private static Action? MergeHUDLayout(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeHUDLayout(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (dependencies.HUDLayout.Count == 0) { @@ -377,7 +377,7 @@ void RemoveBaseHUDLayoutEntries(string folderPath, IEnumerable baseFiles }; } - private static Action? MergeHUDAnimations(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeHUDAnimations(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (dependencies.Events.Count == 0) { @@ -500,7 +500,7 @@ bool SourceHUDAnimationsFileExists(KeyValue kv) }; } - private static Action? MergeClientScheme(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeClientScheme(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (!dependencies.ClientScheme.Any()) { @@ -729,7 +729,7 @@ If the value is a string select the string value }; } - private static Action? MergeSourceScheme(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeSourceScheme(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (!dependencies.SourceScheme.Any() || dependencies.Files.Contains("resource\\sourcescheme.res")) { @@ -963,7 +963,7 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) }; } - private static Action? MergeLanguageTokens(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeLanguageTokens(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (dependencies.LanguageTokens.Count == 0) { @@ -977,7 +977,7 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) List languages = ["english"]; - string settingsLanguage = ((App)Application.Current).Settings.Value.Language; + string settingsLanguage = settingsService.Settings.Language; if (settingsLanguage != "english") { @@ -1100,7 +1100,7 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) }; } - private static Action? MergeImages(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeImages(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { IEnumerable images = dependencies.Images.Concat(dependencies.PreloadImages); @@ -1129,7 +1129,7 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) return null; } - private static Action? MergePreloadImages(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergePreloadImages(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { if (dependencies.PreloadImages.Count == 0) { @@ -1195,13 +1195,13 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) }; } - private static Action? MergeAudio(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeAudio(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { dependencies.Files.UnionWith(dependencies.Audio); return null; } - private static Action? MergeInfoVDF(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? MergeInfoVDF(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { reader.Require([ (target, "info.vdf", FileType.VDF) @@ -1230,7 +1230,7 @@ void RemoveBaseSchemeValues(string folderPath, IEnumerable baseFiles) }; } - private static Action? CopyFiles(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies) + private static Action? CopyFiles(IHUDFileReaderService reader, HUD source, HUD target, Dependencies dependencies, ISettingsService settingsService) { return (writer) => { diff --git a/src/HUDMerger.Core/Services/HUDFileReaderService.cs b/src/HUDMerger.Core/Services/HUDFileReaderService.cs index 2ac970a..dcf79f8 100644 --- a/src/HUDMerger.Core/Services/HUDFileReaderService.cs +++ b/src/HUDMerger.Core/Services/HUDFileReaderService.cs @@ -23,11 +23,20 @@ public enum FileType : byte public partial class HUDFileReaderService : IHUDFileReaderService { - private readonly Lazy TF2MiscDirVPK = new(() => new(Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf\\tf2_misc_dir.vpk"))); - private readonly Lazy PlatformMiscDirVPK = new(() => new(Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "platform\\platform_misc_dir.vpk"))); + private readonly ISettingsService SettingsService; + + private readonly Lazy TF2MiscDirVPK; + private readonly Lazy PlatformMiscDirVPK; private readonly Dictionary Files = []; + public HUDFileReaderService(ISettingsService settingsService) + { + SettingsService = settingsService; + TF2MiscDirVPK = new Lazy(() => new VPK(Path.Join(SettingsService.Settings.TeamFortress2Folder, "tf\\tf2_misc_dir.vpk"))); + PlatformMiscDirVPK = new Lazy(() => new VPK(Path.Join(SettingsService.Settings.TeamFortress2Folder, "platform\\platform_misc_dir.vpk"))); + } + public void Require(IEnumerable<(HUD hud, string relativePath, FileType type)> filePaths) { HashSet seen = []; @@ -65,13 +74,13 @@ void Add(HUD hud, string relativePath, FileType type) return Encoding.UTF8.GetString(PlatformMiscDirVPK.Value.Read(relativePath)); } - string tfPath = Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf", relativePath); + string tfPath = Path.Join(SettingsService.Settings.TeamFortress2Folder, "tf", relativePath); if (File.Exists(tfPath)) { return File.ReadAllText(tfPath); } - string hl2Path = Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "hl2", relativePath); + string hl2Path = Path.Join(SettingsService.Settings.TeamFortress2Folder, "hl2", relativePath); if (File.Exists(hl2Path)) { return File.ReadAllText(hl2Path); diff --git a/src/HUDMerger.Core/Services/ISettingsService.cs b/src/HUDMerger.Core/Services/ISettingsService.cs new file mode 100644 index 0000000..704630c --- /dev/null +++ b/src/HUDMerger.Core/Services/ISettingsService.cs @@ -0,0 +1,10 @@ +using System; +using HUDMerger.Core.Models; + +namespace HUDMerger.Core.Services; + +public interface ISettingsService +{ + public Settings Settings { get; } + public void Save(); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index aa8f2be..8e7efe3 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -17,6 +17,7 @@ namespace HUDMerger.Core.ViewModels; public class MainWindowViewModel : ViewModelBase { + private readonly ISettingsService SettingsService; private readonly IFolderPickerService FolderPickerService; private readonly ISettingsWindowService SettingsWindowService; private readonly IAboutWindowService AboutWindowService; @@ -85,8 +86,9 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IMessageBoxService messageBoxService) + public MainWindowViewModel(ISettingsService settingsService, IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IMessageBoxService messageBoxService) { + SettingsService = settingsService; FolderPickerService = folderPickerService; SettingsWindowService = settingsWindowService; AboutWindowService = aboutWindowService; @@ -104,7 +106,7 @@ public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWi _sourceHUDPanelsListViewModel = new SelectHUDViewModel(LoadSourceHUDCommand); _targetHUDPanelsListViewModel = new SelectHUDViewModel(LoadTargetHUDCommand); - MergeCommand = new MergeCommand(this, messageBoxService); + MergeCommand = new MergeCommand(this, SettingsService, messageBoxService); ChannelReader<(string? sourceName, string? targetName)> reader = DiscordChannel.Reader; Task.Run(async () => await DiscordRichPresence(reader)); @@ -112,7 +114,7 @@ public MainWindowViewModel(IFolderPickerService folderPickerService, ISettingsWi private void ShowSettingsWindow() { - SettingsWindowService.Show(new SettingsWindowViewModel()); + SettingsWindowService.Show(new SettingsWindowViewModel(SettingsService)); } private void ShowAboutWindow() diff --git a/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs index 7a3c0d6..f5b953c 100644 --- a/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SettingsWindowViewModel.cs @@ -2,12 +2,15 @@ using System.Windows; using System.Windows.Input; using HUDMerger.Core.Models; +using HUDMerger.Core.Services; using Microsoft.Toolkit.Mvvm.Input; namespace HUDMerger.Core.ViewModels; public class SettingsWindowViewModel : ViewModelBase { + private readonly ISettingsService SettingsService; + private string _teamFortress2Folder; public string TeamFortress2Folder { @@ -35,12 +38,12 @@ public string Language public event EventHandler? Close; - public SettingsWindowViewModel() + public SettingsWindowViewModel(ISettingsService settingsService) { - Settings settings = ((App)Application.Current).Settings.Value; + SettingsService = settingsService; - _teamFortress2Folder = settings.TeamFortress2Folder; - _language = settings.Language; + _teamFortress2Folder = SettingsService.Settings.TeamFortress2Folder; + _language = SettingsService.Settings.Language; CancelCommand = new RelayCommand(Cancel); ApplyCommand = new RelayCommand(Apply); @@ -53,12 +56,9 @@ private void Cancel() private void Apply() { - ((App)Application.Current).Settings.Value.TeamFortress2Folder = TeamFortress2Folder; - ((App)Application.Current).Settings.Value.Language = Language; - - Properties.Settings.Default.TeamFortress2Folder = TeamFortress2Folder; - Properties.Settings.Default.Language = Language; - Properties.Settings.Default.Save(); + SettingsService.Settings.TeamFortress2Folder = TeamFortress2Folder; + SettingsService.Settings.Language = Language; + SettingsService.Save(); Close?.Invoke(this, new EventArgs()); } diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index 098c8e4..c161d03 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -18,91 +18,6 @@ namespace HUDMerger; /// public partial class App : Application { - public Lazy Settings = new(() => - { - string? teamFortress2Folder = null; - if (!string.IsNullOrEmpty(HUDMerger.Properties.Settings.Default.TeamFortress2Folder)) - { - teamFortress2Folder = HUDMerger.Properties.Settings.Default.TeamFortress2Folder; - } - - string? language = null; - if (!string.IsNullOrEmpty(HUDMerger.Properties.Settings.Default.Language)) - { - language = HUDMerger.Properties.Settings.Default.Language; - } - - if (teamFortress2Folder == null || language == null) - { - try - { - // "C:\Program Files (x86)\Steam" - string? installPath = ( - Registry.GetValue($"HKEY_LOCAL_MACHINE\\Software\\{(Environment.Is64BitProcess ? "Wow6432Node\\" : "")}Valve\\Steam", "InstallPath", "") is string str - ? str - : null - ) ?? throw new Exception(); - - if (teamFortress2Folder == null) - { - try - { - KeyValues libraryFolder = VDFSerializer - .Deserialize(File.ReadAllText(Path.Join(installPath, "steamapps\\libraryfolders.vdf"))) - .Header("libraryfolders") - .First((keyValue) => - keyValue.Value is KeyValues indexValues && indexValues.Any((kv) => kv.Key.Equals("apps") && kv.Value is KeyValues appsKeyValues && appsKeyValues.Any((kv) => kv.Key == "440")) - ) - .Value; - - string libraryFolderPath = libraryFolder.First((kv) => kv.Key.Equals("path", StringComparison.OrdinalIgnoreCase) && kv.Value is string str).Value; - - string libraryFolderTeamFortress2Path = $"{libraryFolderPath.Replace("\\\\", "\\")}\\steamapps\\common\\Team Fortress 2"; - if (Directory.Exists(libraryFolderTeamFortress2Path)) - { - teamFortress2Folder = libraryFolderTeamFortress2Path; - } - } - catch (Exception) - { - } - } - - if (language == null) - { - try - { - string appManifestPath = Path.Join(installPath, "steamapps\\appmanifest_440.acf"); - - KeyValues userConfig = VDFSerializer - .Deserialize(File.ReadAllText(Path.Join(installPath, "steamapps\\appmanifest_440.acf"))) - .Header("AppState") - .First((kv) => kv.Key.Equals("UserConfig", StringComparison.OrdinalIgnoreCase) && kv.Value is KeyValues) - .Value; - - string userConfigLanguage = userConfig - .First((kv) => kv.Key.Equals("language", StringComparison.OrdinalIgnoreCase) && kv.Value is string) - .Value; - - language = userConfigLanguage; - } - catch (Exception) - { - } - } - } - catch (Exception) - { - } - } - - return new Settings - { - TeamFortress2Folder = teamFortress2Folder ?? "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Team Fortress 2", - Language = language ?? "english" - }; - }); - protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); @@ -110,10 +25,13 @@ protected override void OnStartup(StartupEventArgs e) HUDMerger.Properties.Settings.Default.Upgrade(); HUDMerger.Properties.Settings.Default.Save(); + SettingsService settingsService = new(); + MainWindow = new MainWindow { DataContext = new MainWindowViewModel( - new FolderPickerService(HUDMerger.Properties.Settings.Default.TeamFortress2Folder), + settingsService, + new FolderPickerService(settingsService), new SettingsWindowService(), new AboutWindowService(), new MessageBoxService() diff --git a/src/HUDMerger/Services/FolderPickerService.cs b/src/HUDMerger/Services/FolderPickerService.cs index 88c2d13..5eff9f1 100644 --- a/src/HUDMerger/Services/FolderPickerService.cs +++ b/src/HUDMerger/Services/FolderPickerService.cs @@ -11,11 +11,11 @@ public class FolderPickerService : IFolderPickerService { private readonly OpenFolderDialog OpenFolderDialog; - public FolderPickerService(string teamFortress2Folder) + public FolderPickerService(ISettingsService settingsService) { OpenFolderDialog = new OpenFolderDialog { - InitialDirectory = Path.Join(teamFortress2Folder, "tf\\custom\\") + InitialDirectory = Path.Join(settingsService.Settings.TeamFortress2Folder, "tf\\custom\\") }; } diff --git a/src/HUDMerger/Services/SettingsService.cs b/src/HUDMerger/Services/SettingsService.cs new file mode 100644 index 0000000..a469abc --- /dev/null +++ b/src/HUDMerger/Services/SettingsService.cs @@ -0,0 +1,108 @@ +using System; +using System.IO; +using System.Linq; +using HUDMerger.Core.Extensions; +using HUDMerger.Core.Models; +using HUDMerger.Core.Services; +using Microsoft.Win32; +using VDF; +using VDF.Models; + +namespace HUDMerger.Services; + +public class SettingsService : ISettingsService +{ + public Settings Settings { get; } + + public SettingsService() + { + string? teamFortress2Folder = null; + if (!string.IsNullOrEmpty(HUDMerger.Properties.Settings.Default.TeamFortress2Folder)) + { + teamFortress2Folder = HUDMerger.Properties.Settings.Default.TeamFortress2Folder; + } + + string? language = null; + if (!string.IsNullOrEmpty(HUDMerger.Properties.Settings.Default.Language)) + { + language = HUDMerger.Properties.Settings.Default.Language; + } + + if (teamFortress2Folder == null || language == null) + { + try + { + // "C:\Program Files (x86)\Steam" + string? installPath = ( + Registry.GetValue($"HKEY_LOCAL_MACHINE\\Software\\{(Environment.Is64BitProcess ? "Wow6432Node\\" : "")}Valve\\Steam", "InstallPath", "") is string str + ? str + : null + ) ?? throw new Exception(); + + if (teamFortress2Folder == null) + { + try + { + KeyValues libraryFolder = VDFSerializer + .Deserialize(File.ReadAllText(Path.Join(installPath, "steamapps\\libraryfolders.vdf"))) + .Header("libraryfolders") + .First((keyValue) => + keyValue.Value is KeyValues indexValues && indexValues.Any((kv) => kv.Key.Equals("apps") && kv.Value is KeyValues appsKeyValues && appsKeyValues.Any((kv) => kv.Key == "440")) + ) + .Value; + + string libraryFolderPath = libraryFolder.First((kv) => kv.Key.Equals("path", StringComparison.OrdinalIgnoreCase) && kv.Value is string str).Value; + + string libraryFolderTeamFortress2Path = $"{libraryFolderPath.Replace("\\\\", "\\")}\\steamapps\\common\\Team Fortress 2"; + if (Directory.Exists(libraryFolderTeamFortress2Path)) + { + teamFortress2Folder = libraryFolderTeamFortress2Path; + } + } + catch (Exception) + { + } + } + + if (language == null) + { + try + { + string appManifestPath = Path.Join(installPath, "steamapps\\appmanifest_440.acf"); + + KeyValues userConfig = VDFSerializer + .Deserialize(File.ReadAllText(Path.Join(installPath, "steamapps\\appmanifest_440.acf"))) + .Header("AppState") + .First((kv) => kv.Key.Equals("UserConfig", StringComparison.OrdinalIgnoreCase) && kv.Value is KeyValues) + .Value; + + string userConfigLanguage = userConfig + .First((kv) => kv.Key.Equals("language", StringComparison.OrdinalIgnoreCase) && kv.Value is string) + .Value; + + language = userConfigLanguage; + } + catch (Exception) + { + } + } + } + catch (Exception) + { + } + } + + Settings = new Settings + { + TeamFortress2Folder = teamFortress2Folder ?? "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Team Fortress 2", + Language = language ?? "english" + }; + } + + public void Save() + { + Properties.Settings.Default.TeamFortress2Folder = Settings.TeamFortress2Folder; + Properties.Settings.Default.Language = Settings.Language; + Properties.Settings.Default.Save(); + } +} From 974426dd9486c0e4f5483a2de67442e27cede589 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 17:01:00 +1000 Subject: [PATCH 21/23] Fix HUDPanelsCollectionView --- .../ViewModels/MainWindowViewModel.cs | 4 +- .../SourceHUDPanelsListViewModel.cs | 42 ++++++++++++++----- .../TargetHUDPanelsListViewModel.cs | 39 +++++++++++++---- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index 8e7efe3..f0b822e 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -147,7 +147,7 @@ private async Task LoadSourceHUD() if (TargetHUDPanelsListViewModel is TargetHUDPanelsListViewModel targetHUDPanelsListViewModel) { - targetHUDPanelsListViewModel.HUDPanelsCollectionView.Refresh(); + targetHUDPanelsListViewModel.Refresh(); } } @@ -170,7 +170,7 @@ private void HudPanelViewModel_PropertyChanged(object? sender, PropertyChangedEv { if (e.PropertyName == nameof(HUDPanelViewModel.Selected) && TargetHUDPanelsListViewModel is TargetHUDPanelsListViewModel targetHUDPanelsListViewModel) { - targetHUDPanelsListViewModel.HUDPanelsCollectionView.Refresh(); + targetHUDPanelsListViewModel.Refresh(); } } diff --git a/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs b/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs index df092bd..db556b1 100644 --- a/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/SourceHUDPanelsListViewModel.cs @@ -1,13 +1,24 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Windows.Data; +using System.Collections.ObjectModel; +using System.Linq; namespace HUDMerger.Core.ViewModels; public class SourceHUDPanelsListViewModel : ViewModelBase { - public ICollectionView HUDPanelsCollectionView { get; } + private readonly IEnumerable HUDPanelViewModels; + + private ObservableCollection _hudPanelsCollectionView; + public ObservableCollection HUDPanelsCollectionView + { + get => _hudPanelsCollectionView; + private set + { + _hudPanelsCollectionView = value; + OnPropertyChanged(); + } + } private string _searchText = ""; public string SearchText @@ -17,21 +28,30 @@ public string SearchText { _searchText = value; OnPropertyChanged(); - HUDPanelsCollectionView.Refresh(); + Refresh(); } } public SourceHUDPanelsListViewModel(IEnumerable hudPanelViewModels) { - HUDPanelsCollectionView = new CollectionViewSource { Source = hudPanelViewModels }.View; - HUDPanelsCollectionView.Filter = (object obj) => - { - if (obj is HUDPanelViewModel hudPanelViewModel) + HUDPanelViewModels = hudPanelViewModels; + _hudPanelsCollectionView = new ObservableCollection( + HUDPanelViewModels.Where((hudPanelViewModel) => + { + return hudPanelViewModel.HUDPanel.Name.Contains(SearchText, StringComparison.OrdinalIgnoreCase) + || hudPanelViewModel.HUDPanel.Main.Contains(SearchText, StringComparison.OrdinalIgnoreCase); + }) + ); + } + + public void Refresh() + { + HUDPanelsCollectionView = new ObservableCollection( + HUDPanelViewModels.Where((hudPanelViewModel) => { return hudPanelViewModel.HUDPanel.Name.Contains(SearchText, StringComparison.OrdinalIgnoreCase) || hudPanelViewModel.HUDPanel.Main.Contains(SearchText, StringComparison.OrdinalIgnoreCase); - } - return false; - }; + }) + ); } } diff --git a/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs b/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs index 95de40d..ff5b8d8 100644 --- a/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/TargetHUDPanelsListViewModel.cs @@ -1,20 +1,43 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Windows.Data; +using System.Collections.ObjectModel; +using System.Linq; namespace HUDMerger.Core.ViewModels; public class TargetHUDPanelsListViewModel : ViewModelBase { - public ICollectionView HUDPanelsCollectionView { get; } + private readonly IEnumerable HUDPanelViewModels; - public TargetHUDPanelsListViewModel(IEnumerable hudPanelViewModels) + private ObservableCollection _hudPanelsCollectionView; + public ObservableCollection HUDPanelsCollectionView { - HUDPanelsCollectionView = new CollectionViewSource { Source = hudPanelViewModels }.View; - HUDPanelsCollectionView.Filter = (object obj) => + get => _hudPanelsCollectionView; + private set { - return obj is HUDPanelViewModel hudPanelViewModel && hudPanelViewModel.Selected; - }; + _hudPanelsCollectionView = value; + OnPropertyChanged(); + } + } + + public TargetHUDPanelsListViewModel(IEnumerable hudPanelViewModels) + { + HUDPanelViewModels = hudPanelViewModels; + _hudPanelsCollectionView = new ObservableCollection( + HUDPanelViewModels.Where((hudPanelViewModel) => + { + return hudPanelViewModel.Selected; + }) + ); + } + + public void Refresh() + { + HUDPanelsCollectionView = new ObservableCollection( + HUDPanelViewModels.Where((hudPanelViewModel) => + { + return hudPanelViewModel.Selected; + }) + ); } } From 45581244997033f0063f3a1804739a3715ae4e5c Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 17:01:19 +1000 Subject: [PATCH 22/23] Fix OpenFolderDialog thread error --- src/HUDMerger/Services/FolderPickerService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HUDMerger/Services/FolderPickerService.cs b/src/HUDMerger/Services/FolderPickerService.cs index 5eff9f1..58dff63 100644 --- a/src/HUDMerger/Services/FolderPickerService.cs +++ b/src/HUDMerger/Services/FolderPickerService.cs @@ -19,9 +19,9 @@ public FolderPickerService(ISettingsService settingsService) }; } - public async Task PickFolderAsync() + public Task PickFolderAsync() { - return await Task.Run(() => + return Task.FromResult( OpenFolderDialog.ShowDialog(Application.Current.MainWindow) == true ? OpenFolderDialog.FolderName : null From 53cb2c7577bd3bfc045c83266c42e0f7d8c53c07 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 17:25:47 +1000 Subject: [PATCH 23/23] Add QuitService --- src/HUDMerger.Core/Services/IQuitService.cs | 8 ++++++++ .../ViewModels/MainWindowViewModel.cs | 4 ++-- src/HUDMerger/App.xaml.cs | 1 + src/HUDMerger/Services/QuitService.cs | 13 +++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/HUDMerger.Core/Services/IQuitService.cs create mode 100644 src/HUDMerger/Services/QuitService.cs diff --git a/src/HUDMerger.Core/Services/IQuitService.cs b/src/HUDMerger.Core/Services/IQuitService.cs new file mode 100644 index 0000000..1a6e68e --- /dev/null +++ b/src/HUDMerger.Core/Services/IQuitService.cs @@ -0,0 +1,8 @@ +using System; + +namespace HUDMerger.Core.Services; + +public interface IQuitService +{ + public void Quit(); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index f0b822e..5c1f14e 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -86,7 +86,7 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel(ISettingsService settingsService, IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IMessageBoxService messageBoxService) + public MainWindowViewModel(ISettingsService settingsService, IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IQuitService quitService, IMessageBoxService messageBoxService) { SettingsService = settingsService; FolderPickerService = folderPickerService; @@ -96,7 +96,7 @@ public MainWindowViewModel(ISettingsService settingsService, IFolderPickerServic LoadSourceHUDCommand = new AsyncRelayCommand(LoadSourceHUD); LoadTargetHUDCommand = new AsyncRelayCommand(LoadTargetHUD); ShowSettingsWindowCommand = new RelayCommand(ShowSettingsWindow); - QuitCommand = new RelayCommand(Application.Current.Shutdown); + QuitCommand = new RelayCommand(quitService.Quit); ShowAboutWindowCommand = new RelayCommand(ShowAboutWindow); diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index c161d03..d40c1c5 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -34,6 +34,7 @@ protected override void OnStartup(StartupEventArgs e) new FolderPickerService(settingsService), new SettingsWindowService(), new AboutWindowService(), + new QuitService(), new MessageBoxService() ) }; diff --git a/src/HUDMerger/Services/QuitService.cs b/src/HUDMerger/Services/QuitService.cs new file mode 100644 index 0000000..c3283a4 --- /dev/null +++ b/src/HUDMerger/Services/QuitService.cs @@ -0,0 +1,13 @@ +using System; +using System.Windows; +using HUDMerger.Core.Services; + +namespace HUDMerger.Services; + +public class QuitService : IQuitService +{ + public void Quit() + { + Application.Current.Shutdown(); + } +}