split individual ui to visible/group/online/offline
This commit is contained in:
2
MareAPI
2
MareAPI
Submodule MareAPI updated: 7c5bf39c31...f604e6d27e
@@ -554,40 +554,6 @@ public class CompactUi : Window, IDisposable
|
|||||||
|
|
||||||
_pairGroupsUi.Draw(visibleUsers, onlineUsers, offlineUsers);
|
_pairGroupsUi.Draw(visibleUsers, onlineUsers, offlineUsers);
|
||||||
|
|
||||||
visibleUsers = visibleUsers.Where(pair => !_tagHandler.HasAnyTag(pair.UserPair!)).ToList();
|
|
||||||
onlineUsers = onlineUsers.Where(pair => !_tagHandler.HasAnyTag(pair.UserPair!)).ToList();
|
|
||||||
offlineUsers = offlineUsers.Where(pair => !_tagHandler.HasAnyTag(pair.UserPair!)).ToList();
|
|
||||||
|
|
||||||
if (visibleUsers.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Visible");
|
|
||||||
ImGui.Separator();
|
|
||||||
foreach (var entry in visibleUsers)
|
|
||||||
{
|
|
||||||
UiShared.DrawWithID(entry.UserData.UID, () => DrawPairedClient(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlineUsers.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Online");
|
|
||||||
ImGui.Separator();
|
|
||||||
foreach (var entry in onlineUsers)
|
|
||||||
{
|
|
||||||
UiShared.DrawWithID(entry.UserData.UID, () => DrawPairedClient(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offlineUsers.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Offline/Unknown");
|
|
||||||
ImGui.Separator();
|
|
||||||
foreach (var entry in offlineUsers)
|
|
||||||
{
|
|
||||||
UiShared.DrawWithID(entry.UserData.UID, () => DrawPairedClient(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,59 +28,54 @@ namespace MareSynchronos.UI.Components
|
|||||||
// Only render those tags that actually have pairs in them, otherwise
|
// Only render those tags that actually have pairs in them, otherwise
|
||||||
// we can end up with a bunch of useless pair groups
|
// we can end up with a bunch of useless pair groups
|
||||||
var tagsWithPairsInThem = _tagHandler.GetAllTagsSorted();
|
var tagsWithPairsInThem = _tagHandler.GetAllTagsSorted();
|
||||||
|
UiShared.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers));
|
||||||
foreach (var tag in tagsWithPairsInThem)
|
foreach (var tag in tagsWithPairsInThem)
|
||||||
{
|
{
|
||||||
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, visibleUsers, onlineUsers, offlineUsers));
|
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers));
|
||||||
}
|
}
|
||||||
|
UiShared.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag, onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UserPair!)).ToList()));
|
||||||
|
UiShared.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag, offlineUsers));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawCategory(string tag, List<Pair> visibleUsers, List<Pair> onlineUsers, List<Pair> offlineUsers)
|
private void DrawCategory(string tag, List<Pair> users)
|
||||||
{
|
{
|
||||||
var otherUidsTaggedWithTag = _tagHandler.GetOtherUidsForTag(tag);
|
List<Pair> usersInThisTag;
|
||||||
var visiblePairsInThisTag = visibleUsers
|
HashSet<string>? otherUidsTaggedWithTag = null;
|
||||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
if (tag is TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag)
|
||||||
.ToList();
|
|
||||||
var onlinePairsInThisTag = onlineUsers
|
|
||||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
|
||||||
.ToList();
|
|
||||||
var offlinePairsInThisTag = offlineUsers
|
|
||||||
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
|
||||||
.ToList();
|
|
||||||
if (visiblePairsInThisTag.Any() || onlinePairsInThisTag.Any() || offlinePairsInThisTag.Any())
|
|
||||||
{
|
{
|
||||||
DrawName(tag);
|
usersInThisTag = users;
|
||||||
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, visiblePairsInThisTag.Concat(onlinePairsInThisTag).Concat(offlinePairsInThisTag).ToList()));
|
|
||||||
if (_tagHandler.IsTagOpen(tag))
|
|
||||||
{
|
|
||||||
ImGui.Indent(20);
|
|
||||||
if (visiblePairsInThisTag.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Visible");
|
|
||||||
ImGui.Separator();
|
|
||||||
DrawPairs(tag, visiblePairsInThisTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlinePairsInThisTag.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Online");
|
|
||||||
ImGui.Separator();
|
|
||||||
DrawPairs(tag, onlinePairsInThisTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offlinePairsInThisTag.Any())
|
|
||||||
{
|
|
||||||
ImGui.Text("Offline/Unknown");
|
|
||||||
ImGui.Separator();
|
|
||||||
DrawPairs(tag, offlinePairsInThisTag);
|
|
||||||
}
|
|
||||||
ImGui.Unindent(20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
otherUidsTaggedWithTag = _tagHandler.GetOtherUidsForTag(tag);
|
||||||
|
usersInThisTag = users
|
||||||
|
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usersInThisTag.Any()) return;
|
||||||
|
|
||||||
|
DrawName(tag, usersInThisTag.Count, otherUidsTaggedWithTag?.Count);
|
||||||
|
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, usersInThisTag));
|
||||||
|
|
||||||
|
if (!_tagHandler.IsTagOpen(tag)) return;
|
||||||
|
|
||||||
|
ImGui.Indent(20);
|
||||||
|
DrawPairs(tag, usersInThisTag);
|
||||||
|
ImGui.Unindent(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawName(string tag)
|
private void DrawName(string tag, int count, int? total)
|
||||||
{
|
{
|
||||||
var resultFolderName = $"{tag}";
|
string displayedName = tag switch
|
||||||
|
{
|
||||||
|
TagHandler.CustomOfflineTag => "Offline/Unknown",
|
||||||
|
TagHandler.CustomOnlineTag => "Online",
|
||||||
|
TagHandler.CustomVisibleTag => "Visible",
|
||||||
|
_ => tag
|
||||||
|
};
|
||||||
|
|
||||||
|
string resultFolderName = total != null ? $"{displayedName} ({count}/{total} Pairs)" : $"{displayedName} ({count} 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;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class SelectGroupForPairUi
|
|||||||
var tags = _tagHandler.GetAllTagsSorted();
|
var tags = _tagHandler.GetAllTagsSorted();
|
||||||
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
|
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
|
||||||
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
|
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
|
||||||
|
|
||||||
UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
|
UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
|
||||||
if (ImGui.BeginChild(name + "##listGroups", childSize))
|
if (ImGui.BeginChild(name + "##listGroups", childSize))
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ public class SelectGroupForPairUi
|
|||||||
|
|
||||||
private void HandleAddTag()
|
private void HandleAddTag()
|
||||||
{
|
{
|
||||||
if (!_tagNameToAdd.IsNullOrWhitespace())
|
if (!_tagNameToAdd.IsNullOrWhitespace() && _tagNameToAdd is not (TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag))
|
||||||
{
|
{
|
||||||
_tagHandler.AddTag(_tagNameToAdd);
|
_tagHandler.AddTag(_tagNameToAdd);
|
||||||
if (_pair != null)
|
if (_pair != null)
|
||||||
@@ -124,6 +124,10 @@ public class SelectGroupForPairUi
|
|||||||
}
|
}
|
||||||
_tagNameToAdd = string.Empty;
|
_tagNameToAdd = string.Empty;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tagNameToAdd = string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
|
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ namespace MareSynchronos.UI.Handlers
|
|||||||
public class TagHandler
|
public class TagHandler
|
||||||
{
|
{
|
||||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||||
|
public const string CustomVisibleTag = "Mare_Visible";
|
||||||
|
public const string CustomOnlineTag = "Mare_Online";
|
||||||
|
public const string CustomOfflineTag = "Mare_Offline";
|
||||||
|
|
||||||
public TagHandler(ServerConfigurationManager serverConfigurationManager)
|
public TagHandler(ServerConfigurationManager serverConfigurationManager)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user