using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using ImGuiNET; using MareSynchronos.UI.Handlers; using System.Collections.Immutable; namespace MareSynchronos.UI.Components; public class DrawGroupedGroupFolder : IDrawFolder { private readonly IEnumerable _groups; private readonly TagHandler _tagHandler; public IImmutableList DrawPairs => throw new NotSupportedException(); public int OnlinePairs => _groups.SelectMany(g => g.DrawPairs).Where(g => g.Pair.IsOnline).DistinctBy(g => g.Pair.UserData.UID).Count(); public int TotalPairs => _groups.Sum(g => g.TotalPairs); public DrawGroupedGroupFolder(IEnumerable groups, TagHandler tagHandler) { _groups = groups; _tagHandler = tagHandler; } public void Draw() { if (!_groups.Any()) return; string _id = "__folder_syncshells"; using var id = ImRaii.PushId(_id); var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight; UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont); if (ImGui.IsItemClicked()) { _tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id)); } ImGui.SameLine(); using (ImRaii.PushFont(UiBuilder.IconFont)) ImGui.TextUnformatted(FontAwesomeIcon.UsersRectangle.ToIconString()); using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) { ImGui.SameLine(); ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); } UiSharedService.AttachToolTip(OnlinePairs + " online in all of your joined syncshells" + Environment.NewLine + TotalPairs + " pairs combined in all of your joined syncshells"); ImGui.SameLine(); ImGui.TextUnformatted("All Syncshells"); ImGui.Separator(); if (_tagHandler.IsTagOpen(_id)) { using var indent = ImRaii.PushIndent(20f); foreach (var entry in _groups) { entry.Draw(); } } } }