add GroupForPairUi
This commit is contained in:
@@ -47,6 +47,7 @@ public class CompactUi : Window, IDisposable
|
|||||||
private string _lastAddedUserComment = string.Empty;
|
private string _lastAddedUserComment = string.Empty;
|
||||||
|
|
||||||
private readonly SelectGroupForPairUi _selectGroupForPairUi;
|
private readonly SelectGroupForPairUi _selectGroupForPairUi;
|
||||||
|
private readonly SelectPairForGroupUi _selectPairsForGroupUi;
|
||||||
private readonly PairGroupsUi _pairGroupsUi;
|
private readonly PairGroupsUi _pairGroupsUi;
|
||||||
|
|
||||||
public CompactUi(WindowSystem windowSystem,
|
public CompactUi(WindowSystem windowSystem,
|
||||||
@@ -81,7 +82,8 @@ public class CompactUi : Window, IDisposable
|
|||||||
|
|
||||||
groupPanel = new(this, uiShared, configuration, apiController);
|
groupPanel = new(this, uiShared, configuration, apiController);
|
||||||
_selectGroupForPairUi = new(_tagHandler, configuration);
|
_selectGroupForPairUi = new(_tagHandler, configuration);
|
||||||
_pairGroupsUi = new(_tagHandler, DrawPairedClient, apiController);
|
_selectPairsForGroupUi = new(_tagHandler, configuration);
|
||||||
|
_pairGroupsUi = new(_tagHandler, DrawPairedClient, apiController, _selectPairsForGroupUi);
|
||||||
|
|
||||||
SizeConstraints = new WindowSizeConstraints()
|
SizeConstraints = new WindowSizeConstraints()
|
||||||
{
|
{
|
||||||
@@ -157,8 +159,9 @@ public class CompactUi : Window, IDisposable
|
|||||||
}
|
}
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
UiShared.DrawWithID("transfers", DrawTransfers);
|
UiShared.DrawWithID("transfers", DrawTransfers);
|
||||||
UiShared.DrawWithID("grouping-popup", () => _selectGroupForPairUi.Draw(ShowUidForEntry));
|
|
||||||
TransferPartHeight = ImGui.GetCursorPosY() - TransferPartHeight;
|
TransferPartHeight = ImGui.GetCursorPosY() - TransferPartHeight;
|
||||||
|
UiShared.DrawWithID("group-user-popup", () => _selectPairsForGroupUi.Draw(_apiController.PairedClients, ShowUidForEntry));
|
||||||
|
UiShared.DrawWithID("grouping-popup", () => _selectGroupForPairUi.Draw(ShowUidForEntry));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_configuration.OpenPopupOnAdd && _apiController.LastAddedUser != null)
|
if (_configuration.OpenPopupOnAdd && _apiController.LastAddedUser != null)
|
||||||
@@ -450,7 +453,7 @@ public class CompactUi : Window, IDisposable
|
|||||||
{
|
{
|
||||||
_selectGroupForPairUi.Open(entry);
|
_selectGroupForPairUi.Open(entry);
|
||||||
}
|
}
|
||||||
UiShared.AttachToolTip("Chose pair groups for " + entryUID);
|
UiShared.AttachToolTip("Choose pair groups for " + entryUID);
|
||||||
|
|
||||||
if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently"))
|
if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ namespace MareSynchronos.UI.Components
|
|||||||
private readonly Action<ClientPairDto> _clientRenderFn;
|
private readonly Action<ClientPairDto> _clientRenderFn;
|
||||||
private readonly TagHandler _tagHandler;
|
private readonly TagHandler _tagHandler;
|
||||||
private readonly ApiController _apiController;
|
private readonly ApiController _apiController;
|
||||||
|
private readonly SelectPairForGroupUi _selectGroupForPairUi;
|
||||||
|
|
||||||
public PairGroupsUi(TagHandler tagHandler, Action<ClientPairDto> clientRenderFn, ApiController apiController)
|
public PairGroupsUi(TagHandler tagHandler, Action<ClientPairDto> clientRenderFn, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
|
||||||
{
|
{
|
||||||
_clientRenderFn = clientRenderFn;
|
_clientRenderFn = clientRenderFn;
|
||||||
_tagHandler = tagHandler;
|
_tagHandler = tagHandler;
|
||||||
_apiController = apiController;
|
_apiController = apiController;
|
||||||
|
_selectGroupForPairUi = selectGroupForPairUi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(List<ClientPairDto> availablePairs)
|
public void Draw(List<ClientPairDto> availablePairs)
|
||||||
@@ -74,13 +76,13 @@ namespace MareSynchronos.UI.Components
|
|||||||
{
|
{
|
||||||
var allArePaused = availablePairsInThisTag.All(pair => pair.IsPaused);
|
var allArePaused = availablePairsInThisTag.All(pair => pair.IsPaused);
|
||||||
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||||
var trashButtonX = UiShared.GetIconButtonSize(FontAwesomeIcon.Trash).X;
|
var flyoutMenuX = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X;
|
||||||
var pauseButtonX = UiShared.GetIconButtonSize(pauseButton).X;
|
var pauseButtonX = UiShared.GetIconButtonSize(pauseButton).X;
|
||||||
var windowX = ImGui.GetWindowContentRegionMin().X;
|
var windowX = ImGui.GetWindowContentRegionMin().X;
|
||||||
var windowWidth = UiShared.GetWindowContentRegionWidth();
|
var windowWidth = UiShared.GetWindowContentRegionWidth();
|
||||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||||
|
|
||||||
var buttonPauseOffset = windowX + windowWidth - trashButtonX - spacingX - pauseButtonX;
|
var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX;
|
||||||
ImGui.SameLine(buttonPauseOffset);
|
ImGui.SameLine(buttonPauseOffset);
|
||||||
if (ImGuiComponents.IconButton(pauseButton))
|
if (ImGuiComponents.IconButton(pauseButton))
|
||||||
{
|
{
|
||||||
@@ -107,13 +109,37 @@ namespace MareSynchronos.UI.Components
|
|||||||
UiShared.AttachToolTip($"Pause pairing with all pairs in {tag}");
|
UiShared.AttachToolTip($"Pause pairing with all pairs in {tag}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonDeleteOffset = windowX + windowWidth - trashButtonX;
|
var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX;
|
||||||
ImGui.SameLine(buttonDeleteOffset);
|
ImGui.SameLine(buttonDeleteOffset);
|
||||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Trash))
|
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
|
||||||
|
{
|
||||||
|
ImGui.OpenPopup("Group Flyout Menu");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.BeginPopup("Group Flyout Menu"))
|
||||||
|
{
|
||||||
|
UiShared.DrawWithID($"buttons-{tag}", () => DrawGroupMenu(tag));
|
||||||
|
ImGui.EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawGroupMenu(string tag)
|
||||||
|
{
|
||||||
|
if (UiShared.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
|
||||||
|
{
|
||||||
|
_selectGroupForPairUi.Open(tag);
|
||||||
|
}
|
||||||
|
UiShared.AttachToolTip($"Add more users to Group {tag}");
|
||||||
|
|
||||||
|
if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag))
|
||||||
|
{
|
||||||
|
if (UiShared.CtrlPressed())
|
||||||
{
|
{
|
||||||
_tagHandler.RemoveTag(tag);
|
_tagHandler.RemoveTag(tag);
|
||||||
}
|
}
|
||||||
UiShared.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)");
|
}
|
||||||
|
UiShared.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)" + Environment.NewLine + "Hold CTRL to delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPairs(string tag, List<ClientPairDto> availablePairsInThisCategory)
|
private void DrawPairs(string tag, List<ClientPairDto> availablePairsInThisCategory)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ using ImGuiNET;
|
|||||||
using MareSynchronos.API;
|
using MareSynchronos.API;
|
||||||
using MareSynchronos.UI.Handlers;
|
using MareSynchronos.UI.Handlers;
|
||||||
|
|
||||||
namespace MareSynchronos.UI.Components
|
namespace MareSynchronos.UI.Components;
|
||||||
|
|
||||||
|
public class SelectGroupForPairUi
|
||||||
{
|
{
|
||||||
public class SelectGroupForPairUi
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should the panel show, yes/no
|
/// Should the panel show, yes/no
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -62,7 +62,7 @@ namespace MareSynchronos.UI.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
var name = PairName(showUidForEntry, _pair.OtherUID);
|
var name = PairName(showUidForEntry, _pair.OtherUID);
|
||||||
var popupName = $"Chose Groups for {name}";
|
var popupName = $"Choose Groups for {name}";
|
||||||
// Is the popup supposed to show but did not open yet? Open it
|
// Is the popup supposed to show but did not open yet? Open it
|
||||||
if (_show && !_opened)
|
if (_show && !_opened)
|
||||||
{
|
{
|
||||||
@@ -150,6 +150,4 @@ namespace MareSynchronos.UI.Components
|
|||||||
}
|
}
|
||||||
return playerText;
|
return playerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
89
MareSynchronos/UI/Components/SelectPairForGroupUi.cs
Normal file
89
MareSynchronos/UI/Components/SelectPairForGroupUi.cs
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Dalamud.Interface;
|
||||||
|
using ImGuiNET;
|
||||||
|
using MareSynchronos.API;
|
||||||
|
using MareSynchronos.UI.Handlers;
|
||||||
|
|
||||||
|
namespace MareSynchronos.UI.Components;
|
||||||
|
|
||||||
|
public class SelectPairForGroupUi
|
||||||
|
{
|
||||||
|
private bool _show = false;
|
||||||
|
private bool _opened = false;
|
||||||
|
private HashSet<string> _peopleInGroup = new(System.StringComparer.Ordinal);
|
||||||
|
private string _tag = string.Empty;
|
||||||
|
private readonly TagHandler _tagHandler;
|
||||||
|
private readonly Configuration _configuration;
|
||||||
|
|
||||||
|
public SelectPairForGroupUi(TagHandler tagHandler, Configuration configuration)
|
||||||
|
{
|
||||||
|
_tagHandler = tagHandler;
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Open(string tag)
|
||||||
|
{
|
||||||
|
_peopleInGroup = _tagHandler.GetOtherUidsForTag(tag);
|
||||||
|
_tag = tag;
|
||||||
|
_show = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(List<ClientPairDto> pairs, Dictionary<string, bool> showUidForEntry)
|
||||||
|
{
|
||||||
|
var popupName = $"Choose Users for Group {_tag}";
|
||||||
|
|
||||||
|
if (!_show)
|
||||||
|
{
|
||||||
|
_opened = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_show && !_opened)
|
||||||
|
{
|
||||||
|
ImGui.SetWindowSize(new System.Numerics.Vector2(300, 400));
|
||||||
|
ImGui.OpenPopup(popupName);
|
||||||
|
_opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.BeginPopupModal(popupName, ref _show))
|
||||||
|
{
|
||||||
|
UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
|
||||||
|
foreach (var item in pairs.OrderBy(p => string.IsNullOrEmpty(p.VanityUID) ? p.OtherUID : p.VanityUID, System.StringComparer.OrdinalIgnoreCase).ToList())
|
||||||
|
{
|
||||||
|
var isInGroup = _peopleInGroup.Contains(item.OtherUID);
|
||||||
|
if (ImGui.Checkbox(PairName(showUidForEntry, item.OtherUID), ref isInGroup))
|
||||||
|
{
|
||||||
|
if (isInGroup)
|
||||||
|
{
|
||||||
|
_tagHandler.AddTagToPairedUid(item, _tag);
|
||||||
|
_peopleInGroup.Add(item.OtherUID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tagHandler.RemoveTagFromPairedUid(item, _tag);
|
||||||
|
_peopleInGroup.Remove(item.OtherUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_show = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PairName(Dictionary<string, bool> showUidForEntry, string otherUid)
|
||||||
|
{
|
||||||
|
showUidForEntry.TryGetValue(otherUid, out var showUidInsteadOfName);
|
||||||
|
_configuration.GetCurrentServerUidComments().TryGetValue(otherUid, out var playerText);
|
||||||
|
if (showUidInsteadOfName)
|
||||||
|
{
|
||||||
|
playerText = otherUid;
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrEmpty(playerText))
|
||||||
|
{
|
||||||
|
playerText = otherUid;
|
||||||
|
}
|
||||||
|
return playerText;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user