change display of local groups

This commit is contained in:
Stanley Dimant
2023-01-31 10:10:27 +01:00
parent f024486932
commit 12f0789e9c
3 changed files with 31 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.7.10</Version> <Version>0.7.11</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -182,20 +182,19 @@ public sealed class Plugin : IDalamudPlugin
if (string.Equals(splitArgs[0], "toggle", StringComparison.OrdinalIgnoreCase)) if (string.Equals(splitArgs[0], "toggle", StringComparison.OrdinalIgnoreCase))
{ {
var _serverConfigurationManager = _serviceProvider.GetRequiredService<ServerConfigurationManager>(); var serverConfigurationManager = _serviceProvider.GetRequiredService<ServerConfigurationManager>();
var _apiController = _serviceProvider.GetRequiredService<ApiController>(); if (serverConfigurationManager.CurrentServer == null) return;
if (_serverConfigurationManager.CurrentServer == null) return;
var fullPause = splitArgs.Length > 1 ? splitArgs[1] switch var fullPause = splitArgs.Length > 1 ? splitArgs[1] switch
{ {
"on" => false, "on" => false,
"off" => true, "off" => true,
_ => !_serverConfigurationManager.CurrentServer.FullPause, _ => !serverConfigurationManager.CurrentServer.FullPause,
} : !_serverConfigurationManager.CurrentServer.FullPause; } : !serverConfigurationManager.CurrentServer.FullPause;
if (fullPause != _serverConfigurationManager.CurrentServer.FullPause) if (fullPause != serverConfigurationManager.CurrentServer.FullPause)
{ {
_serverConfigurationManager.CurrentServer.FullPause = fullPause; serverConfigurationManager.CurrentServer.FullPause = fullPause;
_serverConfigurationManager.Save(); serverConfigurationManager.Save();
_ = _serviceProvider.GetRequiredService<ApiController>().CreateConnections(); _ = _serviceProvider.GetRequiredService<ApiController>().CreateConnections();
} }
} }

View File

@@ -31,19 +31,22 @@ namespace MareSynchronos.UI.Components
UiShared.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers)); UiShared.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers));
foreach (var tag in tagsWithPairsInThem) foreach (var tag in tagsWithPairsInThem)
{ {
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers)); UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers, visibleUsers));
} }
UiShared.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag, onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UserPair!)).ToList())); UiShared.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag, onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UserPair!)).ToList()));
UiShared.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag, offlineUsers)); UiShared.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag, offlineUsers));
} }
private void DrawCategory(string tag, List<Pair> users) private void DrawCategory(string tag, List<Pair> users, List<Pair>? visibleUsers = null)
{ {
List<Pair> usersInThisTag; List<Pair> usersInThisTag;
HashSet<string>? otherUidsTaggedWithTag = null; HashSet<string>? otherUidsTaggedWithTag = null;
bool isSpecialTag = false;
int visibleInThisTag = 0;
if (tag is TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag) if (tag is TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag)
{ {
usersInThisTag = users; usersInThisTag = users;
isSpecialTag = true;
} }
else else
{ {
@@ -51,11 +54,13 @@ namespace MareSynchronos.UI.Components
usersInThisTag = users usersInThisTag = users
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID)) .Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
.ToList(); .ToList();
visibleInThisTag = visibleUsers?.Count(p => otherUidsTaggedWithTag.Contains(p.UserData.UID)) ?? 0;
} }
if (!usersInThisTag.Any()) return; if (isSpecialTag && !usersInThisTag.Any()) return;
DrawName(tag, usersInThisTag.Count, otherUidsTaggedWithTag?.Count); DrawName(tag, isSpecialTag, visibleInThisTag, usersInThisTag.Count, otherUidsTaggedWithTag?.Count);
if (!isSpecialTag)
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, usersInThisTag)); UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, usersInThisTag));
if (!_tagHandler.IsTagOpen(tag)) return; if (!_tagHandler.IsTagOpen(tag)) return;
@@ -65,7 +70,7 @@ namespace MareSynchronos.UI.Components
ImGui.Unindent(20); ImGui.Unindent(20);
} }
private void DrawName(string tag, int count, int? total) private void DrawName(string tag, bool isSpecialTag, int visible, int online, int? total)
{ {
string displayedName = tag switch string displayedName = tag switch
{ {
@@ -75,7 +80,7 @@ namespace MareSynchronos.UI.Components
_ => tag _ => tag
}; };
string resultFolderName = total != null ? $"{displayedName} ({count}/{total} Pairs)" : $"{displayedName} ({count} Pairs)"; string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight // FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight; var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
@@ -90,6 +95,17 @@ namespace MareSynchronos.UI.Components
{ {
ToggleTagOpen(tag); ToggleTagOpen(tag);
} }
if (!isSpecialTag && ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextUnformatted($"Group {tag}");
ImGui.Separator();
ImGui.TextUnformatted($"{visible} Pairs visible");
ImGui.TextUnformatted($"{online} Pairs online");
ImGui.TextUnformatted($"{total} Pairs total");
ImGui.EndTooltip();
}
} }
private void DrawButtons(string tag, List<Pair> availablePairsInThisTag) private void DrawButtons(string tag, List<Pair> availablePairsInThisTag)