minor refactoring

This commit is contained in:
rootdarkarchon
2024-03-17 14:43:34 +01:00
parent 142c65cc9d
commit 7baca3565a
34 changed files with 554 additions and 627 deletions

View File

@@ -11,13 +11,15 @@ namespace MareSynchronos.UI.Components.Popup;
public class BanUserPopupHandler : IPopupHandler
{
private readonly ApiController _apiController;
private readonly UiSharedService _uiSharedService;
private string _banReason = string.Empty;
private GroupFullInfoDto _group = null!;
private Pair _reportedPair = null!;
public BanUserPopupHandler(ApiController apiController)
public BanUserPopupHandler(ApiController apiController, UiSharedService uiSharedService)
{
_apiController = apiController;
_uiSharedService = uiSharedService;
}
public Vector2 PopupSize => new(500, 250);
@@ -29,7 +31,7 @@ public class BanUserPopupHandler : IPopupHandler
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
var reason = _banReason;

View File

@@ -1,5 +1,4 @@
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.Services.ServerConfiguration;
using System.Numerics;
@@ -25,7 +24,7 @@ public class CensusPopupHandler : IPopupHandler
public void DrawContent()
{
var start = 0f;
using (ImRaii.PushFont(_uiSharedService.UidFont))
using (_uiSharedService.UidFont.Push())
{
start = ImGui.GetCursorPosY() - ImGui.CalcTextSize("Mare Census Data").Y;
UiSharedService.TextWrapped("Mare Census Participation");

View File

@@ -13,9 +13,11 @@ public class PopupHandler : WindowMediatorSubscriberBase
{
protected bool _openPopup = false;
private readonly HashSet<IPopupHandler> _handlers;
private readonly UiSharedService _uiSharedService;
private IPopupHandler? _currentHandler = null;
public PopupHandler(ILogger<PopupHandler> logger, MareMediator mediator, IEnumerable<IPopupHandler> popupHandlers, PerformanceCollectorService performanceCollectorService)
public PopupHandler(ILogger<PopupHandler> logger, MareMediator mediator, IEnumerable<IPopupHandler> popupHandlers, PerformanceCollectorService performanceCollectorService,
UiSharedService uiSharedService)
: base(logger, mediator, "MarePopupHandler", performanceCollectorService)
{
Flags = ImGuiWindowFlags.NoBringToFrontOnFocus
@@ -52,6 +54,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
_currentHandler = _handlers.OfType<CensusPopupHandler>().Single();
IsOpen = true;
});
_uiSharedService = uiSharedService;
}
protected override void DrawInternal()
@@ -73,7 +76,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
if (_currentHandler.ShowClose)
{
ImGui.Separator();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close"))
{
ImGui.CloseCurrentPopup();
}

View File

@@ -28,7 +28,7 @@ internal class ReportPopupHandler : IPopupHandler
public void DrawContent()
{
using (ImRaii.PushFont(_uiSharedService.UidFont))
using (_uiSharedService.UidFont.Push())
UiSharedService.TextWrapped("Report " + _reportedPair!.UserData.AliasOrUID + " Mare Profile");
ImGui.InputTextMultiline("##reportReason", ref _reportReason, 500, new Vector2(500 - ImGui.GetStyle().ItemSpacing.X * 2, 200));
@@ -42,7 +42,7 @@ internal class ReportPopupHandler : IPopupHandler
using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason)))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
{
ImGui.CloseCurrentPopup();
var reason = _reportReason;