* tag '0.9.21': fix combat situations not redrawing every time after combat ends add more resilience to MCDF export and loading disable data application and scanner in combat fix bug add lock around adding to cached handled paths disable target in pvp add click to target in ui change tooltip for penumbra version to 0.8.2.1 add file storage validation add experimental resolving of data through penumbra adjust initial dialog to opt in/out into census with buttons
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using Dalamud.Interface;
|
|
using Dalamud.Interface.Utility;
|
|
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<OpenBanUserPopupMessage>(this, (msg) =>
|
|
{
|
|
_openPopup = true;
|
|
_currentHandler = _handlers.OfType<BanUserPopupHandler>().Single();
|
|
((BanUserPopupHandler)_currentHandler).Open(msg);
|
|
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 * ImGuiHelpers.GlobalScale);
|
|
ImGui.SetNextWindowPos(viewportSize / 2, ImGuiCond.Always, new Vector2(0.5f));
|
|
using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal);
|
|
if (!popup) return;
|
|
_currentHandler.DrawContent();
|
|
if (_currentHandler.ShowClose)
|
|
{
|
|
ImGui.Separator();
|
|
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
|
|
{
|
|
ImGui.CloseCurrentPopup();
|
|
}
|
|
}
|
|
}
|
|
} |