re-re-organize settings part 1

This commit is contained in:
2023-02-16 11:12:48 +01:00
parent 76648b4b94
commit 90f554df8c
7 changed files with 115 additions and 66 deletions

View File

@@ -0,0 +1,18 @@
using PlayerTags.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PlayerTags.Configuration
{
public class GeneralConfiguration : ZoneConfigurationBase
{
public NameplateFreeCompanyVisibility NameplateFreeCompanyVisibility = NameplateFreeCompanyVisibility.Default;
public NameplateTitleVisibility NameplateTitleVisibility = NameplateTitleVisibility.WhenHasTags;
public NameplateTitlePosition NameplateTitlePosition = NameplateTitlePosition.AlwaysAboveName;
public DeadPlayerHandling NameplateDeadPlayerHandling = DeadPlayerHandling.Include;
public bool IsApplyTagsToAllChatMessagesEnabled = true;
}
}

View File

@@ -24,15 +24,33 @@ namespace PlayerTags.Configuration
public int Version { get; set; } = DEFAULT_CONFIG_VERSION;
public bool IsVisible = false;
public ZoneConfiguration<GeneralConfiguration> GeneralConfigs = new();
public ZoneConfiguration<TagsConfiguration> TagsConfigs = new();
public StatusIconPriorizerSettings StatusIconPriorizerSettings = new(true);
public bool MoveStatusIconToNameplateTextIfPossible = true;
public bool IsPlayerNameRandomlyGenerated = false;
public bool IsCustomTagsContextMenuEnabled = true;
public bool IsShowInheritedPropertiesEnabled = true;
public bool IsPlayersTabOrderedByProximity = false;
public bool IsPlayersTabSelfVisible = true;
public bool IsPlayersTabFriendsVisible = true;
public bool IsPlayersTabPartyVisible = true;
public bool IsPlayersTabAllianceVisible = true;
public bool IsPlayersTabEnemiesVisible = true;
public bool IsPlayersTabOthersVisible = false;
public bool IsSimpleUIEnabled = true;
#region Obsulate Properties
[JsonProperty("GeneralOptionsV2"), Obsolete]
private Dictionary<ActivityType, GeneralOptionsClass> GeneralOptionsV2
private Dictionary<ActivityType, GeneralConfiguration> GeneralOptionsV2
{
set
{
void copyOverSettings(ActivityType srcType, ZoneType destType)
{
var src = value[srcType];
var dest = ZoneConfig[destType];
var dest = GeneralConfigs.GetConfig(destType);
dest.IsApplyTagsToAllChatMessagesEnabled = src.IsApplyTagsToAllChatMessagesEnabled;
dest.NameplateDeadPlayerHandling = src.NameplateDeadPlayerHandling;
dest.NameplateFreeCompanyVisibility = src.NameplateFreeCompanyVisibility;
@@ -50,70 +68,44 @@ namespace PlayerTags.Configuration
}
}
public Dictionary<ZoneType, PluginZoneConfiguration> ZoneConfig = new()
[JsonProperty]
[Obsolete]
public bool IsApplyToEverywhereEnabled
{
{ ZoneType.Overworld, new PluginZoneConfiguration() },
{ ZoneType.Doungen, new PluginZoneConfiguration() },
{ ZoneType.Raid, new PluginZoneConfiguration() },
{ ZoneType.AllianceRaid, new PluginZoneConfiguration() },
{ ZoneType.Foray, new PluginZoneConfiguration() },
{ ZoneType.Pvp, new PluginZoneConfiguration() },
{ ZoneType.Everywhere, new PluginZoneConfiguration() }
};
set
{
GeneralConfigs.IsEverywhere = value;
TagsConfigs.IsEverywhere = value;
}
}
public StatusIconPriorizerSettings StatusIconPriorizerSettings = new(true);
public bool MoveStatusIconToNameplateTextIfPossible = true;
public bool IsPlayerNameRandomlyGenerated = false;
public bool IsCustomTagsContextMenuEnabled = true;
public bool IsShowInheritedPropertiesEnabled = true;
public bool IsPlayersTabOrderedByProximity = false;
public bool IsPlayersTabSelfVisible = true;
public bool IsPlayersTabFriendsVisible = true;
public bool IsPlayersTabPartyVisible = true;
public bool IsPlayersTabAllianceVisible = true;
public bool IsPlayersTabEnemiesVisible = true;
public bool IsPlayersTabOthersVisible = false;
public bool IsSimpleUIEnabled = true;
public bool IsApplyToEverywhereEnabled = true;
#region Obsulate Properties
[JsonProperty]
[Obsolete]
private bool IsGeneralOptionsAllTheSameEnabled
{
set => IsApplyToEverywhereEnabled = value;
}
[JsonProperty("NameplateFreeCompanyVisibility"), Obsolete]
private NameplateFreeCompanyVisibility NameplateFreeCompanyVisibilityV1
{
set
{
foreach (var key in ZoneConfig.Keys)
ZoneConfig[key].NameplateFreeCompanyVisibility = value;
}
set => GeneralConfigs.GetConfig(ZoneType.Everywhere).NameplateFreeCompanyVisibility = value;
}
[JsonProperty("NameplateTitleVisibility"), Obsolete]
public NameplateTitleVisibility NameplateTitleVisibilityV1
{
set
{
foreach (var key in ZoneConfig.Keys)
ZoneConfig[key].NameplateTitleVisibility = value;
}
set => GeneralConfigs.GetConfig(ZoneType.Everywhere).NameplateTitleVisibility = value;
}
[JsonProperty("NameplateTitlePosition"), Obsolete]
public NameplateTitlePosition NameplateTitlePositionV1
{
set
{
foreach (var key in ZoneConfig.Keys)
ZoneConfig[key].NameplateTitlePosition = value;
}
set => GeneralConfigs.GetConfig(ZoneType.Everywhere).NameplateTitlePosition = value;
}
[JsonProperty("IsApplyTagsToAllChatMessagesEnabled"), Obsolete]
private bool IsApplyTagsToAllChatMessagesEnabledV1
{
set
{
foreach (var key in ZoneConfig.Keys)
ZoneConfig[key].IsApplyTagsToAllChatMessagesEnabled = value;
}
set => GeneralConfigs.GetConfig(ZoneType.Everywhere).IsApplyTagsToAllChatMessagesEnabled = value;
}
#endregion
@@ -122,8 +114,8 @@ namespace PlayerTags.Configuration
public void Save(PluginData pluginData)
{
foreach (var zoneConfig in ZoneConfig)
zoneConfig.Value.ApplyTagsData(pluginData.GetTagsData(zoneConfig.Key));
foreach (var tagConfig in TagsConfigs)
tagConfig.Value.ApplyTagsData(pluginData.GetTagsData(tagConfig.Key));
SavePluginConfig();
@@ -175,14 +167,5 @@ namespace PlayerTags.Configuration
return jsonSettings;
}
private class GeneralOptionsClass
{
public NameplateFreeCompanyVisibility NameplateFreeCompanyVisibility = NameplateFreeCompanyVisibility.Default;
public NameplateTitleVisibility NameplateTitleVisibility = NameplateTitleVisibility.WhenHasTags;
public NameplateTitlePosition NameplateTitlePosition = NameplateTitlePosition.AlwaysAboveName;
public DeadPlayerHandling NameplateDeadPlayerHandling = DeadPlayerHandling.Include;
public bool IsApplyTagsToAllChatMessagesEnabled = true;
}
}
}

View File

@@ -9,14 +9,9 @@ using System.Threading.Tasks;
namespace PlayerTags.Configuration
{
public class PluginZoneConfiguration
public class TagsConfiguration : ZoneConfigurationBase
{
public DefaultPluginDataTemplate DefaultPluginDataTemplate = DefaultPluginDataTemplate.Simple;
public NameplateFreeCompanyVisibility NameplateFreeCompanyVisibility = NameplateFreeCompanyVisibility.Default;
public NameplateTitleVisibility NameplateTitleVisibility = NameplateTitleVisibility.WhenHasTags;
public NameplateTitlePosition NameplateTitlePosition = NameplateTitlePosition.AlwaysAboveName;
public DeadPlayerHandling NameplateDeadPlayerHandling = DeadPlayerHandling.Include;
public bool IsApplyTagsToAllChatMessagesEnabled = true;
[JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)]
public Dictionary<string, InheritableData> AllTagsChanges = new Dictionary<string, InheritableData>();

View File

@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using Pilz.Dalamud.ActivityContexts;
using PlayerTags.Data;
using PlayerTags.Inheritables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PlayerTags.Configuration
{
public class ZoneConfiguration<TConfig> : Dictionary<ZoneType, TConfig> where TConfig : ZoneConfigurationBase, new()
{
public bool IsEverywhere { get; set; } = true;
public TConfig GetConfig(ZoneType zoneType)
{
if (IsEverywhere)
zoneType = ZoneType.Everywhere;
if (!ContainsKey(zoneType))
Add(zoneType, new TConfig());
return this[zoneType];
}
}
}

View File

@@ -0,0 +1,13 @@
using Lumina.Excel.GeneratedSheets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PlayerTags.Configuration
{
public abstract class ZoneConfigurationBase
{
}
}

View File

@@ -23,13 +23,25 @@ namespace PlayerTags.Data
ReloadDefault();
}
private void EnsureDataExists(ref ZoneType zoneType)
{
if (pluginConfiguration.TagsConfigs.IsEverywhere)
zoneType = ZoneType.Everywhere;
if (!TagsData.ContainsKey(zoneType))
TagsData.Add(zoneType, new PluginTagsData(pluginConfiguration, pluginConfiguration.TagsConfigs.GetConfig(zoneType)));
}
public PluginTagsData GetTagsData(ZoneType zoneType)
{
EnsureDataExists(ref zoneType);
return TagsData[zoneType];
}
public void ReloadDefault(ZoneType zoneType)
{
EnsureDataExists(ref zoneType);
if (TagsData[zoneType].ReloadDefault())
pluginConfiguration.Save(this);
}

View File

@@ -25,9 +25,9 @@ namespace PlayerTags.Data
public Tag AllCustomTags;
public List<Tag> CustomTags;
public List<Identity> Identities;
private readonly PluginZoneConfiguration pluginZonedConfig;
private readonly TagsConfiguration pluginZonedConfig;
public PluginTagsData(PluginConfiguration pluginconfiguration, PluginZoneConfiguration pluginZonedConfiguration)
public PluginTagsData(PluginConfiguration pluginconfiguration, TagsConfiguration pluginZonedConfiguration)
{
pluginZonedConfig = pluginZonedConfiguration;
ReloadDefault();