add total count on mouseover, make syncshell windows non-blocking

This commit is contained in:
rootdarkarchon
2023-10-20 16:53:56 +02:00
parent d7bfa2147f
commit 984ee08a2b
12 changed files with 73 additions and 62 deletions

View File

@@ -112,14 +112,15 @@ public sealed class Plugin : IDalamudPlugin
collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>(); collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>(); collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>(); collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
collection.AddScoped<WindowMediatorSubscriberBase, JoinSyncshellUI>();
collection.AddScoped<WindowMediatorSubscriberBase, CreateSyncshellUI>();
collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>((s) => new EditProfileUi(s.GetRequiredService<ILogger<EditProfileUi>>(), collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>((s) => new EditProfileUi(s.GetRequiredService<ILogger<EditProfileUi>>(),
s.GetRequiredService<MareMediator>(), s.GetRequiredService<ApiController>(), pluginInterface.UiBuilder, s.GetRequiredService<UiSharedService>(), s.GetRequiredService<MareMediator>(), s.GetRequiredService<ApiController>(), pluginInterface.UiBuilder, s.GetRequiredService<UiSharedService>(),
s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareProfileManager>())); s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareProfileManager>()));
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>(); collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
collection.AddScoped<IPopupHandler, ReportPopupHandler>(); collection.AddScoped<IPopupHandler, ReportPopupHandler>();
collection.AddScoped<IPopupHandler, BanUserPopupHandler>(); collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
collection.AddScoped<IPopupHandler, CreateSyncshellPopupHandler>();
collection.AddScoped<IPopupHandler, JoinSyncshellPopupHandler>();
collection.AddScoped<IPopupHandler, SyncshellAdminPopupHandler>(); collection.AddScoped<IPopupHandler, SyncshellAdminPopupHandler>();
collection.AddScoped<CacheCreationService>(); collection.AddScoped<CacheCreationService>();
collection.AddScoped<TransientResourceManager>(); collection.AddScoped<TransientResourceManager>();

View File

@@ -73,8 +73,6 @@ public record PairHandlerVisibleMessage(PairHandler Player) : MessageBase;
public record RefreshUiMessage : MessageBase; public record RefreshUiMessage : MessageBase;
public record OpenReportPopupMessage(Pair PairToReport) : MessageBase; public record OpenReportPopupMessage(Pair PairToReport) : MessageBase;
public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : MessageBase; public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : MessageBase;
public record JoinSyncshellPopupMessage() : MessageBase;
public record OpenCreateSyncshellPopupMessage() : MessageBase;
public record OpenSyncshellAdminPanelPopupMessage(GroupFullInfoDto GroupInfo) : MessageBase; public record OpenSyncshellAdminPanelPopupMessage(GroupFullInfoDto GroupInfo) : MessageBase;
#pragma warning restore S2094 #pragma warning restore S2094

View File

@@ -232,7 +232,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", _syncshellMenuSize, true)) if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", _syncshellMenuSize, true))
{ {
Mediator.Publish(new OpenCreateSyncshellPopupMessage()); Mediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI)));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
} }
@@ -241,7 +241,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", _syncshellMenuSize, true)) if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", _syncshellMenuSize, true))
{ {
Mediator.Publish(new JoinSyncshellPopupMessage()); Mediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI)));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
} }
@@ -517,7 +517,8 @@ public class CompactUi : WindowMediatorSubscriberBase
: (u.Key.GetNote() ?? u.Key.UserData.AliasOrUID), StringComparer.Ordinal) : (u.Key.GetNote() ?? u.Key.UserData.AliasOrUID), StringComparer.Ordinal)
.ToDictionary(k => k.Key, k => k.Value); .ToDictionary(k => k.Key, k => k.Value);
groupFolders.Add(_drawEntityFactory.CreateDrawGroupFolder(group, groupUsers2)); groupFolders.Add(_drawEntityFactory.CreateDrawGroupFolder(group, groupUsers2,
users.Count(v => v.Value.Exists(g => string.Equals(g.GID, group.GID, StringComparison.Ordinal)))));
} }
if (_configService.Current.GroupUpSyncshells) if (_configService.Current.GroupUpSyncshells)
@@ -544,7 +545,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
alreadyInTags.Add(u.Key); alreadyInTags.Add(u.Key);
return (u.Key, u.Value); return (u.Key, u.Value);
}).ToDictionary(u => u.Key, u => u.Value))); }).ToDictionary(u => u.Key, u => u.Value), users.Count(u => _tagHandler.HasTag(u.Key.UserData.UID, tag))));
} }
var onlineDirectPairedUsersNotInTags = users.Where(u => u.Key.IsDirectlyPaired && !u.Key.IsOneSidedPair && !_tagHandler.HasAnyTag(u.Key.UserData.UID) var onlineDirectPairedUsersNotInTags = users.Where(u => u.Key.IsDirectlyPaired && !u.Key.IsOneSidedPair && !_tagHandler.HasAnyTag(u.Key.UserData.UID)

View File

@@ -13,11 +13,13 @@ public abstract class DrawFolderBase : IDrawFolder
protected readonly TagHandler _tagHandler; protected readonly TagHandler _tagHandler;
private float _menuWidth = -1; private float _menuWidth = -1;
public int OnlinePairs => _drawPairs.Count(u => u.Pair.IsOnline); public int OnlinePairs => _drawPairs.Count(u => u.Pair.IsOnline);
protected DrawFolderBase(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler) public int TotalPairs { get; }
protected DrawFolderBase(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, int totalPairs)
{ {
_id = id; _id = id;
_drawPairs = drawPairs; _drawPairs = drawPairs;
_tagHandler = tagHandler; _tagHandler = tagHandler;
TotalPairs = totalPairs;
} }
protected abstract bool RenderIfEmpty { get; } protected abstract bool RenderIfEmpty { get; }

View File

@@ -21,8 +21,8 @@ public class DrawFolderGroup : DrawFolderBase
public DrawFolderGroup(string id, GroupFullInfoDto groupFullInfoDto, ApiController apiController, public DrawFolderGroup(string id, GroupFullInfoDto groupFullInfoDto, ApiController apiController,
IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler,
MareMediator mareMediator) : MareMediator mareMediator, int totalPairs) :
base(id, drawPairs, tagHandler) base(id, drawPairs, tagHandler, totalPairs)
{ {
_groupFullInfoDto = groupFullInfoDto; _groupFullInfoDto = groupFullInfoDto;
_apiController = apiController; _apiController = apiController;
@@ -53,7 +53,7 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.SetCursorPosY(textPosY); ImGui.SetCursorPosY(textPosY);
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
} }
UiSharedService.AttachToolTip(OnlinePairs + " online in this syncshell"); UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total");
ImGui.SameLine(); ImGui.SameLine();
if (IsOwner) if (IsOwner)

View File

@@ -13,8 +13,8 @@ public class DrawFolderTag : DrawFolderBase
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly SelectPairForTagUi _selectPairForTagUi; private readonly SelectPairForTagUi _selectPairForTagUi;
public DrawFolderTag(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, ApiController apiController, SelectPairForTagUi selectPairForTagUi) public DrawFolderTag(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, ApiController apiController, SelectPairForTagUi selectPairForTagUi, int totalPairs)
: base(id, drawPairs, tagHandler) : base(id, drawPairs, tagHandler, totalPairs)
{ {
_apiController = apiController; _apiController = apiController;
_selectPairForTagUi = selectPairForTagUi; _selectPairForTagUi = selectPairForTagUi;
@@ -55,9 +55,12 @@ public class DrawFolderTag : DrawFolderBase
private bool RenderCount => _id switch private bool RenderCount => _id switch
{ {
TagHandler.CustomOfflineSyncshellTag => false,
TagHandler.CustomOfflineTag => false,
TagHandler.CustomUnpairedTag => false, TagHandler.CustomUnpairedTag => false,
TagHandler.CustomOnlineTag => false,
TagHandler.CustomOfflineTag => false,
TagHandler.CustomVisibleTag => false,
TagHandler.CustomAllTag => false,
TagHandler.CustomOfflineSyncshellTag => false,
_ => true _ => true
}; };
@@ -87,7 +90,7 @@ public class DrawFolderTag : DrawFolderBase
ImGui.SetCursorPosY(textPosY); ImGui.SetCursorPosY(textPosY);
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
} }
UiSharedService.AttachToolTip(OnlinePairs + " online in this group"); UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total");
} }
ImGui.SameLine(); ImGui.SameLine();
return ImGui.GetCursorPosX(); return ImGui.GetCursorPosX();

View File

@@ -10,6 +10,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
private readonly IEnumerable<IDrawFolder> _groups; private readonly IEnumerable<IDrawFolder> _groups;
private readonly TagHandler _tagHandler; private readonly TagHandler _tagHandler;
public int OnlinePairs => _groups.Sum(g => g.OnlinePairs); public int OnlinePairs => _groups.Sum(g => g.OnlinePairs);
public int TotalPairs => _groups.Sum(g => g.TotalPairs);
public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler) public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler)
{ {
@@ -39,7 +40,8 @@ public class DrawGroupedGroupFolder : IDrawFolder
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
} }
UiSharedService.AttachToolTip(OnlinePairs + " online all of your syncshells"); UiSharedService.AttachToolTip(OnlinePairs + " online in all of your joined syncshells" + Environment.NewLine +
TotalPairs + " pairs combined in all of your joined syncshells");
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextUnformatted("All Syncshells"); ImGui.TextUnformatted("All Syncshells");
ImGui.Separator(); ImGui.Separator();

View File

@@ -2,6 +2,7 @@
public interface IDrawFolder public interface IDrawFolder
{ {
int TotalPairs { get; }
int OnlinePairs { get; } int OnlinePairs { get; }
void Draw(); void Draw();
} }

View File

@@ -36,14 +36,6 @@ public class PopupHandler : WindowMediatorSubscriberBase
IsOpen = true; IsOpen = true;
}); });
Mediator.Subscribe<OpenCreateSyncshellPopupMessage>(this, (msg) =>
{
_openPopup = true;
_currentHandler = _handlers.OfType<CreateSyncshellPopupHandler>().Single();
((CreateSyncshellPopupHandler)_currentHandler).Open();
IsOpen = true;
});
Mediator.Subscribe<OpenBanUserPopupMessage>(this, (msg) => Mediator.Subscribe<OpenBanUserPopupMessage>(this, (msg) =>
{ {
_openPopup = true; _openPopup = true;
@@ -52,14 +44,6 @@ public class PopupHandler : WindowMediatorSubscriberBase
IsOpen = true; IsOpen = true;
}); });
Mediator.Subscribe<JoinSyncshellPopupMessage>(this, (_) =>
{
_openPopup = true;
_currentHandler = _handlers.OfType<JoinSyncshellPopupHandler>().Single();
((JoinSyncshellPopupHandler)_currentHandler).Open();
IsOpen = true;
});
Mediator.Subscribe<OpenSyncshellAdminPanelPopupMessage>(this, (msg) => Mediator.Subscribe<OpenSyncshellAdminPanelPopupMessage>(this, (msg) =>
{ {
IsOpen = true; IsOpen = true;

View File

@@ -4,27 +4,37 @@ using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.API.Data.Extensions; using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.Group; using MareSynchronos.API.Dto.Group;
using MareSynchronos.Services.Mediator;
using MareSynchronos.WebAPI; using MareSynchronos.WebAPI;
using Microsoft.Extensions.Logging;
using System.Numerics; using System.Numerics;
namespace MareSynchronos.UI.Components.Popup; namespace MareSynchronos.UI;
public class CreateSyncshellPopupHandler : IPopupHandler public class CreateSyncshellUI : WindowMediatorSubscriberBase
{ {
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly UiSharedService _uiSharedService; private readonly UiSharedService _uiSharedService;
private bool _errorGroupCreate; private bool _errorGroupCreate;
private GroupJoinDto? _lastCreatedGroup; private GroupJoinDto? _lastCreatedGroup;
public CreateSyncshellPopupHandler(ApiController apiController, UiSharedService uiSharedService) public CreateSyncshellUI(ILogger<CreateSyncshellUI> logger, MareMediator mareMediator, ApiController apiController, UiSharedService uiSharedService)
: base(logger, mareMediator, "Create new Syncshell###MareSynchronosCreateSyncshell")
{ {
_apiController = apiController; _apiController = apiController;
_uiSharedService = uiSharedService; _uiSharedService = uiSharedService;
SizeConstraints = new()
{
MinimumSize = new(550, 330),
MaximumSize = new(550, 330)
};
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse;
Mediator.Subscribe<DisconnectedMessage>(this, (_) => IsOpen = false);
} }
public Vector2 PopupSize => new(500, 300); public override void Draw()
public void DrawContent()
{ {
using (ImRaii.PushFont(_uiSharedService.UidFont)) using (ImRaii.PushFont(_uiSharedService.UidFont))
ImGui.TextUnformatted("Create new Syncshell"); ImGui.TextUnformatted("Create new Syncshell");
@@ -93,7 +103,7 @@ public class CreateSyncshellPopupHandler : IPopupHandler
} }
} }
public void Open() public override void OnOpen()
{ {
_lastCreatedGroup = null; _lastCreatedGroup = null;
} }

View File

@@ -35,17 +35,17 @@ public class DrawEntityFactory
_serverConfigurationManager = serverConfigurationManager; _serverConfigurationManager = serverConfigurationManager;
} }
public DrawFolderGroup CreateDrawGroupFolder(GroupFullInfoDto groupFullInfoDto, Dictionary<Pair, List<GroupFullInfoDto>> pairs) public DrawFolderGroup CreateDrawGroupFolder(GroupFullInfoDto groupFullInfoDto, Dictionary<Pair, List<GroupFullInfoDto>> pairs, int totalPairs = -1)
{ {
return new DrawFolderGroup(groupFullInfoDto.Group.GID, groupFullInfoDto, _apiController, return new DrawFolderGroup(groupFullInfoDto.Group.GID, groupFullInfoDto, _apiController,
pairs.Select(p => CreateDrawPair(groupFullInfoDto.Group.GID + p.Key.UserData.UID, p.Key, p.Value)).ToList(), pairs.Select(p => CreateDrawPair(groupFullInfoDto.Group.GID + p.Key.UserData.UID, p.Key, p.Value)).ToList(),
_tagHandler, _uidDisplayHandler, _mediator); _tagHandler, _uidDisplayHandler, _mediator, totalPairs);
} }
public DrawFolderTag CreateDrawTagFolder(string tag, Dictionary<Pair, List<GroupFullInfoDto>> pairs) public DrawFolderTag CreateDrawTagFolder(string tag, Dictionary<Pair, List<GroupFullInfoDto>> pairs, int totalPairs = -1)
{ {
return new(tag, pairs.Select(u => CreateDrawPair(tag, u.Key, u.Value)).ToList(), return new(tag, pairs.Select(u => CreateDrawPair(tag, u.Key, u.Value)).ToList(),
_tagHandler, _apiController, _selectPairForTagUi); _tagHandler, _apiController, _selectPairForTagUi, totalPairs);
} }
public DrawUserPair CreateDrawPair(string id, Pair user, List<GroupFullInfoDto> groups) public DrawUserPair CreateDrawPair(string id, Pair user, List<GroupFullInfoDto> groups)

View File

@@ -5,13 +5,14 @@ using MareSynchronos.API.Data.Enum;
using MareSynchronos.API.Data.Extensions; using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto; using MareSynchronos.API.Dto;
using MareSynchronos.API.Dto.Group; using MareSynchronos.API.Dto.Group;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using MareSynchronos.WebAPI; using MareSynchronos.WebAPI;
using System.Numerics; using Microsoft.Extensions.Logging;
namespace MareSynchronos.UI.Components.Popup; namespace MareSynchronos.UI;
internal class JoinSyncshellPopupHandler : IPopupHandler internal class JoinSyncshellUI : WindowMediatorSubscriberBase
{ {
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly UiSharedService _uiSharedService; private readonly UiSharedService _uiSharedService;
@@ -21,18 +22,35 @@ internal class JoinSyncshellPopupHandler : IPopupHandler
private string _previousPassword = string.Empty; private string _previousPassword = string.Empty;
private string _syncshellPassword = string.Empty; private string _syncshellPassword = string.Empty;
public JoinSyncshellPopupHandler(UiSharedService uiSharedService, ApiController apiController) public JoinSyncshellUI(ILogger<JoinSyncshellUI> logger, MareMediator mediator,
UiSharedService uiSharedService, ApiController apiController) : base(logger, mediator, "Join existing Syncshell###MareSynchronosJoinSyncshell")
{ {
_uiSharedService = uiSharedService; _uiSharedService = uiSharedService;
_apiController = apiController; _apiController = apiController;
SizeConstraints = new()
{
MinimumSize = new(700, 400),
MaximumSize = new(700, 400)
};
Mediator.Subscribe<DisconnectedMessage>(this, (_) => IsOpen = false);
Flags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize;
} }
public Vector2 PopupSize => new(700, 400); public override void OnOpen()
{
_desiredSyncshellToJoin = string.Empty;
_syncshellPassword = string.Empty;
_previousPassword = string.Empty;
_groupJoinInfo = null;
_ownPermissions = _apiController.DefaultPermissions.DeepClone()!;
}
public void DrawContent() public override void Draw()
{ {
using (ImRaii.PushFont(_uiSharedService.UidFont)) using (ImRaii.PushFont(_uiSharedService.UidFont))
ImGui.TextUnformatted((_groupJoinInfo == null || !_groupJoinInfo.Success) ? "Join Syncshell" : ("Finalize join Syncshell " + _groupJoinInfo.GroupAliasOrGID)); ImGui.TextUnformatted(_groupJoinInfo == null || !_groupJoinInfo.Success ? "Join Syncshell" : "Finalize join Syncshell " + _groupJoinInfo.GroupAliasOrGID);
ImGui.Separator(); ImGui.Separator();
if (_groupJoinInfo == null || !_groupJoinInfo.Success) if (_groupJoinInfo == null || !_groupJoinInfo.Success)
@@ -147,17 +165,8 @@ internal class JoinSyncshellPopupHandler : IPopupHandler
joinPermissions.SetDisableAnimations(_ownPermissions.DisableGroupAnimations); joinPermissions.SetDisableAnimations(_ownPermissions.DisableGroupAnimations);
joinPermissions.SetDisableVFX(_ownPermissions.DisableGroupVFX); joinPermissions.SetDisableVFX(_ownPermissions.DisableGroupVFX);
_ = _apiController.GroupJoinFinalize(new GroupJoinDto(_groupJoinInfo.Group, _previousPassword, joinPermissions)); _ = _apiController.GroupJoinFinalize(new GroupJoinDto(_groupJoinInfo.Group, _previousPassword, joinPermissions));
ImGui.CloseCurrentPopup(); IsOpen = false;
} }
} }
} }
public void Open()
{
_desiredSyncshellToJoin = string.Empty;
_syncshellPassword = string.Empty;
_previousPassword = string.Empty;
_groupJoinInfo = null;
_ownPermissions = _apiController.DefaultPermissions.DeepClone()!;
}
} }