From 806a4baf1a7e5371b5e695f3f329b8369df02a06 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Sun, 7 Sep 2025 15:28:19 +0200 Subject: [PATCH] Seperated pair tags and syncshell tags, added function to be able to add syncshell tags. --- .../Models/ServerTagStorage.cs | 1 + ...nfigService.cs => PairTagConfigService.cs} | 4 +- .../SyncshellTagConfigService.cs | 14 +++++++ LightlessSync/Plugin.cs | 6 ++- .../ServerConfigurationManager.cs | 40 +++++++++++++------ LightlessSync/UI/CompactUI.cs | 15 ++++++- LightlessSync/UI/Components/RenameTagUi.cs | 2 +- .../UI/Components/SelectTagForPairUi.cs | 4 +- LightlessSync/UI/Handlers/TagHandler.cs | 24 +++++------ 9 files changed, 75 insertions(+), 35 deletions(-) rename LightlessSync/LightlessConfiguration/{ServerTagConfigService.cs => PairTagConfigService.cs} (62%) create mode 100644 LightlessSync/LightlessConfiguration/SyncshellTagConfigService.cs diff --git a/LightlessSync/LightlessConfiguration/Models/ServerTagStorage.cs b/LightlessSync/LightlessConfiguration/Models/ServerTagStorage.cs index 75d3f46..d656214 100644 --- a/LightlessSync/LightlessConfiguration/Models/ServerTagStorage.cs +++ b/LightlessSync/LightlessConfiguration/Models/ServerTagStorage.cs @@ -5,5 +5,6 @@ public class ServerTagStorage { public HashSet OpenPairTags { get; set; } = new(StringComparer.Ordinal); public HashSet ServerAvailablePairTags { get; set; } = new(StringComparer.Ordinal); + public HashSet ServerAvailableSyncshellTags { get; set; } = new(StringComparer.Ordinal); public Dictionary> UidServerPairedUserTags { get; set; } = new(StringComparer.Ordinal); } diff --git a/LightlessSync/LightlessConfiguration/ServerTagConfigService.cs b/LightlessSync/LightlessConfiguration/PairTagConfigService.cs similarity index 62% rename from LightlessSync/LightlessConfiguration/ServerTagConfigService.cs rename to LightlessSync/LightlessConfiguration/PairTagConfigService.cs index b31e746..07cb72a 100644 --- a/LightlessSync/LightlessConfiguration/ServerTagConfigService.cs +++ b/LightlessSync/LightlessConfiguration/PairTagConfigService.cs @@ -2,11 +2,11 @@ namespace LightlessSync.LightlessConfiguration; -public class ServerTagConfigService : ConfigurationServiceBase +public class PairTagConfigService : ConfigurationServiceBase { public const string ConfigName = "servertags.json"; - public ServerTagConfigService(string configDir) : base(configDir) + public PairTagConfigService(string configDir) : base(configDir) { } diff --git a/LightlessSync/LightlessConfiguration/SyncshellTagConfigService.cs b/LightlessSync/LightlessConfiguration/SyncshellTagConfigService.cs new file mode 100644 index 0000000..6fc7f6a --- /dev/null +++ b/LightlessSync/LightlessConfiguration/SyncshellTagConfigService.cs @@ -0,0 +1,14 @@ +using LightlessSync.LightlessConfiguration.Configurations; + +namespace LightlessSync.LightlessConfiguration; + +public class SyncshellTagConfigService : ConfigurationServiceBase +{ + public const string ConfigName = "serversyncshelltags.json"; + + public SyncshellTagConfigService(string configDir) : base(configDir) + { + } + + public override string ConfigurationName => ConfigName; +} \ No newline at end of file diff --git a/LightlessSync/Plugin.cs b/LightlessSync/Plugin.cs index 7e00038..cf9b41c 100644 --- a/LightlessSync/Plugin.cs +++ b/LightlessSync/Plugin.cs @@ -175,7 +175,8 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton((s) => new LightlessConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new NotesConfigService(pluginInterface.ConfigDirectory.FullName)); - collection.AddSingleton((s) => new ServerTagConfigService(pluginInterface.ConfigDirectory.FullName)); + collection.AddSingleton((s) => new PairTagConfigService(pluginInterface.ConfigDirectory.FullName)); + collection.AddSingleton((s) => new SyncshellTagConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new TransientConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new XivDataStorageService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new PlayerPerformanceConfigService(pluginInterface.ConfigDirectory.FullName)); @@ -183,7 +184,8 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton>(s => s.GetRequiredService()); - collection.AddSingleton>(s => s.GetRequiredService()); + collection.AddSingleton>(s => s.GetRequiredService()); + collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton>(s => s.GetRequiredService()); diff --git a/LightlessSync/Services/ServerConfiguration/ServerConfigurationManager.cs b/LightlessSync/Services/ServerConfiguration/ServerConfigurationManager.cs index 8bff7f9..487a1e3 100644 --- a/LightlessSync/Services/ServerConfiguration/ServerConfigurationManager.cs +++ b/LightlessSync/Services/ServerConfiguration/ServerConfigurationManager.cs @@ -23,15 +23,17 @@ public class ServerConfigurationManager private readonly ILogger _logger; private readonly LightlessMediator _lightlessMediator; private readonly NotesConfigService _notesConfig; - private readonly ServerTagConfigService _serverTagConfig; + private readonly PairTagConfigService _pairTagConfig; + private readonly SyncshellTagConfigService _syncshellTagConfig; public ServerConfigurationManager(ILogger logger, ServerConfigService configService, - ServerTagConfigService serverTagConfig, NotesConfigService notesConfig, DalamudUtilService dalamudUtil, + PairTagConfigService pairTagConfig, SyncshellTagConfigService syncshellTagConfig, NotesConfigService notesConfig, DalamudUtilService dalamudUtil, LightlessConfigService lightlessConfigService, HttpClient httpClient, LightlessMediator lightlessMediator) { _logger = logger; _configService = configService; - _serverTagConfig = serverTagConfig; + _pairTagConfig = pairTagConfig; + _syncshellTagConfig = syncshellTagConfig; _notesConfig = notesConfig; _dalamudUtil = dalamudUtil; _lightlessConfigService = lightlessConfigService; @@ -285,7 +287,7 @@ public class ServerConfigurationManager internal void AddOpenPairTag(string tag) { CurrentServerTagStorage().OpenPairTags.Add(tag); - _serverTagConfig.Save(); + _pairTagConfig.Save(); } internal void AddServer(ServerStorage serverStorage) @@ -294,10 +296,17 @@ public class ServerConfigurationManager Save(); } - internal void AddTag(string tag) + internal void AddPairTag(string tag) { CurrentServerTagStorage().ServerAvailablePairTags.Add(tag); - _serverTagConfig.Save(); + _pairTagConfig.Save(); + _lightlessMediator.Publish(new RefreshUiMessage()); + } + + internal void AddSyncshellTag(string tag) + { + CurrentServerTagStorage().ServerAvailableSyncshellTags.Add(tag); + _pairTagConfig.Save(); _lightlessMediator.Publish(new RefreshUiMessage()); } @@ -313,7 +322,7 @@ public class ServerConfigurationManager CurrentServerTagStorage().UidServerPairedUserTags[uid] = [tagName]; } - _serverTagConfig.Save(); + _pairTagConfig.Save(); } internal bool ContainsOpenPairTag(string tag) @@ -369,6 +378,11 @@ public class ServerConfigurationManager return CurrentServerTagStorage().ServerAvailablePairTags; } + internal HashSet GetServerAvailableSyncshellTags() + { + return CurrentServerTagStorage().ServerAvailableSyncshellTags; + } + internal Dictionary> GetUidServerPairedUserTags() { return CurrentServerTagStorage().UidServerPairedUserTags; @@ -399,7 +413,7 @@ public class ServerConfigurationManager internal void RemoveOpenPairTag(string tag) { CurrentServerTagStorage().OpenPairTags.Remove(tag); - _serverTagConfig.Save(); + _pairTagConfig.Save(); } internal void RemoveTag(string tag) @@ -409,7 +423,7 @@ public class ServerConfigurationManager { RemoveTagForUid(uid, tag, save: false); } - _serverTagConfig.Save(); + _pairTagConfig.Save(); _lightlessMediator.Publish(new RefreshUiMessage()); } @@ -421,7 +435,7 @@ public class ServerConfigurationManager if (save) { - _serverTagConfig.Save(); + _pairTagConfig.Save(); _lightlessMediator.Publish(new RefreshUiMessage()); } } @@ -479,7 +493,7 @@ public class ServerConfigurationManager private ServerTagStorage CurrentServerTagStorage() { TryCreateCurrentServerTagStorage(); - return _serverTagConfig.Current.ServerTagStorage[CurrentApiUrl]; + return _pairTagConfig.Current.ServerTagStorage[CurrentApiUrl]; } private void EnsureMainExists() @@ -501,9 +515,9 @@ public class ServerConfigurationManager private void TryCreateCurrentServerTagStorage() { - if (!_serverTagConfig.Current.ServerTagStorage.ContainsKey(CurrentApiUrl)) + if (!_pairTagConfig.Current.ServerTagStorage.ContainsKey(CurrentApiUrl)) { - _serverTagConfig.Current.ServerTagStorage[CurrentApiUrl] = new(); + _pairTagConfig.Current.ServerTagStorage[CurrentApiUrl] = new(); } } diff --git a/LightlessSync/UI/CompactUI.cs b/LightlessSync/UI/CompactUI.cs index 5c1ae53..02d5975 100644 --- a/LightlessSync/UI/CompactUI.cs +++ b/LightlessSync/UI/CompactUI.cs @@ -516,7 +516,8 @@ public class CompactUi : WindowMediatorSubscriberBase else drawFolders.AddRange(groupFolders); - var tags = _tagHandler.GetAllTagsSorted(); + var tags = _tagHandler.GetAllPairTagsSorted(); + _logger.LogInformation($"Loading {tags.Count} pair tags"); foreach (var tag in tags) { var allTagPairs = ImmutablePairList(allPairs @@ -527,6 +528,18 @@ public class CompactUi : WindowMediatorSubscriberBase drawFolders.Add(_drawEntityFactory.CreateDrawTagFolder(tag, filteredTagPairs, allTagPairs)); } + var syncshellTags = _tagHandler.GetAllSyncshellTagsSorted(); + _logger.LogInformation($"Loading {syncshellTags.Count} syncshell tags"); + foreach (var syncshelltag in syncshellTags) + { + var allTagPairs = ImmutablePairList(allPairs + .Where(u => FilterTagusers(u, syncshelltag))); + var filteredTagPairs = BasicSortedDictionary(filteredPairs + .Where(u => FilterTagusers(u, syncshelltag) && FilterOnlineOrPausedSelf(u))); + + drawFolders.Add(_drawEntityFactory.CreateDrawTagFolder(syncshelltag, filteredTagPairs, allTagPairs)); + } + var allOnlineNotTaggedPairs = ImmutablePairList(allPairs .Where(FilterNotTaggedUsers)); var onlineNotTaggedPairs = BasicSortedDictionary(filteredPairs diff --git a/LightlessSync/UI/Components/RenameTagUi.cs b/LightlessSync/UI/Components/RenameTagUi.cs index 1d71f64..139353a 100644 --- a/LightlessSync/UI/Components/RenameTagUi.cs +++ b/LightlessSync/UI/Components/RenameTagUi.cs @@ -80,7 +80,7 @@ public class RenameTagUi _tagHandler.RemoveTag(oldTag); //Creation of new tag and adding of old group pairs in new one. - _tagHandler.AddTag(newTag); + _tagHandler.AddPairTag(newTag); foreach (Pair pair in pairs) { var isInTag = _peopleInGroup.Contains(pair.UserData.UID); diff --git a/LightlessSync/UI/Components/SelectTagForPairUi.cs b/LightlessSync/UI/Components/SelectTagForPairUi.cs index e258f9c..c9ee5fa 100644 --- a/LightlessSync/UI/Components/SelectTagForPairUi.cs +++ b/LightlessSync/UI/Components/SelectTagForPairUi.cs @@ -59,7 +59,7 @@ public class SelectTagForPairUi if (ImGui.BeginPopup(popupName)) { - var tags = _tagHandler.GetAllTagsSorted(); + var tags = _tagHandler.GetAllPairTagsSorted(); var childHeight = tags.Count != 0 ? tags.Count * 25 : 1; var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale; @@ -120,7 +120,7 @@ public class SelectTagForPairUi { if (!_tagNameToAdd.IsNullOrWhitespace() && _tagNameToAdd is not (TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag)) { - _tagHandler.AddTag(_tagNameToAdd); + _tagHandler.AddPairTag(_tagNameToAdd); if (_pair != null) { _tagHandler.AddTagToPairedUid(_pair.UserData.UID, _tagNameToAdd); diff --git a/LightlessSync/UI/Handlers/TagHandler.cs b/LightlessSync/UI/Handlers/TagHandler.cs index f721508..69d0f28 100644 --- a/LightlessSync/UI/Handlers/TagHandler.cs +++ b/LightlessSync/UI/Handlers/TagHandler.cs @@ -17,25 +17,21 @@ public class TagHandler _serverConfigurationManager = serverConfigurationManager; } - public void AddTag(string tag) - { - _serverConfigurationManager.AddTag(tag); - } + public void AddPairTag(string tag) => _serverConfigurationManager.AddPairTag(tag); + public void AddSyncshellTag(string tag) => _serverConfigurationManager.AddSyncshellTag(tag); + public void AddTagToPairedUid(string uid, string tagName) => _serverConfigurationManager.AddTagForUid(uid, tagName); - public void AddTagToPairedUid(string uid, string tagName) - { - _serverConfigurationManager.AddTagForUid(uid, tagName); - } - - public List GetAllTagsSorted() - { - return - [ + public List GetAllPairTagsSorted() => [ .. _serverConfigurationManager.GetServerAvailablePairTags() .OrderBy(s => s, StringComparer.OrdinalIgnoreCase) , ]; - } + + public List GetAllSyncshellTagsSorted() => [ + .. _serverConfigurationManager.GetServerAvailableSyncshellTags() + .OrderBy(s => s, StringComparer.OrdinalIgnoreCase) +, + ]; public HashSet GetOtherUidsForTag(string tag) {