From 4cf122934c7803bd2bd33d7191855aa9594f60c0 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Tue, 9 Sep 2025 23:19:00 +0200 Subject: [PATCH] Removed syncshelltagfolder, adding new parameters for group folder to support it in there. --- LightlessSync.sln | 8 +- LightlessSync/UI/CompactUI.cs | 6 +- .../UI/Components/DrawGroupedGroupFolder.cs | 80 ++++++++++- .../DrawGroupedSyncshellTagFolder.cs | 129 ------------------ 4 files changed, 79 insertions(+), 144 deletions(-) delete mode 100644 LightlessSync/UI/Components/DrawGroupedSyncshellTagFolder.cs diff --git a/LightlessSync.sln b/LightlessSync.sln index f24f6b2..5b7ca3c 100644 --- a/LightlessSync.sln +++ b/LightlessSync.sln @@ -22,16 +22,16 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.ActiveCfg = Debug|x64 - {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.Build.0 = Debug|x64 + {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.ActiveCfg = Release|x64 + {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|Any CPU.Build.0 = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.ActiveCfg = Debug|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Debug|x64.Build.0 = Debug|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.ActiveCfg = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|Any CPU.Build.0 = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.ActiveCfg = Release|x64 {BB929046-4CD2-B174-EBAA-C756AC3AC8DA}.Release|x64.Build.0 = Release|x64 - {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|Any CPU.Build.0 = Release|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.ActiveCfg = Debug|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Debug|x64.Build.0 = Debug|Any CPU {A4E42AFA-5045-7E81-937F-3A320AC52987}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/LightlessSync/UI/CompactUI.cs b/LightlessSync/UI/CompactUI.cs index 93785a1..7d0bfb0 100644 --- a/LightlessSync/UI/CompactUI.cs +++ b/LightlessSync/UI/CompactUI.cs @@ -506,12 +506,11 @@ public class CompactUi : WindowMediatorSubscriberBase } if (_configService.Current.GroupUpSyncshells) - drawFolders.Add(new DrawGroupedGroupFolder(groupFolders, _tagHandler, _uiSharedService)); + drawFolders.Add(new DrawGroupedGroupFolder(groupFolders, _tagHandler, _uiSharedService, _selectSyncshellForTagUi, _renameSyncshellTagUi, "")); else drawFolders.AddRange(groupFolders); var tags = _tagHandler.GetAllPairTagsSorted(); - _logger.LogDebug($"Loading {tags.Count} pair tags"); foreach (var tag in tags) { var allTagPairs = ImmutablePairList(allPairs @@ -523,7 +522,6 @@ public class CompactUi : WindowMediatorSubscriberBase } var syncshellTags = _tagHandler.GetAllSyncshellTagsSorted(); - _logger.LogDebug($"Loading {syncshellTags.Count} syncshell tags"); foreach (var syncshelltag in syncshellTags) { List syncshellFolderTags = []; @@ -538,7 +536,7 @@ public class CompactUi : WindowMediatorSubscriberBase if (syncshellFolderTags.Count > 0) { - drawFolders.Add(new DrawGroupedSyncshellTagFolder(syncshelltag, syncshellFolderTags, _tagHandler, _uiSharedService, _selectSyncshellForTagUi, _renameSyncshellTagUi)); + drawFolders.Add(new DrawGroupedGroupFolder(syncshellFolderTags, _tagHandler, _uiSharedService, _selectSyncshellForTagUi, _renameSyncshellTagUi, syncshelltag)); } } diff --git a/LightlessSync/UI/Components/DrawGroupedGroupFolder.cs b/LightlessSync/UI/Components/DrawGroupedGroupFolder.cs index 5410554..d1876ac 100644 --- a/LightlessSync/UI/Components/DrawGroupedGroupFolder.cs +++ b/LightlessSync/UI/Components/DrawGroupedGroupFolder.cs @@ -9,20 +9,27 @@ namespace LightlessSync.UI.Components; public class DrawGroupedGroupFolder : IDrawFolder { + private readonly string _tag; private readonly IEnumerable _groups; private readonly TagHandler _tagHandler; private readonly UiSharedService _uiSharedService; + private readonly SelectSyncshellForTagUi _selectSyncshellForTagUi; + private readonly RenameSyncshellTagUi _renameSyncshellTagUi; private bool _wasHovered = false; + private float _menuWidth; 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, UiSharedService uiSharedService) + public DrawGroupedGroupFolder(IEnumerable groups, TagHandler tagHandler, UiSharedService uiSharedService, SelectSyncshellForTagUi selectSyncshellForTagUi, RenameSyncshellTagUi renameSyncshellTagUi, string tag) { _groups = groups; _tagHandler = tagHandler; _uiSharedService = uiSharedService; + _selectSyncshellForTagUi = selectSyncshellForTagUi; + _renameSyncshellTagUi = renameSyncshellTagUi; + _tag = tag; } public void Draw() @@ -30,6 +37,11 @@ public class DrawGroupedGroupFolder : IDrawFolder if (!_groups.Any()) return; string _id = "__folder_syncshells"; + if (_tag != "") + { + _id = $"__folder_{_tag}"; + } + using var id = ImRaii.PushId(_id); var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered); using (ImRaii.Child("folder__" + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight()))) @@ -49,18 +61,36 @@ public class DrawGroupedGroupFolder : IDrawFolder ImGui.SameLine(); ImGui.AlignTextToFramePadding(); - _uiSharedService.IconText(FontAwesomeIcon.UsersRectangle); - using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) + + if (_tag != "") { - ImGui.SameLine(); - ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); + _uiSharedService.IconText(FontAwesomeIcon.FolderPlus); + } + else + { + _uiSharedService.IconText(FontAwesomeIcon.UsersRectangle); } + + using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) + { + ImGui.SameLine(); + ImGui.AlignTextToFramePadding(); + 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.AlignTextToFramePadding(); - ImGui.TextUnformatted("All Syncshells"); + if (_tag != "") + { + ImGui.TextUnformatted(_tag); + + ImGui.SameLine(); + DrawMenu(); + } else + { + ImGui.TextUnformatted("All Syncshells"); + } } color.Dispose(); _wasHovered = ImGui.IsItemHovered(); @@ -76,4 +106,40 @@ public class DrawGroupedGroupFolder : IDrawFolder } } } + + protected void DrawMenu() + { + var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.EllipsisV); + var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); + + ImGui.SameLine(windowEndX - barButtonSize.X); + if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV)) + { + ImGui.OpenPopup("User Flyout Menu"); + } + if (ImGui.BeginPopup("User Flyout Menu")) + { + using (ImRaii.PushId($"buttons-syncshell-{_tag}")) GroupMenu(_menuWidth); + _menuWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; + ImGui.EndPopup(); + } + } + + protected void GroupMenu(float menuWidth) + { + ImGui.TextUnformatted("Syncshell Group Menu"); + if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Select Syncshells", menuWidth, isInPopup: true)) + { + _selectSyncshellForTagUi.Open(_tag); + } + if (_uiSharedService.IconTextButton(FontAwesomeIcon.Edit, "Rename Syncshell Group", menuWidth, isInPopup: true)) + { + _renameSyncshellTagUi.Open(_tag); + } + if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell Group", menuWidth, isInPopup: true) && UiSharedService.CtrlPressed()) + { + _tagHandler.RemoveSyncshellTag(_tag); + } + UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently."); + } } diff --git a/LightlessSync/UI/Components/DrawGroupedSyncshellTagFolder.cs b/LightlessSync/UI/Components/DrawGroupedSyncshellTagFolder.cs deleted file mode 100644 index 8401e9a..0000000 --- a/LightlessSync/UI/Components/DrawGroupedSyncshellTagFolder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Dalamud.Bindings.ImGui; -using Dalamud.Interface; -using Dalamud.Interface.Utility.Raii; -using LightlessSync.UI.Handlers; -using System.Collections.Immutable; -using System.Numerics; - -namespace LightlessSync.UI.Components; - -public class DrawGroupedSyncshellTagFolder : IDrawFolder -{ - private readonly string _tag; - private readonly IEnumerable _groups; - private readonly TagHandler _tagHandler; - private readonly UiSharedService _uiSharedService; - private readonly SelectSyncshellForTagUi _selectSyncshellForTagUi; - private readonly RenameSyncshellTagUi _renameSyncshellTagUi; - private bool _wasHovered = false; - private float _menuWidth = -1; - - 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 DrawGroupedSyncshellTagFolder(string tag, IEnumerable groups, TagHandler tagHandler, UiSharedService uiSharedService, - SelectSyncshellForTagUi selectSyncshellForTagUi, RenameSyncshellTagUi renameSyncshellTagUi) - { - _tag = tag; - _groups = groups; - _tagHandler = tagHandler; - _uiSharedService = uiSharedService; - _selectSyncshellForTagUi = selectSyncshellForTagUi; - _renameSyncshellTagUi = renameSyncshellTagUi; - } - - public void Draw() - { - if (!_groups.Any()) return; - - string _id = $"__folder_{_tag}"; - using var id = ImRaii.PushId(_id); - var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered); - using (ImRaii.Child("folder__" + _id, new Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight()))) - { - ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight())); - using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 0f))) - ImGui.SameLine(); - - var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight; - ImGui.AlignTextToFramePadding(); - - _uiSharedService.IconText(icon); - if (ImGui.IsItemClicked()) - { - _tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id)); - } - - ImGui.SameLine(); - ImGui.AlignTextToFramePadding(); - _uiSharedService.IconText(FontAwesomeIcon.FolderPlus); - using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) - { - ImGui.SameLine(); - ImGui.AlignTextToFramePadding(); - 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.AlignTextToFramePadding(); - ImGui.TextUnformatted(_tag); - - ImGui.SameLine(); - ImGui.AlignTextToFramePadding(); - DrawMenu(); - } - color.Dispose(); - _wasHovered = ImGui.IsItemHovered(); - - if (_tagHandler.IsTagOpen(_id)) - { - using var indent = ImRaii.PushIndent(20f); - foreach (var entry in _groups) - { - entry.Draw(); - } - } - } - - protected void DrawMenu() - { - var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.EllipsisV); - var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); - - ImGui.SameLine(windowEndX - barButtonSize.X); - if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV)) - { - ImGui.OpenPopup("User Flyout Menu"); - } - if (ImGui.BeginPopup("User Flyout Menu")) - { - using (ImRaii.PushId($"buttons-syncshell-{_tag}")) GroupMenu(_menuWidth); - _menuWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; - ImGui.EndPopup(); - } - else - { - _menuWidth = 0; - } - } - - protected void GroupMenu(float menuWidth) - { - ImGui.TextUnformatted("Syncshell Group Menu"); - if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Select Syncshells", menuWidth, isInPopup: true)) - { - _selectSyncshellForTagUi.Open(_tag); - } - if (_uiSharedService.IconTextButton(FontAwesomeIcon.Edit, "Rename Syncshell Group", menuWidth, isInPopup: true)) - { - _renameSyncshellTagUi.Open(_tag); - } - if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell Group", menuWidth, isInPopup: true) && UiSharedService.CtrlPressed()) - { - _tagHandler.RemoveSyncshellTag(_tag); - } - UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently."); - } -}