From 9c927d91f3f79560e7080b1a62c2ffed3bac4675 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Tue, 8 Nov 2022 07:42:58 +0100 Subject: [PATCH] set some json attributes for eventually changes of configuraiton in the future --- .../Configuration/PluginConfiguration.cs | 28 ++++++++++--------- PlayerTags/Data/Tag.cs | 9 ++++++ .../Inheritables/InheritableReference.cs | 6 +++- PlayerTags/Inheritables/InheritableValue.cs | 3 ++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/PlayerTags/Configuration/PluginConfiguration.cs b/PlayerTags/Configuration/PluginConfiguration.cs index bc340e4..0bc50ac 100644 --- a/PlayerTags/Configuration/PluginConfiguration.cs +++ b/PlayerTags/Configuration/PluginConfiguration.cs @@ -13,21 +13,9 @@ namespace PlayerTags.Configuration [Serializable] public class PluginConfiguration : IPluginConfiguration { - public int Version { get; set; } = 0; + public int Version { get; set; } = 1; public bool IsVisible = false; - [Obsolete] - [JsonProperty("GeneralOptions")] - private Dictionary GeneralOptionsV1 - { - set - { - GeneralOptions.Clear(); - foreach (var kvp in value) - GeneralOptions.Add((ActivityType)kvp.Key, kvp.Value); - } - } - [JsonProperty("GeneralOptionsV2")] public Dictionary GeneralOptions = new() { @@ -49,6 +37,8 @@ namespace PlayerTags.Configuration public bool IsPlayersTabOthersVisible = false; public bool IsGeneralOptionsAllTheSameEnabled = true; + public Tag AllTags = null; + [JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)] public Dictionary AllTagsChanges = new Dictionary(); @@ -81,6 +71,18 @@ namespace PlayerTags.Configuration #region Obsulate Properties + [Obsolete] + [JsonProperty("GeneralOptions")] + private Dictionary GeneralOptionsV1 + { + set + { + GeneralOptions.Clear(); + foreach (var kvp in value) + GeneralOptions.Add((ActivityType)kvp.Key, kvp.Value); + } + } + [JsonProperty("NameplateFreeCompanyVisibility"), Obsolete] private NameplateFreeCompanyVisibility NameplateFreeCompanyVisibilityV1 { diff --git a/PlayerTags/Data/Tag.cs b/PlayerTags/Data/Tag.cs index e32fe59..5f427e6 100644 --- a/PlayerTags/Data/Tag.cs +++ b/PlayerTags/Data/Tag.cs @@ -1,4 +1,5 @@ using Dalamud.Game.Text.SeStringHandling; +using Newtonsoft.Json; using Pilz.Dalamud.Icons; using PlayerTags.Inheritables; using PlayerTags.PluginStrings; @@ -12,7 +13,10 @@ namespace PlayerTags.Data { public IPluginString Name { get; init; } + [JsonProperty("Parent")] private Tag? m_Parent = null; + + [JsonIgnore] public Tag? Parent { get => m_Parent; @@ -43,6 +47,7 @@ namespace PlayerTags.Data public List Children { get; } = new List(); + [JsonIgnore] public IEnumerable Descendents { get @@ -58,7 +63,9 @@ namespace PlayerTags.Data } } + [JsonIgnore] private Dictionary? m_Inheritables = null; + [JsonIgnore] public Dictionary Inheritables { get @@ -165,6 +172,7 @@ namespace PlayerTags.Data [InheritableCategory("PlayerCategory")] public InheritableValue IsVisibleForOtherPlayers = new InheritableValue(false); + [JsonIgnore] public string[] IdentitiesToAddTo { get @@ -179,6 +187,7 @@ namespace PlayerTags.Data } private Tag? m_Defaults; + [JsonIgnore] public bool HasDefaults { get { return m_Defaults != null; } diff --git a/PlayerTags/Inheritables/InheritableReference.cs b/PlayerTags/Inheritables/InheritableReference.cs index abc101f..ea3c5e2 100644 --- a/PlayerTags/Inheritables/InheritableReference.cs +++ b/PlayerTags/Inheritables/InheritableReference.cs @@ -1,4 +1,6 @@ -namespace PlayerTags.Inheritables +using Newtonsoft.Json; + +namespace PlayerTags.Inheritables { public class InheritableReference : IInheritable where T : class @@ -7,8 +9,10 @@ public InheritableBehavior Behavior { get; set; } + [JsonProperty] public T Value; + [JsonIgnore] public T? InheritedValue { get diff --git a/PlayerTags/Inheritables/InheritableValue.cs b/PlayerTags/Inheritables/InheritableValue.cs index e49e304..f17e55a 100644 --- a/PlayerTags/Inheritables/InheritableValue.cs +++ b/PlayerTags/Inheritables/InheritableValue.cs @@ -1,4 +1,5 @@ using Dalamud.Logging; +using Newtonsoft.Json; using System; namespace PlayerTags.Inheritables @@ -10,8 +11,10 @@ namespace PlayerTags.Inheritables public InheritableBehavior Behavior { get; set; } + [JsonProperty] public T Value; + [JsonIgnore] public T? InheritedValue { get