Partially revert Mare 0.9 UI/API changes

This commit is contained in:
Loporrit
2023-12-08 12:00:43 +00:00
parent d2ccafd505
commit 78b56aa952
37 changed files with 1795 additions and 1954 deletions

View File

@@ -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;
}
}

View File

@@ -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()!;
}
}

View File

@@ -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;

View File

@@ -143,44 +143,42 @@ internal class SyncshellAdminPopupHandler : IPopupHandler
var permNode = ImRaii.TreeNode("Permissions");
if (permNode)
{
bool isDisableAnimations = perm.IsPreferDisableAnimations();
bool isDisableSounds = perm.IsPreferDisableSounds();
bool isDisableVfx = perm.IsPreferDisableVFX();
bool isDisableAnimations = perm.IsDisableAnimations();
bool isDisableSounds = perm.IsDisableSounds();
bool isDisableVfx = perm.IsDisableVFX();
ImGui.AlignTextToFramePadding();
ImGui.Text("Suggest Sound Sync");
ImGui.Text("Sound Sync");
UiSharedService.BooleanToColoredIcon(!isDisableSounds);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
isDisableSounds ? "Suggest to enable sound sync" : "Suggest to disable sound sync"))
isDisableSounds ? "Enable sound sync" : "Disable sound sync"))
{
perm.SetPreferDisableSounds(!perm.IsPreferDisableSounds());
perm.SetDisableSounds(!perm.IsDisableSounds());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
ImGui.AlignTextToFramePadding();
ImGui.Text("Suggest Animation Sync");
ImGui.Text("Animation Sync");
UiSharedService.BooleanToColoredIcon(!isDisableAnimations);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
isDisableAnimations ? "Suggest to enable animation sync" : "Suggest to disable animation sync"))
isDisableAnimations ? "Enable animation sync" : "Disable animation sync"))
{
perm.SetPreferDisableAnimations(!perm.IsPreferDisableAnimations());
perm.SetDisableAnimations(!perm.IsDisableAnimations());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
ImGui.AlignTextToFramePadding();
ImGui.Text("Suggest VFX Sync");
ImGui.Text("VFX Sync");
UiSharedService.BooleanToColoredIcon(!isDisableVfx);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
isDisableVfx ? "Suggest to enable vfx sync" : "Suggest to disable vfx sync"))
isDisableVfx ? "Enable VFX sync" : "Disable VFX sync"))
{
perm.SetPreferDisableVFX(!perm.IsPreferDisableVFX());
perm.SetDisableVFX(!perm.IsDisableVFX());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
UiSharedService.TextWrapped("Note: those suggested permissions will be shown to users on joining the Syncshell.");
}
permNode.Dispose();