add total count on mouseover, make syncshell windows non-blocking
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
public class CreateSyncshellPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private bool _errorGroupCreate;
|
||||
private GroupJoinDto? _lastCreatedGroup;
|
||||
|
||||
public CreateSyncshellPopupHandler(ApiController apiController, UiSharedService uiSharedService)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(500, 300);
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
ImGui.TextUnformatted("Create new Syncshell");
|
||||
|
||||
if (_lastCreatedGroup == null)
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create Syncshell"))
|
||||
{
|
||||
try
|
||||
{
|
||||
_lastCreatedGroup = _apiController.GroupCreate().Result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_lastCreatedGroup = null;
|
||||
_errorGroupCreate = true;
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (_lastCreatedGroup == null)
|
||||
{
|
||||
UiSharedService.TextWrapped("Creating a new Syncshell with create it defaulting to your current preferred permissions for Syncshells." + Environment.NewLine +
|
||||
"- You can own up to " + _apiController.ServerInfo.MaxGroupsCreatedByUser + " Syncshells on this server." + Environment.NewLine +
|
||||
"- You can join up to " + _apiController.ServerInfo.MaxGroupsJoinedByUser + " Syncshells on this server (including your own)" + Environment.NewLine +
|
||||
"- Syncshells on this server can have a maximum of " + _apiController.ServerInfo.MaxGroupUserCount + " users");
|
||||
ImGui.Dummy(new(2f));
|
||||
ImGui.TextUnformatted("Your current Syncshell preferred permissions are:");
|
||||
ImGui.TextUnformatted("- Animations");
|
||||
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupAnimations);
|
||||
ImGui.TextUnformatted("- Sounds");
|
||||
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupSounds);
|
||||
ImGui.TextUnformatted("- VFX");
|
||||
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupVFX);
|
||||
UiSharedService.TextWrapped("(Those preferred permissions can be changed anytime after Syncshell creation, your defaults can be changed anytime in the Mare Settings)");
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorGroupCreate = false;
|
||||
ImGui.TextUnformatted("Syncshell ID: " + _lastCreatedGroup.Group.GID);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy))
|
||||
{
|
||||
ImGui.SetClipboardText(_lastCreatedGroup.Password);
|
||||
}
|
||||
UiSharedService.TextWrapped("You can change the Syncshell password later at any time.");
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped("These settings were set based on your preferred syncshell permissions:");
|
||||
ImGui.Dummy(new(2f));
|
||||
UiSharedService.TextWrapped("Suggest Animation sync:");
|
||||
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableAnimations());
|
||||
UiSharedService.TextWrapped("Suggest Sounds sync:");
|
||||
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableSounds());
|
||||
UiSharedService.TextWrapped("Suggest VFX sync:");
|
||||
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableVFX());
|
||||
}
|
||||
|
||||
if (_errorGroupCreate)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Something went wrong during creation of a new Syncshell", new Vector4(1, 0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
_lastCreatedGroup = null;
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
internal class JoinSyncshellPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private string _desiredSyncshellToJoin = string.Empty;
|
||||
private GroupJoinInfoDto? _groupJoinInfo = null;
|
||||
private DefaultPermissionsDto _ownPermissions = null!;
|
||||
private string _previousPassword = string.Empty;
|
||||
private string _syncshellPassword = string.Empty;
|
||||
|
||||
public JoinSyncshellPopupHandler(UiSharedService uiSharedService, ApiController apiController)
|
||||
{
|
||||
_uiSharedService = uiSharedService;
|
||||
_apiController = apiController;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(700, 400);
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
ImGui.TextUnformatted((_groupJoinInfo == null || !_groupJoinInfo.Success) ? "Join Syncshell" : ("Finalize join Syncshell " + _groupJoinInfo.GroupAliasOrGID));
|
||||
ImGui.Separator();
|
||||
|
||||
if (_groupJoinInfo == null || !_groupJoinInfo.Success)
|
||||
{
|
||||
UiSharedService.TextWrapped("Here you can join existing Syncshells. " +
|
||||
"Please keep in mind that you cannot join more than " + _apiController.ServerInfo.MaxGroupsJoinedByUser + " syncshells on this server." + Environment.NewLine +
|
||||
"Joining a Syncshell will pair you implicitly with all existing users in the Syncshell." + Environment.NewLine +
|
||||
"All permissions to all users in the Syncshell will be set to the preferred Syncshell permissions on joining, excluding prior set preferred permissions.");
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted("Note: Syncshell ID and Password are case sensitive. MSS- is part of Syncshell IDs, unless using Vanity IDs.");
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("Syncshell ID");
|
||||
ImGui.SameLine(200);
|
||||
ImGui.InputTextWithHint("##syncshellId", "Full Syncshell ID", ref _desiredSyncshellToJoin, 20);
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("Syncshell Password");
|
||||
ImGui.SameLine(200);
|
||||
ImGui.InputTextWithHint("##syncshellpw", "Password", ref _syncshellPassword, 20, ImGuiInputTextFlags.Password);
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(_desiredSyncshellToJoin) || string.IsNullOrEmpty(_syncshellPassword)))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Join Syncshell"))
|
||||
{
|
||||
_groupJoinInfo = _apiController.GroupJoin(new GroupPasswordDto(new API.Data.GroupData(_desiredSyncshellToJoin), _syncshellPassword)).Result;
|
||||
_previousPassword = _syncshellPassword;
|
||||
_syncshellPassword = string.Empty;
|
||||
}
|
||||
}
|
||||
if (_groupJoinInfo != null && !_groupJoinInfo.Success)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Failed to join the Syncshell. This is due to one of following reasons:" + Environment.NewLine +
|
||||
"- The Syncshell does not exist or the password is incorrect" + Environment.NewLine +
|
||||
"- You are already in that Syncshell or are banned from that Syncshell" + Environment.NewLine +
|
||||
"- The Syncshell is at capacity or has invites disabled" + Environment.NewLine, ImGuiColors.DalamudYellow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID);
|
||||
ImGui.Dummy(new(2));
|
||||
ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:");
|
||||
ImGui.TextUnformatted("- Sounds ");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
|
||||
ImGui.TextUnformatted("- Animations");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
|
||||
ImGui.TextUnformatted("- VFX");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
|
||||
|
||||
if (_groupJoinInfo.GroupPermissions.IsPreferDisableSounds() != _ownPermissions.DisableGroupSounds
|
||||
|| _groupJoinInfo.GroupPermissions.IsPreferDisableVFX() != _ownPermissions.DisableGroupVFX
|
||||
|| _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations() != _ownPermissions.DisableGroupAnimations)
|
||||
{
|
||||
ImGui.Dummy(new(2));
|
||||
UiSharedService.ColorText("Your current preferred default Syncshell permissions deviate from the suggested permissions:", ImGuiColors.DalamudYellow);
|
||||
if (_groupJoinInfo.GroupPermissions.IsPreferDisableSounds() != _ownPermissions.DisableGroupSounds)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("- Sounds");
|
||||
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupSounds);
|
||||
ImGui.SameLine(200);
|
||||
ImGui.TextUnformatted("Suggested");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
|
||||
ImGui.SameLine();
|
||||
using var id = ImRaii.PushId("suggestedSounds");
|
||||
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
|
||||
{
|
||||
_ownPermissions.DisableGroupSounds = _groupJoinInfo.GroupPermissions.IsPreferDisableSounds();
|
||||
}
|
||||
}
|
||||
if (_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations() != _ownPermissions.DisableGroupAnimations)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("- Animations");
|
||||
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupAnimations);
|
||||
ImGui.SameLine(200);
|
||||
ImGui.TextUnformatted("Suggested");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
|
||||
ImGui.SameLine();
|
||||
using var id = ImRaii.PushId("suggestedAnims");
|
||||
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
|
||||
{
|
||||
_ownPermissions.DisableGroupAnimations = _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations();
|
||||
}
|
||||
}
|
||||
if (_groupJoinInfo.GroupPermissions.IsPreferDisableVFX() != _ownPermissions.DisableGroupVFX)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("- VFX");
|
||||
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupVFX);
|
||||
ImGui.SameLine(200);
|
||||
ImGui.TextUnformatted("Suggested");
|
||||
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
|
||||
ImGui.SameLine();
|
||||
using var id = ImRaii.PushId("suggestedVfx");
|
||||
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
|
||||
{
|
||||
_ownPermissions.DisableGroupVFX = _groupJoinInfo.GroupPermissions.IsPreferDisableVFX();
|
||||
}
|
||||
}
|
||||
UiSharedService.TextWrapped("Note: you do not need to apply the suggested Syncshell permissions, they are solely suggestions by the staff of the Syncshell.");
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.TextWrapped("Your default syncshell permissions on joining are in line with the suggested Syncshell permissions through the owner.");
|
||||
}
|
||||
ImGui.Dummy(new(2));
|
||||
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Finalize and join " + _groupJoinInfo.GroupAliasOrGID))
|
||||
{
|
||||
GroupUserPreferredPermissions joinPermissions = GroupUserPreferredPermissions.NoneSet;
|
||||
joinPermissions.SetDisableSounds(_ownPermissions.DisableGroupSounds);
|
||||
joinPermissions.SetDisableAnimations(_ownPermissions.DisableGroupAnimations);
|
||||
joinPermissions.SetDisableVFX(_ownPermissions.DisableGroupVFX);
|
||||
_ = _apiController.GroupJoinFinalize(new GroupJoinDto(_groupJoinInfo.Group, _previousPassword, joinPermissions));
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
_desiredSyncshellToJoin = string.Empty;
|
||||
_syncshellPassword = string.Empty;
|
||||
_previousPassword = string.Empty;
|
||||
_groupJoinInfo = null;
|
||||
_ownPermissions = _apiController.DefaultPermissions.DeepClone()!;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user