Mare 0.9 (#65)
* add jwt expiry * start of 0.9 api impl * some stuff idk * some more impl * some cleanup * remove grouppair, add configuration, rework some pair drawing stuff * do some stuff * rework some ui * I don't even know anymore * add cancellationtoken * token bla * ui fixes etc * probably individual adding/removing now working fully as expected * add working report popup * I guess it's more syncshell shit or so * popup shit idk * work out most of the syncshell bullshit I guess * delete some old crap * are we actually getting closer to the end * update pair info stuff * more fixes/adjustments, idk * refactor some things * some rework * some more cleanup * cleanup * make menu buttons w i d e * better icon text buttons * add all syncshell folder and ordering fixes --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
46
MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs
Normal file
46
MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
public class BanUserPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private string _banReason = string.Empty;
|
||||
private GroupFullInfoDto _group = null!;
|
||||
private Pair _reportedPair = null!;
|
||||
|
||||
public BanUserPopupHandler(ApiController apiController)
|
||||
{
|
||||
_apiController = apiController;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(500, 250);
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
|
||||
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
|
||||
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var reason = _banReason;
|
||||
_ = _apiController.GroupBanUser(new GroupPairDto(_group.Group, _reportedPair.UserData), reason);
|
||||
_banReason = string.Empty;
|
||||
}
|
||||
UiSharedService.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
||||
}
|
||||
|
||||
public void Open(OpenBanUserPopupMessage message)
|
||||
{
|
||||
_reportedPair = message.PairToBan;
|
||||
_group = message.GroupFullInfoDto;
|
||||
_banReason = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
10
MareSynchronos/UI/Components/Popup/IPopupHandler.cs
Normal file
10
MareSynchronos/UI/Components/Popup/IPopupHandler.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
public interface IPopupHandler
|
||||
{
|
||||
Vector2 PopupSize { get; }
|
||||
|
||||
void DrawContent();
|
||||
}
|
||||
163
MareSynchronos/UI/Components/Popup/JoinSyncshellPopupHandler.cs
Normal file
163
MareSynchronos/UI/Components/Popup/JoinSyncshellPopupHandler.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
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()!;
|
||||
}
|
||||
}
|
||||
95
MareSynchronos/UI/Components/Popup/PopupHandler.cs
Normal file
95
MareSynchronos/UI/Components/Popup/PopupHandler.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
public class PopupHandler : WindowMediatorSubscriberBase
|
||||
{
|
||||
protected bool _openPopup = false;
|
||||
private readonly HashSet<IPopupHandler> _handlers;
|
||||
private IPopupHandler? _currentHandler = null;
|
||||
|
||||
public PopupHandler(ILogger<PopupHandler> logger, MareMediator mediator, IEnumerable<IPopupHandler> popupHandlers)
|
||||
: base(logger, mediator, "MarePopupHandler")
|
||||
{
|
||||
Flags = ImGuiWindowFlags.NoBringToFrontOnFocus
|
||||
| ImGuiWindowFlags.NoDecoration
|
||||
| ImGuiWindowFlags.NoInputs
|
||||
| ImGuiWindowFlags.NoSavedSettings
|
||||
| ImGuiWindowFlags.NoBackground
|
||||
| ImGuiWindowFlags.NoMove
|
||||
| ImGuiWindowFlags.NoNav
|
||||
| ImGuiWindowFlags.NoTitleBar;
|
||||
IsOpen = true;
|
||||
|
||||
_handlers = popupHandlers.ToHashSet();
|
||||
|
||||
Mediator.Subscribe<OpenReportPopupMessage>(this, (msg) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<ReportPopupHandler>().Single();
|
||||
((ReportPopupHandler)_currentHandler).Open(msg);
|
||||
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;
|
||||
_currentHandler = _handlers.OfType<BanUserPopupHandler>().Single();
|
||||
((BanUserPopupHandler)_currentHandler).Open(msg);
|
||||
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;
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<SyncshellAdminPopupHandler>().Single();
|
||||
((SyncshellAdminPopupHandler)_currentHandler).Open(msg.GroupInfo);
|
||||
IsOpen = true;
|
||||
});
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
if (_currentHandler == null) return;
|
||||
|
||||
if (_openPopup)
|
||||
{
|
||||
ImGui.OpenPopup(WindowName);
|
||||
_openPopup = false;
|
||||
}
|
||||
|
||||
var viewportSize = ImGui.GetWindowViewport().Size;
|
||||
ImGui.SetNextWindowSize(_currentHandler!.PopupSize);
|
||||
ImGui.SetNextWindowPos(viewportSize / 2, ImGuiCond.Always, new Vector2(0.5f));
|
||||
using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal);
|
||||
if (!popup) return;
|
||||
_currentHandler.DrawContent();
|
||||
ImGui.Separator();
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
57
MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs
Normal file
57
MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
internal class ReportPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private Pair? _reportedPair;
|
||||
private string _reportReason = string.Empty;
|
||||
|
||||
public ReportPopupHandler(ApiController apiController, UiSharedService uiSharedService)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(500, 500);
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
UiSharedService.TextWrapped("Report " + _reportedPair!.UserData.AliasOrUID + " Mare Profile");
|
||||
|
||||
ImGui.InputTextMultiline("##reportReason", ref _reportReason, 500, new Vector2(500 - ImGui.GetStyle().ItemSpacing.X * 2, 200));
|
||||
UiSharedService.TextWrapped($"Note: Sending a report will disable the offending profile globally.{Environment.NewLine}" +
|
||||
$"The report will be sent to the team of your currently connected Mare Synchronos Service.{Environment.NewLine}" +
|
||||
$"The report will include your user and your contact info (Discord User).{Environment.NewLine}" +
|
||||
$"Depending on the severity of the offense the users Mare profile or account can be permanently disabled or banned.");
|
||||
UiSharedService.ColorTextWrapped("Report spam and wrong reports will not be tolerated and can lead to permanent account suspension.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("This is not for reporting misbehavior or Mare usage but solely for the actual profile. " +
|
||||
"Reports that are not solely for the profile will be ignored.", ImGuiColors.DalamudYellow);
|
||||
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason)))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var reason = _reportReason;
|
||||
_ = _apiController.UserReportProfile(new(_reportedPair.UserData, reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Open(OpenReportPopupMessage msg)
|
||||
{
|
||||
_reportedPair = msg.PairToReport;
|
||||
_reportReason = string.Empty;
|
||||
}
|
||||
}
|
||||
234
MareSynchronos/UI/Components/Popup/SyncshellAdminPopupHandler.cs
Normal file
234
MareSynchronos/UI/Components/Popup/SyncshellAdminPopupHandler.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
internal class SyncshellAdminPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly List<string> _oneTimeInvites = [];
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private List<BannedGroupUserDto> _bannedUsers = [];
|
||||
private GroupFullInfoDto _groupFullInfo = null!;
|
||||
private bool _isModerator = false;
|
||||
private bool _isOwner = false;
|
||||
private int _multiInvites = 30;
|
||||
private string _newPassword = string.Empty;
|
||||
private bool _pwChangeSuccess = true;
|
||||
|
||||
public SyncshellAdminPopupHandler(ApiController apiController, UiSharedService uiSharedService, PairManager pairManager)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
_pairManager = pairManager;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(700, 500);
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
if (!_isModerator && !_isOwner) return;
|
||||
|
||||
_groupFullInfo = _pairManager.Groups[_groupFullInfo.Group];
|
||||
|
||||
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||
ImGui.TextUnformatted(_groupFullInfo.GroupAliasOrGID + " Administrative Panel");
|
||||
|
||||
ImGui.Separator();
|
||||
var perm = _groupFullInfo.GroupPermissions;
|
||||
|
||||
var inviteNode = ImRaii.TreeNode("Invites");
|
||||
if (inviteNode)
|
||||
{
|
||||
bool isInvitesDisabled = perm.IsDisableInvites();
|
||||
|
||||
if (UiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
|
||||
isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell"))
|
||||
{
|
||||
perm.SetDisableInvites(!isInvitesDisabled);
|
||||
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
|
||||
}
|
||||
|
||||
ImGui.Dummy(new(2f));
|
||||
|
||||
UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password.");
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite"))
|
||||
{
|
||||
ImGui.SetClipboardText(_apiController.GroupCreateTempInvite(new(_groupFullInfo.Group), 1).Result.FirstOrDefault() ?? string.Empty);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Creates a single-use password for joining the syncshell which is valid for 24h and copies it to the clipboard.");
|
||||
ImGui.InputInt("##amountofinvites", ref _multiInvites);
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.Disabled(_multiInvites <= 1 || _multiInvites > 100))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Generate " + _multiInvites + " one-time invites"))
|
||||
{
|
||||
_oneTimeInvites.AddRange(_apiController.GroupCreateTempInvite(new(_groupFullInfo.Group), _multiInvites).Result);
|
||||
}
|
||||
}
|
||||
|
||||
if (_oneTimeInvites.Any())
|
||||
{
|
||||
var invites = string.Join(Environment.NewLine, _oneTimeInvites);
|
||||
ImGui.InputTextMultiline("Generated Multi Invites", ref invites, 5000, new(0, 0), ImGuiInputTextFlags.ReadOnly);
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
|
||||
{
|
||||
ImGui.SetClipboardText(invites);
|
||||
}
|
||||
}
|
||||
}
|
||||
inviteNode.Dispose();
|
||||
|
||||
var mgmtNode = ImRaii.TreeNode("User Management");
|
||||
if (mgmtNode)
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
|
||||
{
|
||||
_ = _apiController.GroupClear(new(_groupFullInfo.Group));
|
||||
}
|
||||
UiSharedService.AttachToolTip("This will remove all non-pinned, non-moderator users from the Syncshell");
|
||||
|
||||
ImGui.Dummy(new(2f));
|
||||
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
|
||||
{
|
||||
_bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(_groupFullInfo.Group)).Result;
|
||||
}
|
||||
|
||||
if (ImGui.BeginTable("bannedusertable" + _groupFullInfo.GID, 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.ScrollY))
|
||||
{
|
||||
ImGui.TableSetupColumn("UID", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("Alias", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("By", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("Date", ImGuiTableColumnFlags.None, 2);
|
||||
ImGui.TableSetupColumn("Reason", ImGuiTableColumnFlags.None, 3);
|
||||
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.None, 1);
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
foreach (var bannedUser in _bannedUsers.ToList())
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(bannedUser.UID);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(bannedUser.UserAlias ?? string.Empty);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(bannedUser.BannedBy);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(bannedUser.BannedOn.ToLocalTime().ToString(CultureInfo.CurrentCulture));
|
||||
ImGui.TableNextColumn();
|
||||
UiSharedService.TextWrapped(bannedUser.Reason);
|
||||
ImGui.TableNextColumn();
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
|
||||
{
|
||||
_ = _apiController.GroupUnbanUser(bannedUser);
|
||||
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
mgmtNode.Dispose();
|
||||
|
||||
var permNode = ImRaii.TreeNode("Permissions");
|
||||
if (permNode)
|
||||
{
|
||||
bool isDisableAnimations = perm.IsPreferDisableAnimations();
|
||||
bool isDisableSounds = perm.IsPreferDisableSounds();
|
||||
bool isDisableVfx = perm.IsPreferDisableVFX();
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text("Suggest 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"))
|
||||
{
|
||||
perm.SetPreferDisableSounds(!perm.IsPreferDisableSounds());
|
||||
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
|
||||
}
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text("Suggest 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"))
|
||||
{
|
||||
perm.SetPreferDisableAnimations(!perm.IsPreferDisableAnimations());
|
||||
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
|
||||
}
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text("Suggest 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"))
|
||||
{
|
||||
perm.SetPreferDisableVFX(!perm.IsPreferDisableVFX());
|
||||
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
|
||||
}
|
||||
|
||||
UiSharedService.TextWrapped("Note: those suggested permissions will be shown to users on joining the Syncshell.");
|
||||
}
|
||||
permNode.Dispose();
|
||||
|
||||
if (_isOwner)
|
||||
{
|
||||
var ownerNode = ImRaii.TreeNode("Owner Settings");
|
||||
if (ownerNode)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("New Password");
|
||||
ImGui.SameLine();
|
||||
ImGui.InputTextWithHint("##changepw", "Min 10 characters", ref _newPassword, 50);
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.Disabled(_newPassword.Length < 10))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Passport, "Change Password"))
|
||||
{
|
||||
_pwChangeSuccess = _apiController.GroupChangePassword(new GroupPasswordDto(_groupFullInfo.Group, _newPassword)).Result;
|
||||
_newPassword = string.Empty;
|
||||
}
|
||||
}
|
||||
UiSharedService.AttachToolTip("Password requires to be at least 10 characters long. This action is irreversible.");
|
||||
|
||||
if (!_pwChangeSuccess)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Failed to change the password. Password requires to be at least 10 characters long.", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
_ = _apiController.GroupDelete(new(_groupFullInfo.Group));
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hold CTRL and Shift and click to delete this Syncshell." + Environment.NewLine + "WARNING: this action is irreversible.");
|
||||
}
|
||||
ownerNode.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Open(GroupFullInfoDto groupFullInfo)
|
||||
{
|
||||
_groupFullInfo = groupFullInfo;
|
||||
_isOwner = string.Equals(_groupFullInfo.OwnerUID, _apiController.UID, StringComparison.Ordinal);
|
||||
_isModerator = _groupFullInfo.GroupUserInfo.IsModerator();
|
||||
_newPassword = string.Empty;
|
||||
_bannedUsers.Clear();
|
||||
_oneTimeInvites.Clear();
|
||||
_multiInvites = 30;
|
||||
_pwChangeSuccess = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user