init 2
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.UI.Models;
|
||||
using System.Collections.Immutable;
|
||||
using LightlessSync.UI;
|
||||
using LightlessSync.UI.Style;
|
||||
|
||||
namespace LightlessSync.UI.Components;
|
||||
|
||||
@@ -11,16 +13,18 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
{
|
||||
public IImmutableList<DrawUserPair> DrawPairs { get; init; }
|
||||
protected readonly string _id;
|
||||
protected readonly IImmutableList<Pair> _allPairs;
|
||||
protected readonly IImmutableList<PairUiEntry> _allPairs;
|
||||
protected readonly TagHandler _tagHandler;
|
||||
protected readonly UiSharedService _uiSharedService;
|
||||
private float _menuWidth = -1;
|
||||
public int OnlinePairs => DrawPairs.Count(u => u.Pair.IsOnline);
|
||||
public int OnlinePairs => DrawPairs.Count(u => u.DisplayEntry.Connection.IsOnline);
|
||||
public int TotalPairs => _allPairs.Count;
|
||||
private bool _wasHovered = false;
|
||||
private bool _suppressNextRowToggle;
|
||||
private bool _rowClickArmed;
|
||||
|
||||
protected DrawFolderBase(string id, IImmutableList<DrawUserPair> drawPairs,
|
||||
IImmutableList<Pair> allPairs, TagHandler tagHandler, UiSharedService uiSharedService)
|
||||
IImmutableList<PairUiEntry> allPairs, TagHandler tagHandler, UiSharedService uiSharedService)
|
||||
{
|
||||
_id = id;
|
||||
DrawPairs = drawPairs;
|
||||
@@ -31,11 +35,14 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
|
||||
protected abstract bool RenderIfEmpty { get; }
|
||||
protected abstract bool RenderMenu { get; }
|
||||
protected virtual bool EnableRowClick => true;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (!RenderIfEmpty && !DrawPairs.Any()) return;
|
||||
|
||||
_suppressNextRowToggle = false;
|
||||
|
||||
using var id = ImRaii.PushId("folder_" + _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())))
|
||||
@@ -48,7 +55,8 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
_uiSharedService.IconText(icon);
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
|
||||
ToggleFolderOpen();
|
||||
SuppressNextRowToggle();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -62,10 +70,41 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
DrawName(rightSideStart - leftSideEnd);
|
||||
}
|
||||
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
var rowHovered = ImGui.IsItemHovered();
|
||||
_wasHovered = rowHovered;
|
||||
|
||||
if (EnableRowClick)
|
||||
{
|
||||
if (rowHovered && ImGui.IsMouseClicked(ImGuiMouseButton.Left) && !_suppressNextRowToggle)
|
||||
{
|
||||
_rowClickArmed = true;
|
||||
}
|
||||
|
||||
if (_rowClickArmed && rowHovered && ImGui.IsMouseReleased(ImGuiMouseButton.Left))
|
||||
{
|
||||
ToggleFolderOpen();
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
|
||||
if (!ImGui.IsMouseDown(ImGuiMouseButton.Left))
|
||||
{
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
|
||||
if (_wasHovered)
|
||||
{
|
||||
Selune.RegisterHighlight(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), spanFullWidth: true);
|
||||
}
|
||||
|
||||
color.Dispose();
|
||||
|
||||
_suppressNextRowToggle = false;
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
// if opened draw content
|
||||
@@ -110,6 +149,7 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
ImGui.SameLine(windowEndX - barButtonSize.X);
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
|
||||
{
|
||||
SuppressNextRowToggle();
|
||||
ImGui.OpenPopup("User Flyout Menu");
|
||||
}
|
||||
if (ImGui.BeginPopup("User Flyout Menu"))
|
||||
@@ -123,7 +163,16 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
_menuWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DrawRightSide(rightSideStart);
|
||||
}
|
||||
|
||||
protected void SuppressNextRowToggle()
|
||||
{
|
||||
_suppressNextRowToggle = true;
|
||||
}
|
||||
|
||||
private void ToggleFolderOpen()
|
||||
{
|
||||
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.UI.Models;
|
||||
using LightlessSync.WebAPI;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
private readonly SelectTagForSyncshellUi _selectTagForSyncshellUi;
|
||||
|
||||
public DrawFolderGroup(string id, GroupFullInfoDto groupFullInfoDto, ApiController apiController,
|
||||
IImmutableList<DrawUserPair> drawPairs, IImmutableList<Pair> allPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler,
|
||||
IImmutableList<DrawUserPair> drawPairs, IImmutableList<PairUiEntry> allPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler,
|
||||
LightlessMediator lightlessMediator, UiSharedService uiSharedService, SelectTagForSyncshellUi selectTagForSyncshellUi) :
|
||||
base(id, drawPairs, allPairs, tagHandler, uiSharedService)
|
||||
{
|
||||
@@ -35,6 +35,7 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
|
||||
protected override bool RenderIfEmpty => true;
|
||||
protected override bool RenderMenu => true;
|
||||
protected override bool EnableRowClick => false;
|
||||
private bool IsModerator => IsOwner || _groupFullInfoDto.GroupUserInfo.IsModerator();
|
||||
private bool IsOwner => string.Equals(_groupFullInfoDto.OwnerUID, _apiController.UID, StringComparison.Ordinal);
|
||||
private bool IsPinned => _groupFullInfoDto.GroupUserInfo.IsPinned();
|
||||
@@ -87,6 +88,13 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.TextUnformatted("General Syncshell Actions");
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.AddressCard, "Open Syncshell Profile", menuWidth, true))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
_lightlessMediator.Publish(new GroupProfileOpenStandaloneMessage(_groupFullInfoDto));
|
||||
}
|
||||
UiSharedService.AttachToolTip("Opens the profile for this syncshell in a new window.");
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy ID", menuWidth, true))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
@@ -160,6 +168,14 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted("Syncshell Admin Functions");
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserEdit, "Open Profile Editor", menuWidth, true))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
_lightlessMediator.Publish(new OpenGroupProfileEditorMessage(_groupFullInfoDto));
|
||||
}
|
||||
UiSharedService.AttachToolTip("Open the syncshell profile editor.");
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
@@ -244,6 +260,7 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
ImGui.SameLine();
|
||||
if (_uiSharedService.IconButton(pauseIcon))
|
||||
{
|
||||
SuppressNextRowToggle();
|
||||
var perm = _groupFullInfoDto.GroupUserPermissions;
|
||||
perm.SetPaused(!perm.IsPaused());
|
||||
_ = _apiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(_groupFullInfoDto.Group, new(_apiController.UID), perm));
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.API.Data.Enum;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Services.ServerConfiguration;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.UI.Models;
|
||||
using LightlessSync.WebAPI;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace LightlessSync.UI.Components;
|
||||
|
||||
@@ -14,14 +21,30 @@ public class DrawFolderTag : DrawFolderBase
|
||||
private readonly ApiController _apiController;
|
||||
private readonly SelectPairForTagUi _selectPairForTagUi;
|
||||
private readonly RenamePairTagUi _renameTagUi;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly LightlessConfigService _configService;
|
||||
private readonly LightlessMediator _mediator;
|
||||
|
||||
public DrawFolderTag(string id, IImmutableList<DrawUserPair> drawPairs, IImmutableList<Pair> allPairs,
|
||||
TagHandler tagHandler, ApiController apiController, SelectPairForTagUi selectPairForTagUi, RenamePairTagUi renameTagUi, UiSharedService uiSharedService)
|
||||
public DrawFolderTag(
|
||||
string id,
|
||||
IImmutableList<DrawUserPair> drawPairs,
|
||||
IImmutableList<PairUiEntry> allPairs,
|
||||
TagHandler tagHandler,
|
||||
ApiController apiController,
|
||||
SelectPairForTagUi selectPairForTagUi,
|
||||
RenamePairTagUi renameTagUi,
|
||||
UiSharedService uiSharedService,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
LightlessConfigService configService,
|
||||
LightlessMediator mediator)
|
||||
: base(id, drawPairs, allPairs, tagHandler, uiSharedService)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_selectPairForTagUi = selectPairForTagUi;
|
||||
_renameTagUi = renameTagUi;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_configService = configService;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
protected override bool RenderIfEmpty => _id switch
|
||||
@@ -86,15 +109,18 @@ public class DrawFolderTag : DrawFolderBase
|
||||
|
||||
if (RenderCount)
|
||||
{
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing,
|
||||
ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
|
||||
ImGui.TextUnformatted($"[{OnlinePairs}]");
|
||||
}
|
||||
UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total");
|
||||
|
||||
UiSharedService.AttachToolTip($"{OnlinePairs} online{Environment.NewLine}{TotalPairs} total");
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
return ImGui.GetCursorPosX();
|
||||
}
|
||||
@@ -102,19 +128,24 @@ public class DrawFolderTag : DrawFolderBase
|
||||
protected override void DrawMenu(float menuWidth)
|
||||
{
|
||||
ImGui.TextUnformatted("Group Menu");
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Select Pairs", menuWidth, isInPopup: true))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Select Pairs", menuWidth, true))
|
||||
{
|
||||
_selectPairForTagUi.Open(_id);
|
||||
}
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Edit, "Rename Pair Group", menuWidth, isInPopup: true))
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Edit, "Rename Pair Group", menuWidth, true))
|
||||
{
|
||||
_renameTagUi.Open(_id);
|
||||
}
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Pair Group", menuWidth, isInPopup: true) && UiSharedService.CtrlPressed())
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Pair Group", menuWidth, true) &&
|
||||
UiSharedService.CtrlPressed())
|
||||
{
|
||||
_tagHandler.RemovePairTag(_id);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently." + Environment.NewLine +
|
||||
|
||||
UiSharedService.AttachToolTip(
|
||||
"Hold CTRL to remove this Group permanently." + Environment.NewLine +
|
||||
"Note: this will not unpair with users in this Group.");
|
||||
}
|
||||
|
||||
@@ -122,7 +153,7 @@ public class DrawFolderTag : DrawFolderBase
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
string name = _id switch
|
||||
var name = _id switch
|
||||
{
|
||||
TagHandler.CustomUnpairedTag => "One-sided Individual Pairs",
|
||||
TagHandler.CustomOnlineTag => "Online / Paused by you",
|
||||
@@ -138,16 +169,25 @@ public class DrawFolderTag : DrawFolderBase
|
||||
|
||||
protected override float DrawRightSide(float currentRightSideX)
|
||||
{
|
||||
if (!RenderPause) return currentRightSideX;
|
||||
|
||||
var allArePaused = _allPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
|
||||
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseButtonX = _uiSharedService.GetIconButtonSize(pauseButton).X;
|
||||
|
||||
var buttonPauseOffset = currentRightSideX - pauseButtonX;
|
||||
ImGui.SameLine(buttonPauseOffset);
|
||||
if (_uiSharedService.IconButton(pauseButton))
|
||||
if (_id == TagHandler.CustomVisibleTag)
|
||||
{
|
||||
return DrawVisibleFilter(currentRightSideX);
|
||||
}
|
||||
|
||||
if (!RenderPause)
|
||||
{
|
||||
return currentRightSideX;
|
||||
}
|
||||
|
||||
var allArePaused = _allPairs.All(entry => entry.SelfPermissions.IsPaused());
|
||||
var pauseIcon = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseButtonSize = _uiSharedService.GetIconButtonSize(pauseIcon);
|
||||
|
||||
var buttonPauseOffset = currentRightSideX - pauseButtonSize.X;
|
||||
ImGui.SameLine(buttonPauseOffset);
|
||||
if (_uiSharedService.IconButton(pauseIcon))
|
||||
{
|
||||
SuppressNextRowToggle();
|
||||
if (allArePaused)
|
||||
{
|
||||
ResumeAllPairs(_allPairs);
|
||||
@@ -157,39 +197,89 @@ public class DrawFolderTag : DrawFolderBase
|
||||
PauseRemainingPairs(_allPairs);
|
||||
}
|
||||
}
|
||||
if (allArePaused)
|
||||
{
|
||||
UiSharedService.AttachToolTip($"Resume pairing with all pairs in {_id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.AttachToolTip($"Pause pairing with all pairs in {_id}");
|
||||
}
|
||||
|
||||
UiSharedService.AttachToolTip(allArePaused
|
||||
? $"Resume pairing with all pairs in {_id}"
|
||||
: $"Pause pairing with all pairs in {_id}");
|
||||
|
||||
return currentRightSideX;
|
||||
}
|
||||
|
||||
private void PauseRemainingPairs(IEnumerable<Pair> availablePairs)
|
||||
private void PauseRemainingPairs(IEnumerable<PairUiEntry> entries)
|
||||
{
|
||||
_ = _apiController.SetBulkPermissions(new(availablePairs
|
||||
.ToDictionary(g => g.UserData.UID, g =>
|
||||
{
|
||||
var perm = g.UserPair.OwnPermissions;
|
||||
perm.SetPaused(paused: true);
|
||||
return perm;
|
||||
}, StringComparer.Ordinal), new(StringComparer.Ordinal)))
|
||||
_ = _apiController.SetBulkPermissions(new(
|
||||
entries.ToDictionary(entry => entry.DisplayEntry.User.UID, entry =>
|
||||
{
|
||||
var permissions = entry.SelfPermissions;
|
||||
permissions.SetPaused(true);
|
||||
return permissions;
|
||||
}, StringComparer.Ordinal),
|
||||
new(StringComparer.Ordinal)))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void ResumeAllPairs(IEnumerable<Pair> availablePairs)
|
||||
private void ResumeAllPairs(IEnumerable<PairUiEntry> entries)
|
||||
{
|
||||
_ = _apiController.SetBulkPermissions(new(availablePairs
|
||||
.ToDictionary(g => g.UserData.UID, g =>
|
||||
{
|
||||
var perm = g.UserPair.OwnPermissions;
|
||||
perm.SetPaused(paused: false);
|
||||
return perm;
|
||||
}, StringComparer.Ordinal), new(StringComparer.Ordinal)))
|
||||
_ = _apiController.SetBulkPermissions(new(
|
||||
entries.ToDictionary(entry => entry.DisplayEntry.User.UID, entry =>
|
||||
{
|
||||
var permissions = entry.SelfPermissions;
|
||||
permissions.SetPaused(false);
|
||||
return permissions;
|
||||
}, StringComparer.Ordinal),
|
||||
new(StringComparer.Ordinal)))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private float DrawVisibleFilter(float currentRightSideX)
|
||||
{
|
||||
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Filter);
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var buttonStart = currentRightSideX - buttonSize.X;
|
||||
|
||||
ImGui.SameLine(buttonStart);
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.Filter))
|
||||
{
|
||||
SuppressNextRowToggle();
|
||||
ImGui.OpenPopup($"visible-filter-{_id}");
|
||||
}
|
||||
|
||||
UiSharedService.AttachToolTip("Adjust how visible pairs are ordered.");
|
||||
|
||||
if (ImGui.BeginPopup($"visible-filter-{_id}"))
|
||||
{
|
||||
ImGui.TextUnformatted("Visible Pair Ordering");
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (VisiblePairSortMode mode in Enum.GetValues<VisiblePairSortMode>())
|
||||
{
|
||||
var selected = _configService.Current.VisiblePairSortMode == mode;
|
||||
if (ImGui.MenuItem(GetSortLabel(mode), string.Empty, selected))
|
||||
{
|
||||
if (!selected)
|
||||
{
|
||||
_configService.Current.VisiblePairSortMode = mode;
|
||||
_configService.Save();
|
||||
_mediator.Publish(new RefreshUiMessage());
|
||||
}
|
||||
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
return buttonStart - spacingX;
|
||||
}
|
||||
|
||||
private static string GetSortLabel(VisiblePairSortMode mode) => mode switch
|
||||
{
|
||||
VisiblePairSortMode.Alphabetical => "Alphabetical",
|
||||
VisiblePairSortMode.VramUsage => "VRAM usage (descending)",
|
||||
VisiblePairSortMode.EffectiveVramUsage => "Effective VRAM usage (descending)",
|
||||
VisiblePairSortMode.TriangleCount => "Triangle count (descending)",
|
||||
VisiblePairSortMode.PreferredDirectPairs => "Preferred permissions & Direct pairs",
|
||||
_ => "Default",
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.UI;
|
||||
using LightlessSync.API.Data.Extensions;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.UI.Style;
|
||||
using LightlessSync.UI.Models;
|
||||
using LightlessSync.WebAPI;
|
||||
using System.Collections.Immutable;
|
||||
@@ -22,6 +24,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
private readonly RenameSyncshellTagUi _renameSyncshellTagUi;
|
||||
private bool _wasHovered = false;
|
||||
private float _menuWidth;
|
||||
private bool _rowClickArmed;
|
||||
|
||||
public IImmutableList<DrawUserPair> DrawPairs => _groups.SelectMany(g => g.GroupDrawFolder.DrawPairs).ToImmutableList();
|
||||
public int OnlinePairs => _groups.SelectMany(g => g.GroupDrawFolder.DrawPairs).Where(g => g.Pair.IsOnline).DistinctBy(g => g.Pair.UserData.UID).Count();
|
||||
@@ -48,7 +51,9 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
|
||||
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())))
|
||||
var allowRowClick = string.IsNullOrEmpty(_tag);
|
||||
var suppressRowToggle = false;
|
||||
using (ImRaii.Child("folder__" + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
{
|
||||
ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight()));
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 0f)))
|
||||
@@ -61,6 +66,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
|
||||
suppressRowToggle = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -92,7 +98,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
ImGui.SameLine();
|
||||
DrawPauseButton();
|
||||
ImGui.SameLine();
|
||||
DrawMenu();
|
||||
DrawMenu(ref suppressRowToggle);
|
||||
} else
|
||||
{
|
||||
ImGui.TextUnformatted("All Syncshells");
|
||||
@@ -102,7 +108,36 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
}
|
||||
}
|
||||
color.Dispose();
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
var rowHovered = ImGui.IsItemHovered();
|
||||
_wasHovered = rowHovered;
|
||||
|
||||
if (allowRowClick)
|
||||
{
|
||||
if (rowHovered && ImGui.IsMouseClicked(ImGuiMouseButton.Left) && !suppressRowToggle)
|
||||
{
|
||||
_rowClickArmed = true;
|
||||
}
|
||||
|
||||
if (_rowClickArmed && rowHovered && ImGui.IsMouseReleased(ImGuiMouseButton.Left))
|
||||
{
|
||||
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
|
||||
if (!ImGui.IsMouseDown(ImGuiMouseButton.Left))
|
||||
{
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_rowClickArmed = false;
|
||||
}
|
||||
|
||||
if (_wasHovered)
|
||||
{
|
||||
Selune.RegisterHighlight(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), spanFullWidth: true);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
@@ -154,7 +189,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawMenu()
|
||||
protected void DrawMenu(ref bool suppressRowToggle)
|
||||
{
|
||||
var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.EllipsisV);
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
@@ -162,6 +197,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
ImGui.SameLine(windowEndX - barButtonSize.X);
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
|
||||
{
|
||||
suppressRowToggle = true;
|
||||
ImGui.OpenPopup("User Flyout Menu");
|
||||
}
|
||||
if (ImGui.BeginPopup("User Flyout Menu"))
|
||||
|
||||
@@ -12,11 +12,16 @@ using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Services.ServerConfiguration;
|
||||
using LightlessSync.UI.Handlers;
|
||||
using LightlessSync.UI.Models;
|
||||
using LightlessSync.UI.Style;
|
||||
using LightlessSync.Utils;
|
||||
using LightlessSync.WebAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LightlessSync.UI;
|
||||
|
||||
namespace LightlessSync.UI.Components;
|
||||
|
||||
@@ -27,29 +32,41 @@ public class DrawUserPair
|
||||
protected readonly LightlessMediator _mediator;
|
||||
protected readonly List<GroupFullInfoDto> _syncedGroups;
|
||||
private readonly GroupFullInfoDto? _currentGroup;
|
||||
protected Pair _pair;
|
||||
protected Pair? _pair;
|
||||
private PairUiEntry _uiEntry;
|
||||
protected PairDisplayEntry _displayEntry;
|
||||
private readonly string _id;
|
||||
private readonly SelectTagForPairUi _selectTagForPairUi;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly PlayerPerformanceConfigService _performanceConfigService;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
private readonly PairLedger _pairLedger;
|
||||
private float _menuWidth = -1;
|
||||
private bool _wasHovered = false;
|
||||
private TooltipSnapshot _tooltipSnapshot = TooltipSnapshot.Empty;
|
||||
private string _cachedTooltip = string.Empty;
|
||||
|
||||
public DrawUserPair(string id, Pair entry, List<GroupFullInfoDto> syncedGroups,
|
||||
public DrawUserPair(
|
||||
string id,
|
||||
PairUiEntry uiEntry,
|
||||
Pair? legacyPair,
|
||||
GroupFullInfoDto? currentGroup,
|
||||
ApiController apiController, IdDisplayHandler uIDDisplayHandler,
|
||||
LightlessMediator lightlessMediator, SelectTagForPairUi selectTagForPairUi,
|
||||
ApiController apiController,
|
||||
IdDisplayHandler uIDDisplayHandler,
|
||||
LightlessMediator lightlessMediator,
|
||||
SelectTagForPairUi selectTagForPairUi,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
UiSharedService uiSharedService, PlayerPerformanceConfigService performanceConfigService,
|
||||
CharaDataManager charaDataManager)
|
||||
UiSharedService uiSharedService,
|
||||
PlayerPerformanceConfigService performanceConfigService,
|
||||
CharaDataManager charaDataManager,
|
||||
PairLedger pairLedger)
|
||||
{
|
||||
_id = id;
|
||||
_pair = entry;
|
||||
_syncedGroups = syncedGroups;
|
||||
_uiEntry = uiEntry;
|
||||
_displayEntry = uiEntry.DisplayEntry;
|
||||
_pair = legacyPair ?? throw new ArgumentNullException(nameof(legacyPair));
|
||||
_syncedGroups = uiEntry.DisplayEntry.Groups.ToList();
|
||||
_currentGroup = currentGroup;
|
||||
_apiController = apiController;
|
||||
_displayHandler = uIDDisplayHandler;
|
||||
@@ -59,6 +76,18 @@ public class DrawUserPair
|
||||
_uiSharedService = uiSharedService;
|
||||
_performanceConfigService = performanceConfigService;
|
||||
_charaDataManager = charaDataManager;
|
||||
_pairLedger = pairLedger;
|
||||
}
|
||||
|
||||
public PairDisplayEntry DisplayEntry => _displayEntry;
|
||||
public PairUiEntry UiEntry => _uiEntry;
|
||||
|
||||
public void UpdateDisplayEntry(PairUiEntry entry)
|
||||
{
|
||||
_uiEntry = entry;
|
||||
_displayEntry = entry.DisplayEntry;
|
||||
_syncedGroups.Clear();
|
||||
_syncedGroups.AddRange(entry.DisplayEntry.Groups);
|
||||
}
|
||||
|
||||
public Pair Pair => _pair;
|
||||
@@ -77,6 +106,10 @@ public class DrawUserPair
|
||||
DrawName(posX, rightSide);
|
||||
}
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
if (_wasHovered)
|
||||
{
|
||||
Selune.RegisterHighlight(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), spanFullWidth: true);
|
||||
}
|
||||
color.Dispose();
|
||||
}
|
||||
|
||||
@@ -103,7 +136,7 @@ public class DrawUserPair
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state", _menuWidth, true))
|
||||
{
|
||||
_ = _apiController.CyclePauseAsync(_pair.UserData);
|
||||
_ = _apiController.CyclePauseAsync(_pair);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
ImGui.Separator();
|
||||
@@ -313,6 +346,7 @@ public class DrawUserPair
|
||||
_pair.PlayerName ?? string.Empty,
|
||||
_pair.LastAppliedDataBytes,
|
||||
_pair.LastAppliedApproximateVRAMBytes,
|
||||
_pair.LastAppliedApproximateEffectiveVRAMBytes,
|
||||
_pair.LastAppliedDataTris,
|
||||
_pair.IsPaired,
|
||||
groupDisplays is null ? ImmutableArray<string>.Empty : ImmutableArray.CreateRange(groupDisplays));
|
||||
@@ -381,7 +415,14 @@ public class DrawUserPair
|
||||
{
|
||||
builder.Append(Environment.NewLine);
|
||||
builder.Append("Approx. VRAM Usage: ");
|
||||
builder.Append(UiSharedService.ByteToString(snapshot.LastAppliedApproximateVRAMBytes, true));
|
||||
var originalText = UiSharedService.ByteToString(snapshot.LastAppliedApproximateVRAMBytes, true);
|
||||
builder.Append(originalText);
|
||||
if (snapshot.LastAppliedApproximateEffectiveVRAMBytes >= 0)
|
||||
{
|
||||
builder.Append(" (Effective: ");
|
||||
builder.Append(UiSharedService.ByteToString(snapshot.LastAppliedApproximateEffectiveVRAMBytes, true));
|
||||
builder.Append(')');
|
||||
}
|
||||
}
|
||||
|
||||
if (snapshot.LastAppliedDataTris >= 0)
|
||||
@@ -420,12 +461,13 @@ public class DrawUserPair
|
||||
string PlayerName,
|
||||
long LastAppliedDataBytes,
|
||||
long LastAppliedApproximateVRAMBytes,
|
||||
long LastAppliedApproximateEffectiveVRAMBytes,
|
||||
long LastAppliedDataTris,
|
||||
bool IsPaired,
|
||||
ImmutableArray<string> GroupDisplays)
|
||||
{
|
||||
public static TooltipSnapshot Empty { get; } =
|
||||
new(false, false, false, IndividualPairStatus.None, string.Empty, string.Empty, -1, -1, -1, false, ImmutableArray<string>.Empty);
|
||||
new(false, false, false, IndividualPairStatus.None, string.Empty, string.Empty, -1, -1, -1, -1, false, ImmutableArray<string>.Empty);
|
||||
}
|
||||
|
||||
private void DrawPairedClientMenu()
|
||||
@@ -647,7 +689,13 @@ public class DrawUserPair
|
||||
|
||||
private void DrawSyncshellMenu(GroupFullInfoDto group, bool selfIsOwner, bool selfIsModerator, bool userIsPinned, bool userIsModerator)
|
||||
{
|
||||
if (selfIsOwner || ((selfIsModerator) && (!userIsModerator)))
|
||||
var showModeratorActions = selfIsOwner || (selfIsModerator && !userIsModerator);
|
||||
var showOwnerActions = selfIsOwner;
|
||||
|
||||
if (showModeratorActions || showOwnerActions)
|
||||
ImGui.Separator();
|
||||
|
||||
if (showModeratorActions)
|
||||
{
|
||||
ImGui.TextUnformatted("Syncshell Moderator Functions");
|
||||
var pinText = userIsPinned ? "Unpin user" : "Pin user";
|
||||
@@ -683,7 +731,7 @@ public class DrawUserPair
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
if (selfIsOwner)
|
||||
if (showOwnerActions)
|
||||
{
|
||||
ImGui.TextUnformatted("Syncshell Owner Functions");
|
||||
string modText = userIsModerator ? "Demod user" : "Mod user";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.PlayerData.Factories;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.WebAPI;
|
||||
@@ -12,14 +13,16 @@ public class BanUserPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly PairFactory _pairFactory;
|
||||
private string _banReason = string.Empty;
|
||||
private GroupFullInfoDto _group = null!;
|
||||
private Pair _reportedPair = null!;
|
||||
|
||||
public BanUserPopupHandler(ApiController apiController, UiSharedService uiSharedService)
|
||||
public BanUserPopupHandler(ApiController apiController, UiSharedService uiSharedService, PairFactory pairFactory)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
_pairFactory = pairFactory;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(500, 250);
|
||||
@@ -43,7 +46,7 @@ public class BanUserPopupHandler : IPopupHandler
|
||||
|
||||
public void Open(OpenBanUserPopupMessage message)
|
||||
{
|
||||
_reportedPair = message.PairToBan;
|
||||
_reportedPair = _pairFactory.Create(message.PairToBan.UniqueIdent) ?? message.PairToBan;
|
||||
_group = message.GroupFullInfoDto;
|
||||
_banReason = string.Empty;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SelectPairForTagUi
|
||||
_uidDisplayHandler = uidDisplayHandler;
|
||||
}
|
||||
|
||||
public void Draw(List<Pair> pairs)
|
||||
public void Draw(IReadOnlyList<Pair> pairs)
|
||||
{
|
||||
var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
|
||||
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SelectSyncshellForTagUi
|
||||
_tagHandler = tagHandler;
|
||||
}
|
||||
|
||||
public void Draw(List<GroupFullInfoDto> groups)
|
||||
public void Draw(IReadOnlyCollection<GroupFullInfoDto> groups)
|
||||
{
|
||||
var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
|
||||
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
Reference in New Issue
Block a user