Seperated pair tags and syncshell tags, added function to be able to add syncshell tags.
This commit is contained in:
@@ -5,5 +5,6 @@ public class ServerTagStorage
|
||||
{
|
||||
public HashSet<string> OpenPairTags { get; set; } = new(StringComparer.Ordinal);
|
||||
public HashSet<string> ServerAvailablePairTags { get; set; } = new(StringComparer.Ordinal);
|
||||
public HashSet<string> ServerAvailableSyncshellTags { get; set; } = new(StringComparer.Ordinal);
|
||||
public Dictionary<string, List<string>> UidServerPairedUserTags { get; set; } = new(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace LightlessSync.LightlessConfiguration;
|
||||
|
||||
public class ServerTagConfigService : ConfigurationServiceBase<ServerTagConfig>
|
||||
public class PairTagConfigService : ConfigurationServiceBase<ServerTagConfig>
|
||||
{
|
||||
public const string ConfigName = "servertags.json";
|
||||
|
||||
public ServerTagConfigService(string configDir) : base(configDir)
|
||||
public PairTagConfigService(string configDir) : base(configDir)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using LightlessSync.LightlessConfiguration.Configurations;
|
||||
|
||||
namespace LightlessSync.LightlessConfiguration;
|
||||
|
||||
public class SyncshellTagConfigService : ConfigurationServiceBase<ServerTagConfig>
|
||||
{
|
||||
public const string ConfigName = "serversyncshelltags.json";
|
||||
|
||||
public SyncshellTagConfigService(string configDir) : base(configDir)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ConfigurationName => ConfigName;
|
||||
}
|
||||
@@ -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<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<LightlessConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<ServerConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<NotesConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<ServerTagConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<PairTagConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<SyncshellTagConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<TransientConfigService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<XivDataStorageService>());
|
||||
collection.AddSingleton<IConfigService<ILightlessConfiguration>>(s => s.GetRequiredService<PlayerPerformanceConfigService>());
|
||||
|
||||
@@ -23,15 +23,17 @@ public class ServerConfigurationManager
|
||||
private readonly ILogger<ServerConfigurationManager> _logger;
|
||||
private readonly LightlessMediator _lightlessMediator;
|
||||
private readonly NotesConfigService _notesConfig;
|
||||
private readonly ServerTagConfigService _serverTagConfig;
|
||||
private readonly PairTagConfigService _pairTagConfig;
|
||||
private readonly SyncshellTagConfigService _syncshellTagConfig;
|
||||
|
||||
public ServerConfigurationManager(ILogger<ServerConfigurationManager> 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<string> GetServerAvailableSyncshellTags()
|
||||
{
|
||||
return CurrentServerTagStorage().ServerAvailableSyncshellTags;
|
||||
}
|
||||
|
||||
internal Dictionary<string, List<string>> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<string> GetAllTagsSorted()
|
||||
{
|
||||
return
|
||||
[
|
||||
public List<string> GetAllPairTagsSorted() => [
|
||||
.. _serverConfigurationManager.GetServerAvailablePairTags()
|
||||
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
|
||||
,
|
||||
];
|
||||
}
|
||||
|
||||
public List<string> GetAllSyncshellTagsSorted() => [
|
||||
.. _serverConfigurationManager.GetServerAvailableSyncshellTags()
|
||||
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
|
||||
,
|
||||
];
|
||||
|
||||
public HashSet<string> GetOtherUidsForTag(string tag)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user