Files
tbd-station-14/Content.Client/Administration/UI/PlayerPanel/PlayerPanelEui.cs
nikthechampiongr d1a60fafe7 Implement a playerpanel (#30238)
* Basic structure for the player panel ui

* Ensure basic functionality

Player panel now receives and displays basic info

* Make whitelistcommands accept user ids

* Make PlayerPanel use GUIDs where possible

* Add functionality to most playerpanel buttons

* Implement remaining playerpanel features

* Localize everything

* Finish up

* Put command arguments in quotes

I am not sure if it's even possible to have something like a space in
them considering they are guids and usernames but sure why not

* Make playerpanel a verb

* Add Logs button to player panel

* Change Notesbutton text and make whitelistbutton a confirmtion button

* Add freeze button that does not mute the player

* Add sharedconnections counter to playerpanel

* Make the playetime format clearer

* Allow for copying of the a player's username

* Do minor cleanup

* Rearrange buttons

* Fix unfreeze button not updating

* Fix wrong localisation text

* "Fix" the same role ban counting multiple times

The way rolebans are stored is horrible.
As such if you ban someone from a departmenrt or something
role bans are individually placed for every role.
The only way I found to distinguish them is the bantime.
This is horrible but I do not want to rewrite how all the bans are
stored right now.

* Add Delete and Rejuvenate buttons to player panel

By popular demand

* Marginally improve ui

* Add logs

* review update

* Fix verb

* Fix double notes

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-08-09 15:33:25 +10:00

73 lines
2.7 KiB
C#

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();
}
}