rebuild project & update internal names
This commit is contained in:
50
LightlessSync/UI/Components/Popup/BanUserPopupHandler.cs
Normal file
50
LightlessSync/UI/Components/Popup/BanUserPopupHandler.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using LightlessSync.API.Dto.Group;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.WebAPI;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.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, UiSharedService uiSharedService)
|
||||
{
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
public Vector2 PopupSize => new(500, 250);
|
||||
|
||||
public bool ShowClose => true;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
64
LightlessSync/UI/Components/Popup/CensusPopupHandler.cs
Normal file
64
LightlessSync/UI/Components/Popup/CensusPopupHandler.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
using LightlessSync.Services.ServerConfiguration;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI.Components.Popup;
|
||||
|
||||
public class CensusPopupHandler : IPopupHandler
|
||||
{
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
|
||||
public CensusPopupHandler(ServerConfigurationManager serverConfigurationManager, UiSharedService uiSharedService)
|
||||
{
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
private Vector2 _size = new(600, 450);
|
||||
public Vector2 PopupSize => _size;
|
||||
|
||||
public bool ShowClose => false;
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
var start = 0f;
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
{
|
||||
start = ImGui.GetCursorPosY() - ImGui.CalcTextSize("Mare Census Data").Y;
|
||||
UiSharedService.TextWrapped("Mare Census Participation");
|
||||
}
|
||||
ImGuiHelpers.ScaledDummy(5f);
|
||||
UiSharedService.TextWrapped("If you are seeing this popup you are updating from a Mare version that did not collect census data. Please read the following carefully.");
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped("Mare Census is a data collecting service that can be used for statistical purposes. " +
|
||||
"All data collected through Mare Census is temporary and will be stored associated with your UID on the connected service as long as you are connected. " +
|
||||
"The data cannot be used for long term tracking of individuals.");
|
||||
UiSharedService.TextWrapped("If enabled, Mare Census will collect following data:" + Environment.NewLine
|
||||
+ "- Currently connected World" + Environment.NewLine
|
||||
+ "- Current Gender (reflecting Glamourer changes)" + Environment.NewLine
|
||||
+ "- Current Race (reflecting Glamourer changes)" + Environment.NewLine
|
||||
+ "- Current Clan (i.e. Seeker of the Sun, Keeper of the Moon, etc., reflecting Glamourer changes)");
|
||||
UiSharedService.TextWrapped("To consent to collecting census data press the appropriate button below.");
|
||||
UiSharedService.TextWrapped("This setting can be changed anytime in the Mare Settings.");
|
||||
var width = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
|
||||
var buttonSize = ImGuiHelpers.GetButtonSize("I consent to send my census data");
|
||||
ImGuiHelpers.ScaledDummy(5f);
|
||||
if (ImGui.Button("I consent to send my census data", new Vector2(width, buttonSize.Y * 2.5f)))
|
||||
{
|
||||
_serverConfigurationManager.SendCensusData = true;
|
||||
_serverConfigurationManager.ShownCensusPopup = true;
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
ImGuiHelpers.ScaledDummy(1f);
|
||||
if (ImGui.Button("I do not consent to send my census data", new Vector2(width, buttonSize.Y)))
|
||||
{
|
||||
_serverConfigurationManager.SendCensusData = false;
|
||||
_serverConfigurationManager.ShownCensusPopup = true;
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
var height = ImGui.GetCursorPosY() - start;
|
||||
_size = _size with { Y = height };
|
||||
}
|
||||
}
|
||||
11
LightlessSync/UI/Components/Popup/IPopupHandler.cs
Normal file
11
LightlessSync/UI/Components/Popup/IPopupHandler.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI.Components.Popup;
|
||||
|
||||
public interface IPopupHandler
|
||||
{
|
||||
Vector2 PopupSize { get; }
|
||||
bool ShowClose { get; }
|
||||
|
||||
void DrawContent();
|
||||
}
|
||||
80
LightlessSync/UI/Components/Popup/PopupHandler.cs
Normal file
80
LightlessSync/UI/Components/Popup/PopupHandler.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
|
||||
namespace LightlessSync.UI.Components.Popup;
|
||||
|
||||
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, UiSharedService uiSharedService)
|
||||
: base(logger, mediator, "MarePopupHandler", performanceCollectorService)
|
||||
{
|
||||
Flags = ImGuiWindowFlags.NoBringToFrontOnFocus
|
||||
| ImGuiWindowFlags.NoDecoration
|
||||
| ImGuiWindowFlags.NoInputs
|
||||
| ImGuiWindowFlags.NoSavedSettings
|
||||
| ImGuiWindowFlags.NoBackground
|
||||
| ImGuiWindowFlags.NoMove
|
||||
| ImGuiWindowFlags.NoNav
|
||||
| ImGuiWindowFlags.NoTitleBar
|
||||
| ImGuiWindowFlags.NoFocusOnAppearing;
|
||||
|
||||
IsOpen = true;
|
||||
|
||||
_handlers = popupHandlers.ToHashSet();
|
||||
|
||||
Mediator.Subscribe<OpenBanUserPopupMessage>(this, (msg) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<BanUserPopupHandler>().Single();
|
||||
((BanUserPopupHandler)_currentHandler).Open(msg);
|
||||
IsOpen = true;
|
||||
});
|
||||
|
||||
Mediator.Subscribe<OpenCensusPopupMessage>(this, (msg) =>
|
||||
{
|
||||
_openPopup = true;
|
||||
_currentHandler = _handlers.OfType<CensusPopupHandler>().Single();
|
||||
IsOpen = true;
|
||||
});
|
||||
_uiSharedService = uiSharedService;
|
||||
DisableWindowSounds = true;
|
||||
}
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
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.IconTextButton(FontAwesomeIcon.Times, "Close"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user