Fixed some issues with syncshell saving, fetching of tags and spacing issues. Added button for rename/select/remove.
This commit is contained in:
@@ -13,18 +13,24 @@ public class DrawGroupedSyncshellTagFolder : IDrawFolder
|
||||
private readonly IEnumerable<IDrawFolder> _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<DrawUserPair> 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<IDrawFolder> groups, TagHandler tagHandler, UiSharedService uiSharedService)
|
||||
public DrawGroupedSyncshellTagFolder(string tag, IEnumerable<IDrawFolder> groups, TagHandler tagHandler, UiSharedService uiSharedService,
|
||||
SelectSyncshellForTagUi selectSyncshellForTagUi, RenameSyncshellTagUi renameSyncshellTagUi)
|
||||
{
|
||||
_tag = tag;
|
||||
_groups = groups;
|
||||
_tagHandler = tagHandler;
|
||||
_uiSharedService = uiSharedService;
|
||||
_selectSyncshellForTagUi = selectSyncshellForTagUi;
|
||||
_renameSyncshellTagUi = renameSyncshellTagUi;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
@@ -51,7 +57,7 @@ public class DrawGroupedSyncshellTagFolder : IDrawFolder
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.UsersRectangle);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.FolderPlus);
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
@@ -63,12 +69,14 @@ public class DrawGroupedSyncshellTagFolder : IDrawFolder
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(_tag);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
DrawMenu();
|
||||
}
|
||||
color.Dispose();
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (_tagHandler.IsTagOpen(_id))
|
||||
{
|
||||
using var indent = ImRaii.PushIndent(20f);
|
||||
@@ -78,4 +86,45 @@ public class DrawGroupedSyncshellTagFolder : 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();
|
||||
}
|
||||
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.RemovePairTag(_tag);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently." + Environment.NewLine +
|
||||
"Note: this will not unpair with users in this Group.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class RenameSyncshellTagUi
|
||||
var minSize = new Vector2(300, workHeight < 110 ? workHeight : 110) * ImGuiHelpers.GlobalScale;
|
||||
var maxSize = new Vector2(300, 110) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
var popupName = $"Renaming Pair Group {_tag}";
|
||||
var popupName = $"Renaming Syncshell Group {_tag}";
|
||||
|
||||
if (!_show)
|
||||
{
|
||||
@@ -74,6 +74,6 @@ public class RenameSyncshellTagUi
|
||||
|
||||
public void RenameTag(string oldTag, string newTag)
|
||||
{
|
||||
_tagHandler.RenamePairTag(oldTag, newTag);
|
||||
_tagHandler.RenameSyncshellTag(oldTag, newTag);
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,11 @@ public class SelectSyncshellForTagUi
|
||||
ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
|
||||
foreach (var group in groups
|
||||
.Where(g => string.IsNullOrEmpty(_filter) || g.GID.Contains(_filter, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(g => g.GID, StringComparer.OrdinalIgnoreCase)
|
||||
.OrderBy(g => g.GroupAliasOrGID, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList())
|
||||
{
|
||||
var isInGroup = _syncshellsInGroup.Contains(group.GID);
|
||||
if (ImGui.Checkbox(group.GID, ref isInGroup))
|
||||
if (ImGui.Checkbox(group.GroupAliasOrGID, ref isInGroup))
|
||||
{
|
||||
if (isInGroup)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user