add total count on mouseover, make syncshell windows non-blocking
This commit is contained in:
@@ -112,14 +112,15 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, JoinSyncshellUI>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, CreateSyncshellUI>();
|
||||
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>((s) => new EditProfileUi(s.GetRequiredService<ILogger<EditProfileUi>>(),
|
||||
s.GetRequiredService<MareMediator>(), s.GetRequiredService<ApiController>(), pluginInterface.UiBuilder, s.GetRequiredService<UiSharedService>(),
|
||||
s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareProfileManager>()));
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, ReportPopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, CreateSyncshellPopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, JoinSyncshellPopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, SyncshellAdminPopupHandler>();
|
||||
collection.AddScoped<CacheCreationService>();
|
||||
collection.AddScoped<TransientResourceManager>();
|
||||
|
||||
@@ -73,8 +73,6 @@ public record PairHandlerVisibleMessage(PairHandler Player) : MessageBase;
|
||||
public record RefreshUiMessage : MessageBase;
|
||||
public record OpenReportPopupMessage(Pair PairToReport) : MessageBase;
|
||||
public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : MessageBase;
|
||||
public record JoinSyncshellPopupMessage() : MessageBase;
|
||||
public record OpenCreateSyncshellPopupMessage() : MessageBase;
|
||||
public record OpenSyncshellAdminPanelPopupMessage(GroupFullInfoDto GroupInfo) : MessageBase;
|
||||
|
||||
#pragma warning restore S2094
|
||||
|
||||
@@ -232,7 +232,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", _syncshellMenuSize, true))
|
||||
{
|
||||
Mediator.Publish(new OpenCreateSyncshellPopupMessage());
|
||||
Mediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI)));
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", _syncshellMenuSize, true))
|
||||
{
|
||||
Mediator.Publish(new JoinSyncshellPopupMessage());
|
||||
Mediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI)));
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,8 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
: (u.Key.GetNote() ?? u.Key.UserData.AliasOrUID), StringComparer.Ordinal)
|
||||
.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)
|
||||
@@ -544,7 +545,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
alreadyInTags.Add(u.Key);
|
||||
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)
|
||||
|
||||
@@ -13,11 +13,13 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
protected readonly TagHandler _tagHandler;
|
||||
private float _menuWidth = -1;
|
||||
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;
|
||||
_drawPairs = drawPairs;
|
||||
_tagHandler = tagHandler;
|
||||
TotalPairs = totalPairs;
|
||||
}
|
||||
|
||||
protected abstract bool RenderIfEmpty { get; }
|
||||
|
||||
@@ -21,8 +21,8 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
|
||||
public DrawFolderGroup(string id, GroupFullInfoDto groupFullInfoDto, ApiController apiController,
|
||||
IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler,
|
||||
MareMediator mareMediator) :
|
||||
base(id, drawPairs, tagHandler)
|
||||
MareMediator mareMediator, int totalPairs) :
|
||||
base(id, drawPairs, tagHandler, totalPairs)
|
||||
{
|
||||
_groupFullInfoDto = groupFullInfoDto;
|
||||
_apiController = apiController;
|
||||
@@ -53,7 +53,7 @@ public class DrawFolderGroup : DrawFolderBase
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
|
||||
}
|
||||
UiSharedService.AttachToolTip(OnlinePairs + " online in this syncshell");
|
||||
UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total");
|
||||
|
||||
ImGui.SameLine();
|
||||
if (IsOwner)
|
||||
|
||||
@@ -13,8 +13,8 @@ public class DrawFolderTag : DrawFolderBase
|
||||
private readonly ApiController _apiController;
|
||||
private readonly SelectPairForTagUi _selectPairForTagUi;
|
||||
|
||||
public DrawFolderTag(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, ApiController apiController, SelectPairForTagUi selectPairForTagUi)
|
||||
: base(id, drawPairs, tagHandler)
|
||||
public DrawFolderTag(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, ApiController apiController, SelectPairForTagUi selectPairForTagUi, int totalPairs)
|
||||
: base(id, drawPairs, tagHandler, totalPairs)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_selectPairForTagUi = selectPairForTagUi;
|
||||
@@ -55,9 +55,12 @@ public class DrawFolderTag : DrawFolderBase
|
||||
|
||||
private bool RenderCount => _id switch
|
||||
{
|
||||
TagHandler.CustomOfflineSyncshellTag => false,
|
||||
TagHandler.CustomOfflineTag => false,
|
||||
TagHandler.CustomUnpairedTag => false,
|
||||
TagHandler.CustomOnlineTag => false,
|
||||
TagHandler.CustomOfflineTag => false,
|
||||
TagHandler.CustomVisibleTag => false,
|
||||
TagHandler.CustomAllTag => false,
|
||||
TagHandler.CustomOfflineSyncshellTag => false,
|
||||
_ => true
|
||||
};
|
||||
|
||||
@@ -87,7 +90,7 @@ public class DrawFolderTag : DrawFolderBase
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
|
||||
}
|
||||
UiSharedService.AttachToolTip(OnlinePairs + " online in this group");
|
||||
UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total");
|
||||
}
|
||||
ImGui.SameLine();
|
||||
return ImGui.GetCursorPosX();
|
||||
|
||||
@@ -10,6 +10,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
private readonly IEnumerable<IDrawFolder> _groups;
|
||||
private readonly TagHandler _tagHandler;
|
||||
public int OnlinePairs => _groups.Sum(g => g.OnlinePairs);
|
||||
public int TotalPairs => _groups.Sum(g => g.TotalPairs);
|
||||
|
||||
public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler)
|
||||
{
|
||||
@@ -39,7 +40,8 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
ImGui.SameLine();
|
||||
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.TextUnformatted("All Syncshells");
|
||||
ImGui.Separator();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
public interface IDrawFolder
|
||||
{
|
||||
int TotalPairs { get; }
|
||||
int OnlinePairs { get; }
|
||||
void Draw();
|
||||
}
|
||||
|
||||
@@ -36,14 +36,6 @@ public class PopupHandler : WindowMediatorSubscriberBase
|
||||
IsOpen = true;
|
||||
});
|
||||
|
||||
Mediator.Subscribe<OpenCreateSyncshellPopupMessage>(this, (msg) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<CreateSyncshellPopupHandler>().Single();
|
||||
((CreateSyncshellPopupHandler)_currentHandler).Open();
|
||||
IsOpen = true;
|
||||
});
|
||||
|
||||
Mediator.Subscribe<OpenBanUserPopupMessage>(this, (msg) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
@@ -52,14 +44,6 @@ public class PopupHandler : WindowMediatorSubscriberBase
|
||||
IsOpen = true;
|
||||
});
|
||||
|
||||
Mediator.Subscribe<JoinSyncshellPopupMessage>(this, (_) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<JoinSyncshellPopupHandler>().Single();
|
||||
((JoinSyncshellPopupHandler)_currentHandler).Open();
|
||||
IsOpen = true;
|
||||
});
|
||||
|
||||
Mediator.Subscribe<OpenSyncshellAdminPanelPopupMessage>(this, (msg) =>
|
||||
{
|
||||
IsOpen = true;
|
||||
|
||||
@@ -4,27 +4,37 @@ using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 UiSharedService _uiSharedService;
|
||||
private bool _errorGroupCreate;
|
||||
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;
|
||||
_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 void DrawContent()
|
||||
public override void Draw()
|
||||
{
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
ImGui.TextUnformatted("Create new Syncshell");
|
||||
@@ -93,7 +103,7 @@ public class CreateSyncshellPopupHandler : IPopupHandler
|
||||
}
|
||||
}
|
||||
|
||||
public void Open()
|
||||
public override void OnOpen()
|
||||
{
|
||||
_lastCreatedGroup = null;
|
||||
}
|
||||
@@ -35,17 +35,17 @@ public class DrawEntityFactory
|
||||
_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,
|
||||
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(),
|
||||
_tagHandler, _apiController, _selectPairForTagUi);
|
||||
_tagHandler, _apiController, _selectPairForTagUi, totalPairs);
|
||||
}
|
||||
|
||||
public DrawUserPair CreateDrawPair(string id, Pair user, List<GroupFullInfoDto> groups)
|
||||
|
||||
@@ -5,13 +5,14 @@ using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Utils;
|
||||
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 UiSharedService _uiSharedService;
|
||||
@@ -21,18 +22,35 @@ internal class JoinSyncshellPopupHandler : IPopupHandler
|
||||
private string _previousPassword = 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;
|
||||
_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))
|
||||
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();
|
||||
|
||||
if (_groupJoinInfo == null || !_groupJoinInfo.Success)
|
||||
@@ -147,17 +165,8 @@ internal class JoinSyncshellPopupHandler : IPopupHandler
|
||||
joinPermissions.SetDisableAnimations(_ownPermissions.DisableGroupAnimations);
|
||||
joinPermissions.SetDisableVFX(_ownPermissions.DisableGroupVFX);
|
||||
_ = _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()!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user