Add ban list window (#12574)
This commit is contained in:
15
Content.Client/Administration/UI/BanList/BanListControl.xaml
Normal file
15
Content.Client/Administration/UI/BanList/BanListControl.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<controls:BanListControl
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.Administration.UI.BanList"
|
||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||
<PanelContainer>
|
||||
<PanelContainer.PanelOverride>
|
||||
<graphics:StyleBoxFlat BackgroundColor="#25252A"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<ScrollContainer>
|
||||
<BoxContainer Name="Bans" Access="Public" Orientation="Vertical">
|
||||
<controls:BanListHeader Name="BansHeader"/>
|
||||
</BoxContainer>
|
||||
</ScrollContainer>
|
||||
</PanelContainer>
|
||||
</controls:BanListControl>
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Shared.Administration.BanList;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BanListControl : Control
|
||||
{
|
||||
private BanListIdsPopup? _popup;
|
||||
|
||||
public BanListControl()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SetBans(List<SharedServerBan> bans)
|
||||
{
|
||||
foreach (var control in Bans.Children.ToArray()[1..])
|
||||
{
|
||||
control.Orphan();
|
||||
}
|
||||
|
||||
foreach (var ban in bans)
|
||||
{
|
||||
Bans.AddChild(new HSeparator());
|
||||
|
||||
var line = new BanListLine(ban);
|
||||
line.OnIdsClicked += LineIdsClicked;
|
||||
|
||||
Bans.AddChild(line);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePopup()
|
||||
{
|
||||
_popup?.Close();
|
||||
_popup = null;
|
||||
}
|
||||
|
||||
private bool LineIdsClicked(BanListLine line)
|
||||
{
|
||||
ClosePopup();
|
||||
|
||||
var ban = line.Ban;
|
||||
var ip = ban.Address == null
|
||||
? string.Empty
|
||||
: Loc.GetString("ban-list-ip", ("ip", ban.Address.Value.address));
|
||||
var hwid = ban.HWId == null ? string.Empty : Loc.GetString("ban-list-hwid", ("hwid", ban.HWId));
|
||||
var guid = ban.UserId == null ? string.Empty : Loc.GetString("ban-list-guid", ("guid", ban.UserId.Value.ToString()));
|
||||
|
||||
_popup = new BanListIdsPopup(ip, hwid, guid);
|
||||
|
||||
var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1));
|
||||
_popup.Open(box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (_popup != null)
|
||||
{
|
||||
UserInterfaceManager.PopupRoot.RemoveChild(_popup);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Content.Client/Administration/UI/BanList/BanListEui.cs
Normal file
34
Content.Client/Administration/UI/BanList/BanListEui.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Administration.BanList;
|
||||
using Content.Shared.Eui;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
public sealed class BanListEui : BaseEui
|
||||
{
|
||||
public BanListEui()
|
||||
{
|
||||
BanWindow = new BanListWindow();
|
||||
BanControl = BanWindow.BanList;
|
||||
}
|
||||
|
||||
private BanListWindow BanWindow { get; }
|
||||
|
||||
private BanListControl BanControl { get; }
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
if (state is not BanListEuiState s)
|
||||
return;
|
||||
|
||||
BanWindow.SetTitlePlayer(s.BanListPlayerName);
|
||||
|
||||
s.Bans.Sort((a, b) => a.BanTime.CompareTo(b.BanTime));
|
||||
BanControl.SetBans(s.Bans);
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
BanWindow.OpenCentered();
|
||||
}
|
||||
}
|
||||
31
Content.Client/Administration/UI/BanList/BanListHeader.xaml
Normal file
31
Content.Client/Administration/UI/BanList/BanListHeader.xaml
Normal file
@@ -0,0 +1,31 @@
|
||||
<ContainerButton
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
|
||||
<PanelContainer Name="BackgroundPanel" Access="Public">
|
||||
<BoxContainer
|
||||
Orientation="Horizontal"
|
||||
HorizontalExpand="True"
|
||||
SeparationOverride="4">
|
||||
<Label Text="{Loc ban-list-header-ids}"
|
||||
SizeFlagsStretchRatio="1"
|
||||
HorizontalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Text="{Loc ban-list-header-reason}"
|
||||
SizeFlagsStretchRatio="6"
|
||||
HorizontalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Text="{Loc ban-list-header-time}"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Text="{Loc ban-list-header-expires}"
|
||||
SizeFlagsStretchRatio="4"
|
||||
HorizontalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Text="{Loc ban-list-header-banning-admin}"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</ContainerButton>
|
||||
@@ -0,0 +1,14 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BanListHeader : ContainerButton
|
||||
{
|
||||
public BanListHeader()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<Popup xmlns="https://spacestation14.io"
|
||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||
<PanelContainer>
|
||||
<PanelContainer.PanelOverride>
|
||||
<graphics:StyleBoxFlat BackgroundColor="#25252A"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<Label Name="IP" HorizontalExpand="True"/>
|
||||
<Label Name="HWId" HorizontalExpand="True"/>
|
||||
<Label Name="GUID" HorizontalExpand="True"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</Popup>
|
||||
@@ -0,0 +1,20 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BanListIdsPopup : Popup
|
||||
{
|
||||
public BanListIdsPopup(string? ip, string? hwid, string? guid)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
IP.Text = ip;
|
||||
HWId.Text = hwid;
|
||||
GUID.Text = guid;
|
||||
|
||||
UserInterfaceManager.ModalRoot.AddChild(this);
|
||||
}
|
||||
}
|
||||
38
Content.Client/Administration/UI/BanList/BanListLine.xaml
Normal file
38
Content.Client/Administration/UI/BanList/BanListLine.xaml
Normal file
@@ -0,0 +1,38 @@
|
||||
<BoxContainer
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Orientation="Horizontal"
|
||||
HorizontalExpand="True"
|
||||
SeparationOverride="4">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
SizeFlagsStretchRatio="1"
|
||||
HorizontalExpand="True"
|
||||
RectClipContent="True">
|
||||
<Label Name="IdsHidden"
|
||||
Text="{Loc 'ban-list-hidden'}"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
MouseFilter="Pass"/>
|
||||
</BoxContainer>
|
||||
<cc:VSeparator/>
|
||||
<Label Name="Reason"
|
||||
SizeFlagsStretchRatio="6"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Name="BanTime"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Name="Expires"
|
||||
SizeFlagsStretchRatio="4"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"/>
|
||||
<cc:VSeparator/>
|
||||
<Label Name="BanningAdmin"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"/>
|
||||
<cc:VSeparator/>
|
||||
</BoxContainer>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<controls:BanListWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.Administration.UI.BanList"
|
||||
SetSize="1400 400">
|
||||
<controls:BanListControl Name="BanList" Access="Public"/>
|
||||
</controls:BanListWindow>
|
||||
@@ -0,0 +1,19 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Administration.UI.BanList;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BanListWindow : DefaultWindow
|
||||
{
|
||||
public BanListWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SetTitlePlayer(string playerName)
|
||||
{
|
||||
Title = Loc.GetString("ban-list-title", ("player", playerName));
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
|
||||
<BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
|
||||
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" />
|
||||
<Button Visible="False" Name="Notes" Text="{Loc 'admin-player-actions-notes'}" />
|
||||
<Button Visible="False" Name="Kick" Text="{Loc 'admin-player-actions-kick'}" />
|
||||
<Button Visible="False" Name="Ban" Text="{Loc 'admin-player-actions-ban'}" />
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#nullable enable
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Content.Client.Administration.Managers;
|
||||
using Content.Client.Administration.Systems;
|
||||
using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Client.Administration.UI.Tabs.AdminTab;
|
||||
using Content.Client.Stylesheets;
|
||||
@@ -62,7 +60,7 @@ namespace Content.Client.Administration.UI
|
||||
sb.Append('●');
|
||||
else
|
||||
sb.Append(info.ActiveThisRound ? '○' : '·');
|
||||
|
||||
|
||||
sb.Append(' ');
|
||||
if (_adminAHelpHelper.TryGetChannel(info.SessionId, out var panel) && panel.Unread > 0)
|
||||
{
|
||||
@@ -106,6 +104,12 @@ namespace Content.Client.Administration.UI
|
||||
return bch!.LastMessage.CompareTo(ach!.LastMessage);
|
||||
};
|
||||
|
||||
Bans.OnPressed += _ =>
|
||||
{
|
||||
if (_currentPlayer is not null)
|
||||
_console.ExecuteCommand($"banlist \"{_currentPlayer.SessionId}\"");
|
||||
};
|
||||
|
||||
Notes.OnPressed += _ =>
|
||||
{
|
||||
if (_currentPlayer is not null)
|
||||
@@ -170,6 +174,9 @@ namespace Content.Client.Administration.UI
|
||||
|
||||
private void FixButtons()
|
||||
{
|
||||
Bans.Visible = _adminManager.HasFlag(AdminFlags.Ban);
|
||||
Bans.Disabled = !Bans.Visible;
|
||||
|
||||
Notes.Visible = _adminManager.HasFlag(AdminFlags.ViewNotes);
|
||||
Notes.Disabled = !Notes.Visible;
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Content.Client.Administration.UI.Notes;
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class AdminNotesControl : Control
|
||||
{
|
||||
[Dependency] private readonly IUserInterfaceManager _ui = default!;
|
||||
|
||||
public event Action<int, string>? OnNoteChanged;
|
||||
public event Action<string>? OnNewNoteEntered;
|
||||
public event Action<int>? OnNoteDeleted;
|
||||
@@ -53,7 +51,7 @@ public sealed partial class AdminNotesControl : Control
|
||||
OnNoteChanged?.Invoke(input.Id, text);
|
||||
}
|
||||
|
||||
private bool NoteRightClicked(AdminNotesLine line)
|
||||
private bool NoteClicked(AdminNotesLine line)
|
||||
{
|
||||
ClosePopup();
|
||||
|
||||
@@ -69,7 +67,7 @@ public sealed partial class AdminNotesControl : Control
|
||||
};
|
||||
_popup.OnDeletePressed += noteId => OnNoteDeleted?.Invoke(noteId);
|
||||
|
||||
var box = UIBox2.FromDimensions(_ui.MousePositionScaled.Position, (1, 1));
|
||||
var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1));
|
||||
_popup.Open(box);
|
||||
|
||||
return true;
|
||||
@@ -102,7 +100,7 @@ public sealed partial class AdminNotesControl : Control
|
||||
|
||||
input = new AdminNotesLine(note);
|
||||
input.OnSubmitted += NoteSubmitted;
|
||||
input.OnRightClicked += NoteRightClicked;
|
||||
input.OnClicked += NoteClicked;
|
||||
Notes.AddChild(input);
|
||||
Inputs[note.Id] = input;
|
||||
}
|
||||
@@ -136,7 +134,7 @@ public sealed partial class AdminNotesControl : Control
|
||||
|
||||
if (_popup != null)
|
||||
{
|
||||
_ui.PopupRoot.RemoveChild(_popup);
|
||||
UserInterfaceManager.PopupRoot.RemoveChild(_popup);
|
||||
}
|
||||
|
||||
OnNoteChanged = null;
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed partial class AdminNotesLine : BoxContainer
|
||||
public string EditText => _edit?.Text ?? OriginalMessage;
|
||||
|
||||
public event Action<AdminNotesLine>? OnSubmitted;
|
||||
public event Func<AdminNotesLine, bool>? OnRightClicked;
|
||||
public event Func<AdminNotesLine, bool>? OnClicked;
|
||||
|
||||
private void AddLabel()
|
||||
{
|
||||
@@ -92,7 +92,7 @@ public sealed partial class AdminNotesLine : BoxContainer
|
||||
return;
|
||||
}
|
||||
|
||||
if (OnRightClicked?.Invoke(this) == true)
|
||||
if (OnClicked?.Invoke(this) == true)
|
||||
{
|
||||
args.Handle();
|
||||
}
|
||||
@@ -137,6 +137,6 @@ public sealed partial class AdminNotesLine : BoxContainer
|
||||
}
|
||||
|
||||
OnSubmitted = null;
|
||||
OnRightClicked = null;
|
||||
OnClicked = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<Popup xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||
<PanelContainer>
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#25252A"/>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<cc:CommandButton Command="announceui" Text="{Loc admin-player-actions-window-announce}"/>
|
||||
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
|
||||
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
|
||||
<cc:CommandButton Command="adminnotes" Text="{Loc admin-player-actions-window-admin-notes}"/>
|
||||
</GridContainer>
|
||||
</BoxContainer>
|
||||
</Control>
|
||||
|
||||
Reference in New Issue
Block a user