Add ban id to ban list, make ids label a button (#12700)

This commit is contained in:
DrSmugleaf
2022-11-21 20:04:24 +01:00
committed by GitHub
parent a5c2d7c7a9
commit 5c80153665
6 changed files with 20 additions and 25 deletions

View File

@@ -46,13 +46,16 @@ public sealed partial class BanListControl : Control
ClosePopup(); ClosePopup();
var ban = line.Ban; var ban = line.Ban;
var id = ban.Id == null ? string.Empty : Loc.GetString("ban-list-id", ("id", ban.Id.Value));
var ip = ban.Address == null var ip = ban.Address == null
? string.Empty ? string.Empty
: Loc.GetString("ban-list-ip", ("ip", ban.Address.Value.address)); : 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 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())); var guid = ban.UserId == null
? string.Empty
: Loc.GetString("ban-list-guid", ("guid", ban.UserId.Value.ToString()));
_popup = new BanListIdsPopup(ip, hwid, guid); _popup = new BanListIdsPopup(id, ip, hwid, guid);
var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1)); var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1));
_popup.Open(box); _popup.Open(box);

View File

@@ -5,6 +5,7 @@
<graphics:StyleBoxFlat BackgroundColor="#25252A"/> <graphics:StyleBoxFlat BackgroundColor="#25252A"/>
</PanelContainer.PanelOverride> </PanelContainer.PanelOverride>
<BoxContainer Orientation="Vertical"> <BoxContainer Orientation="Vertical">
<Label Name="ID" HorizontalExpand="True"/>
<Label Name="IP" HorizontalExpand="True"/> <Label Name="IP" HorizontalExpand="True"/>
<Label Name="HWId" HorizontalExpand="True"/> <Label Name="HWId" HorizontalExpand="True"/>
<Label Name="GUID" HorizontalExpand="True"/> <Label Name="GUID" HorizontalExpand="True"/>

View File

@@ -7,10 +7,11 @@ namespace Content.Client.Administration.UI.BanList;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class BanListIdsPopup : Popup public sealed partial class BanListIdsPopup : Popup
{ {
public BanListIdsPopup(string? ip, string? hwid, string? guid) public BanListIdsPopup(string? id, string? ip, string? hwid, string? guid)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
ID.Text = id;
IP.Text = ip; IP.Text = ip;
HWId.Text = hwid; HWId.Text = hwid;
GUID.Text = guid; GUID.Text = guid;

View File

@@ -8,8 +8,8 @@
SizeFlagsStretchRatio="1" SizeFlagsStretchRatio="1"
HorizontalExpand="True" HorizontalExpand="True"
RectClipContent="True"> RectClipContent="True">
<Label Name="IdsHidden" <Button Name="IdsHidden"
Text="{Loc 'ban-list-hidden'}" Text="{Loc 'ban-list-view'}"
HorizontalExpand="True" HorizontalExpand="True"
VerticalExpand="True" VerticalExpand="True"
MouseFilter="Pass"/> MouseFilter="Pass"/>

View File

@@ -1,9 +1,7 @@
using Content.Shared.Administration.BanList; using Content.Shared.Administration.BanList;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
namespace Content.Client.Administration.UI.BanList; namespace Content.Client.Administration.UI.BanList;
@@ -20,7 +18,7 @@ public sealed partial class BanListLine : BoxContainer
Ban = ban; Ban = ban;
IdsHidden.OnKeyBindDown += IdsKeyBindDown; IdsHidden.OnPressed += IdsPressed;
Reason.Text = ban.Reason; Reason.Text = ban.Reason;
BanTime.Text = FormatDate(ban.BanTime); BanTime.Text = FormatDate(ban.BanTime);
@@ -46,25 +44,16 @@ public sealed partial class BanListLine : BoxContainer
return date.ToString("MM/dd/yyyy h:mm tt"); return date.ToString("MM/dd/yyyy h:mm tt");
} }
private void IdsKeyBindDown(GUIBoundKeyEventArgs args) private void IdsPressed(BaseButton.ButtonEventArgs buttonEventArgs)
{ {
if (args.Function != EngineKeyFunctions.UIRightClick && OnIdsClicked?.Invoke(this);
args.Function != EngineKeyFunctions.UIClick)
{
return;
}
if (OnIdsClicked?.Invoke(this) == true)
{
args.Handle();
}
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
IdsHidden.OnKeyBindDown -= IdsKeyBindDown; IdsHidden.OnPressed -= IdsPressed;
OnIdsClicked = null; OnIdsClicked = null;
} }
} }

View File

@@ -6,7 +6,8 @@ ban-list-header-expires = Expires
ban-list-header-banning-admin = Banning admin ban-list-header-banning-admin = Banning admin
ban-list-title = Bans for {$player} ban-list-title = Bans for {$player}
ban-list-hidden = Hidden ban-list-view = View
ban-list-id = ID: {$id}
ban-list-ip = IP: {$ip} ban-list-ip = IP: {$ip}
ban-list-hwid = HWID: {$hwid} ban-list-hwid = HWID: {$hwid}
ban-list-guid = GUID: {$guid} ban-list-guid = GUID: {$guid}