From a7da74bb80a7f95d084bf7d4e31ec6be455c039c Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Sat, 5 Oct 2024 22:17:47 +0300 Subject: [PATCH] New actor assignment ui experiments --- CustomizePlus/Core/ServiceManagerBuilder.cs | 1 + CustomizePlus/Profiles/Data/Profile.cs | 66 +------- .../Profiles/ProfileManager.ProfileLoading.cs | 155 ++++++++++++++++++ CustomizePlus/Profiles/ProfileManager.cs | 61 +------ CustomizePlus/Templates/Data/Template.cs | 3 +- .../UI/Windows/Controls/ActorAssignmentUi.cs | 155 ++++++++++++++++++ .../MainWindow/Tabs/Profiles/ProfilePanel.cs | 16 +- 7 files changed, 335 insertions(+), 122 deletions(-) create mode 100644 CustomizePlus/Profiles/ProfileManager.ProfileLoading.cs create mode 100644 CustomizePlus/UI/Windows/Controls/ActorAssignmentUi.cs diff --git a/CustomizePlus/Core/ServiceManagerBuilder.cs b/CustomizePlus/Core/ServiceManagerBuilder.cs index 8414e5b..cb45dd4 100644 --- a/CustomizePlus/Core/ServiceManagerBuilder.cs +++ b/CustomizePlus/Core/ServiceManagerBuilder.cs @@ -89,6 +89,7 @@ public static class ServiceManagerBuilder services .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() // template .AddSingleton() diff --git a/CustomizePlus/Profiles/Data/Profile.cs b/CustomizePlus/Profiles/Data/Profile.cs index 6a67907..bb97d2c 100644 --- a/CustomizePlus/Profiles/Data/Profile.cs +++ b/CustomizePlus/Profiles/Data/Profile.cs @@ -21,13 +21,19 @@ namespace CustomizePlus.Profiles.Data; /// public sealed class Profile : ISavable { + public const int Version = 4; + private static int _nextGlobalId; private readonly int _localId; public List Armatures = new(); + [Obsolete("To be removed")] public LowerString CharacterName { get; set; } = LowerString.Empty; + + public ActorIdentifier Character { get; set; } = ActorIdentifier.Invalid; + public LowerString Name { get; set; } = LowerString.Empty; /// @@ -35,8 +41,6 @@ public sealed class Profile : ISavable /// public bool LimitLookupToOwnedObjects { get; set; } = false; - public int Version { get; set; } = Constants.ConfigurationVersion; - public bool Enabled { get; set; } public DateTimeOffset CreationDate { get; set; } = DateTime.UtcNow; public DateTimeOffset ModifiedDate { get; set; } = DateTime.UtcNow; @@ -99,6 +103,7 @@ public sealed class Profile : ISavable ["CreationDate"] = CreationDate, ["ModifiedDate"] = ModifiedDate, ["CharacterName"] = CharacterName.Text, + //["Character"] = Character.ToJson(), ["Name"] = Name.Text, ["LimitLookupToOwnedObjects"] = LimitLookupToOwnedObjects, ["Enabled"] = Enabled, @@ -124,62 +129,7 @@ public sealed class Profile : ISavable #endregion - #region Deserialization - - public static Profile Load(TemplateManager templateManager, JObject obj) - { - var version = obj["Version"]?.ToObject() ?? 0; - return version switch - { - //Ignore everything below v4 for now - 4 => LoadV4(templateManager, obj), - _ => throw new Exception("The design to be loaded has no valid Version."), - }; - } - - private static Profile LoadV4(TemplateManager templateManager, JObject obj) - { - var creationDate = obj["CreationDate"]?.ToObject() ?? throw new ArgumentNullException("CreationDate"); - - var profile = new Profile() - { - CreationDate = creationDate, - UniqueId = obj["UniqueId"]?.ToObject() ?? throw new ArgumentNullException("UniqueId"), - Name = new LowerString(obj["Name"]?.ToObject()?.Trim() ?? throw new ArgumentNullException("Name")), - CharacterName = new LowerString(obj["CharacterName"]?.ToObject()?.Trim() ?? throw new ArgumentNullException("CharacterName")), - LimitLookupToOwnedObjects = obj["LimitLookupToOwnedObjects"]?.ToObject() ?? throw new ArgumentNullException("LimitLookupToOwnedObjects"), - Enabled = obj["Enabled"]?.ToObject() ?? throw new ArgumentNullException("Enabled"), - ModifiedDate = obj["ModifiedDate"]?.ToObject() ?? creationDate, - IsWriteProtected = obj["IsWriteProtected"]?.ToObject() ?? false, - Templates = new List