-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1,385 changed files
with
48,062 additions
and
45,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<ui:FancyWindow | ||
xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="{Loc ban-panel-title}" MinSize="300 300"> | ||
<BoxContainer Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="PlayerName"/> | ||
<Button Name="UsernameCopyButton" Text="{Loc player-panel-copy-username}"/> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="Whitelisted"/> | ||
<controls:ConfirmButton Name="WhitelistToggle" Text="{Loc 'player-panel-false'}" Visible="False"></controls:ConfirmButton> | ||
</BoxContainer> | ||
<Label Name="Playtime"/> | ||
<Label Name="Notes"/> | ||
<Label Name="Bans"/> | ||
<Label Name="RoleBans"/> | ||
<Label Name="SharedConnections"/> | ||
|
||
<BoxContainer Align="Center"> | ||
<GridContainer Rows="5"> | ||
<Button Name="NotesButton" Text="{Loc player-panel-show-notes}" SetWidth="136" Disabled="True"/> | ||
<Button Name="AhelpButton" Text="{Loc player-panel-help}" Disabled="True"/> | ||
<Button Name="FreezeButton" Text = "{Loc player-panel-freeze}" Disabled="True"/> | ||
<controls:ConfirmButton Name="KickButton" Text="{Loc player-panel-kick}" Disabled="True"/> | ||
<controls:ConfirmButton Name="DeleteButton" Text="{Loc player-panel-delete}" Disabled="True"/> | ||
<Button Name="ShowBansButton" Text="{Loc player-panel-show-bans}" SetWidth="136" Disabled="True"/> | ||
<Button Name="LogsButton" Text="{Loc player-panel-logs}" Disabled="True"/> | ||
<Button Name="FreezeAndMuteToggleButton" Text="{Loc player-panel-freeze-and-mute}" Disabled="True"/> | ||
<Button Name="BanButton" Text="{Loc player-panel-ban}" Disabled="True"/> | ||
<controls:ConfirmButton Name="RejuvenateButton" Text="{Loc player-panel-rejuvenate}" Disabled="True"/> | ||
</GridContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</ui:FancyWindow> |
132 changes: 132 additions & 0 deletions
132
Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using Content.Client.Administration.Managers; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Administration; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Network; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Administration.UI.PlayerPanel; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class PlayerPanel : FancyWindow | ||
{ | ||
private readonly IClientAdminManager _adminManager; | ||
|
||
public event Action<string>? OnUsernameCopy; | ||
public event Action<NetUserId?>? OnOpenNotes; | ||
public event Action<NetUserId?>? OnOpenBans; | ||
public event Action<NetUserId?>? OnAhelp; | ||
public event Action<string?>? OnKick; | ||
public event Action<NetUserId?>? OnOpenBanPanel; | ||
public event Action<NetUserId?, bool>? OnWhitelistToggle; | ||
public event Action? OnFreezeAndMuteToggle; | ||
public event Action? OnFreeze; | ||
public event Action? OnLogs; | ||
public event Action? OnDelete; | ||
public event Action? OnRejuvenate; | ||
|
||
public NetUserId? TargetPlayer; | ||
public string? TargetUsername; | ||
private bool _isWhitelisted; | ||
|
||
public PlayerPanel(IClientAdminManager adminManager) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
_adminManager = adminManager; | ||
|
||
UsernameCopyButton.OnPressed += _ => OnUsernameCopy?.Invoke(PlayerName.Text ?? ""); | ||
BanButton.OnPressed += _ => OnOpenBanPanel?.Invoke(TargetPlayer); | ||
KickButton.OnPressed += _ => OnKick?.Invoke(TargetUsername); | ||
NotesButton.OnPressed += _ => OnOpenNotes?.Invoke(TargetPlayer); | ||
ShowBansButton.OnPressed += _ => OnOpenBans?.Invoke(TargetPlayer); | ||
AhelpButton.OnPressed += _ => OnAhelp?.Invoke(TargetPlayer); | ||
WhitelistToggle.OnPressed += _ => | ||
{ | ||
OnWhitelistToggle?.Invoke(TargetPlayer, _isWhitelisted); | ||
SetWhitelisted(!_isWhitelisted); | ||
}; | ||
FreezeButton.OnPressed += _ => OnFreeze?.Invoke(); | ||
FreezeAndMuteToggleButton.OnPressed += _ => OnFreezeAndMuteToggle?.Invoke(); | ||
LogsButton.OnPressed += _ => OnLogs?.Invoke(); | ||
DeleteButton.OnPressed += _ => OnDelete?.Invoke(); | ||
RejuvenateButton.OnPressed += _ => OnRejuvenate?.Invoke(); | ||
} | ||
|
||
public void SetUsername(string player) | ||
{ | ||
Title = Loc.GetString("player-panel-title", ("player", player)); | ||
PlayerName.Text = Loc.GetString("player-panel-username", ("player", player)); | ||
} | ||
|
||
public void SetWhitelisted(bool? whitelisted) | ||
{ | ||
if (whitelisted == null) | ||
{ | ||
Whitelisted.Text = null; | ||
WhitelistToggle.Visible = false; | ||
} | ||
else | ||
{ | ||
Whitelisted.Text = Loc.GetString("player-panel-whitelisted"); | ||
WhitelistToggle.Text = whitelisted.Value.ToString(); | ||
WhitelistToggle.Visible = true; | ||
_isWhitelisted = whitelisted.Value; | ||
} | ||
} | ||
|
||
public void SetBans(int? totalBans, int? totalRoleBans) | ||
{ | ||
// If one value exists then so should the other. | ||
DebugTools.Assert(totalBans.HasValue && totalRoleBans.HasValue || totalBans == null && totalRoleBans == null); | ||
|
||
Bans.Text = totalBans != null ? Loc.GetString("player-panel-bans", ("totalBans", totalBans)) : null; | ||
|
||
RoleBans.Text = totalRoleBans != null ? Loc.GetString("player-panel-rolebans", ("totalRoleBans", totalRoleBans)) : null; | ||
} | ||
|
||
public void SetNotes(int? totalNotes) | ||
{ | ||
Notes.Text = totalNotes != null ? Loc.GetString("player-panel-notes", ("totalNotes", totalNotes)) : null; | ||
} | ||
|
||
public void SetSharedConnections(int sharedConnections) | ||
{ | ||
SharedConnections.Text = Loc.GetString("player-panel-shared-connections", ("sharedConnections", sharedConnections)); | ||
} | ||
|
||
public void SetPlaytime(TimeSpan playtime) | ||
{ | ||
Playtime.Text = Loc.GetString("player-panel-playtime", | ||
("days", playtime.Days), | ||
("hours", playtime.Hours % 24), | ||
("minutes", playtime.Minutes % (24 * 60))); | ||
} | ||
|
||
public void SetFrozen(bool canFreeze, bool frozen) | ||
{ | ||
FreezeAndMuteToggleButton.Disabled = !canFreeze; | ||
FreezeButton.Disabled = !canFreeze || frozen; | ||
|
||
FreezeAndMuteToggleButton.Text = Loc.GetString(!frozen ? "player-panel-freeze-and-mute" : "player-panel-unfreeze"); | ||
} | ||
|
||
public void SetAhelp(bool canAhelp) | ||
{ | ||
AhelpButton.Disabled = !canAhelp; | ||
} | ||
|
||
public void SetButtons() | ||
{ | ||
BanButton.Disabled = !_adminManager.CanCommand("banpanel"); | ||
KickButton.Disabled = !_adminManager.CanCommand("kick"); | ||
NotesButton.Disabled = !_adminManager.CanCommand("adminnotes"); | ||
ShowBansButton.Disabled = !_adminManager.CanCommand("banlist"); | ||
WhitelistToggle.Disabled = | ||
!(_adminManager.CanCommand("addwhitelist") && _adminManager.CanCommand("removewhitelist")); | ||
LogsButton.Disabled = !_adminManager.CanCommand("adminlogs"); | ||
RejuvenateButton.Disabled = !_adminManager.HasFlag(AdminFlags.Debug); | ||
DeleteButton.Disabled = !_adminManager.HasFlag(AdminFlags.Debug); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
Content.Client/Administration/UI/PlayerPanel/PlayerPanelEui.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Content.Client.Administration.Managers; | ||
using Content.Client.Eui; | ||
using Content.Shared.Administration; | ||
using Content.Shared.Eui; | ||
using JetBrains.Annotations; | ||
using Robust.Client.Console; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.Administration.UI.PlayerPanel; | ||
|
||
[UsedImplicitly] | ||
public sealed class PlayerPanelEui : BaseEui | ||
{ | ||
[Dependency] private readonly IClientConsoleHost _console = default!; | ||
[Dependency] private readonly IClientAdminManager _admin = default!; | ||
[Dependency] private readonly IClipboardManager _clipboard = default!; | ||
|
||
private PlayerPanel PlayerPanel { get; } | ||
|
||
public PlayerPanelEui() | ||
{ | ||
PlayerPanel = new PlayerPanel(_admin); | ||
|
||
PlayerPanel.OnUsernameCopy += username => _clipboard.SetText(username); | ||
PlayerPanel.OnOpenNotes += id => _console.ExecuteCommand($"adminnotes \"{id}\""); | ||
// Kick command does not support GUIDs | ||
PlayerPanel.OnKick += username => _console.ExecuteCommand($"kick \"{username}\""); | ||
PlayerPanel.OnOpenBanPanel += id => _console.ExecuteCommand($"banpanel \"{id}\""); | ||
PlayerPanel.OnOpenBans += id => _console.ExecuteCommand($"banlist \"{id}\""); | ||
PlayerPanel.OnAhelp += id => _console.ExecuteCommand($"openahelp \"{id}\""); | ||
PlayerPanel.OnWhitelistToggle += (id, whitelisted) => | ||
{ | ||
_console.ExecuteCommand(whitelisted ? $"whitelistremove \"{id}\"" : $"whitelistadd \"{id}\""); | ||
}; | ||
|
||
PlayerPanel.OnFreezeAndMuteToggle += () => SendMessage(new PlayerPanelFreezeMessage(true)); | ||
PlayerPanel.OnFreeze += () => SendMessage(new PlayerPanelFreezeMessage()); | ||
PlayerPanel.OnLogs += () => SendMessage(new PlayerPanelLogsMessage()); | ||
PlayerPanel.OnRejuvenate += () => SendMessage(new PlayerPanelRejuvenationMessage()); | ||
PlayerPanel.OnDelete+= () => SendMessage(new PlayerPanelDeleteMessage()); | ||
|
||
PlayerPanel.OnClose += () => SendMessage(new CloseEuiMessage()); | ||
} | ||
|
||
public override void Opened() | ||
{ | ||
PlayerPanel.OpenCentered(); | ||
} | ||
|
||
public override void Closed() | ||
{ | ||
PlayerPanel.Close(); | ||
} | ||
|
||
public override void HandleState(EuiStateBase state) | ||
{ | ||
if (state is not PlayerPanelEuiState s) | ||
return; | ||
|
||
PlayerPanel.TargetPlayer = s.Guid; | ||
PlayerPanel.TargetUsername = s.Username; | ||
PlayerPanel.SetUsername(s.Username); | ||
PlayerPanel.SetPlaytime(s.Playtime); | ||
PlayerPanel.SetBans(s.TotalBans, s.TotalRoleBans); | ||
PlayerPanel.SetNotes(s.TotalNotes); | ||
PlayerPanel.SetWhitelisted(s.Whitelisted); | ||
PlayerPanel.SetSharedConnections(s.SharedConnections); | ||
PlayerPanel.SetFrozen(s.CanFreeze, s.Frozen); | ||
PlayerPanel.SetAhelp(s.CanAhelp); | ||
PlayerPanel.SetButtons(); | ||
} | ||
} |
Oops, something went wrong.