Add ban list window (#12574)
This commit is contained in:
70
Content.Client/Administration/UI/BanList/BanListLine.xaml.cs
Normal file
70
Content.Client/Administration/UI/BanList/BanListLine.xaml.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Content.Shared.Administration.BanList;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Input;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BanListLine : BoxContainer
|
||||
{
|
||||
public readonly SharedServerBan Ban;
|
||||
|
||||
public event Func<BanListLine, bool>? OnIdsClicked;
|
||||
|
||||
public BanListLine(SharedServerBan ban)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
Ban = ban;
|
||||
|
||||
IdsHidden.OnKeyBindDown += IdsKeyBindDown;
|
||||
|
||||
Reason.Text = ban.Reason;
|
||||
BanTime.Text = FormatDate(ban.BanTime);
|
||||
Expires.Text = ban.ExpirationTime == null
|
||||
? Loc.GetString("ban-list-permanent")
|
||||
: FormatDate(ban.ExpirationTime.Value);
|
||||
|
||||
if (ban.Unban is { } unban)
|
||||
{
|
||||
var unbanned = Loc.GetString("ban-list-unbanned", ("date", FormatDate(unban.UnbanTime)));
|
||||
var unbannedBy = unban.UnbanningAdmin == null
|
||||
? string.Empty
|
||||
: $"\n{Loc.GetString("ban-list-unbanned-by", ("unbanner", unban.UnbanningAdmin))}";
|
||||
|
||||
Expires.Text += $"\n{unbanned}{unbannedBy}";
|
||||
}
|
||||
|
||||
BanningAdmin.Text = ban.BanningAdminName;
|
||||
}
|
||||
|
||||
private static string FormatDate(DateTimeOffset date)
|
||||
{
|
||||
return date.ToString("MM/dd/yyyy h:mm tt");
|
||||
}
|
||||
|
||||
private void IdsKeyBindDown(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
if (args.Function != EngineKeyFunctions.UIRightClick &&
|
||||
args.Function != EngineKeyFunctions.UIClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (OnIdsClicked?.Invoke(this) == true)
|
||||
{
|
||||
args.Handle();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
IdsHidden.OnKeyBindDown -= IdsKeyBindDown;
|
||||
OnIdsClicked = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user