* Stop network serializing prototypes Send the damn proto ID instead. * Fix sandbox violation
105 lines
3.9 KiB
C#
105 lines
3.9 KiB
C#
using Content.Shared.Administration;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Roles;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Administration.UI.Tabs.PlayerTab;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class PlayerTabEntry : PanelContainer
|
|
{
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
|
|
public PlayerTabEntry(
|
|
PlayerInfo player,
|
|
StyleBoxFlat styleBoxFlat,
|
|
AdminPlayerTabColorOption colorOption,
|
|
AdminPlayerTabRoleTypeOption roleSetting,
|
|
AdminPlayerTabSymbolOption symbolSetting)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
RobustXamlLoader.Load(this);
|
|
var roles = _entMan.System<SharedRoleSystem>();
|
|
|
|
var rolePrototype = player.RoleProto == null ? null : _prototype.Index(player.RoleProto.Value);
|
|
|
|
UsernameLabel.Text = player.Username;
|
|
if (!player.Connected)
|
|
UsernameLabel.StyleClasses.Add("Disabled");
|
|
JobLabel.Text = player.StartingJob;
|
|
|
|
var colorAntags = false;
|
|
var colorRoles = false;
|
|
switch (colorOption)
|
|
{
|
|
case AdminPlayerTabColorOption.Off:
|
|
break;
|
|
case AdminPlayerTabColorOption.Character:
|
|
colorAntags = true;
|
|
break;
|
|
case AdminPlayerTabColorOption.Roletype:
|
|
colorRoles = true;
|
|
break;
|
|
default:
|
|
case AdminPlayerTabColorOption.Both:
|
|
colorAntags = true;
|
|
colorRoles = true;
|
|
break;
|
|
}
|
|
|
|
var symbol = string.Empty;
|
|
switch (symbolSetting)
|
|
{
|
|
case AdminPlayerTabSymbolOption.Off:
|
|
break;
|
|
case AdminPlayerTabSymbolOption.Basic:
|
|
symbol = player.Antag ? Loc.GetString("player-tab-antag-prefix") : string.Empty;
|
|
break;
|
|
default:
|
|
case AdminPlayerTabSymbolOption.Specific:
|
|
symbol = player.Antag ? rolePrototype?.Symbol ?? RoleTypePrototype.FallbackSymbol : string.Empty;
|
|
break;
|
|
}
|
|
|
|
CharacterLabel.Text = Loc.GetString("player-tab-character-name-antag-symbol", ("symbol", symbol), ("name", player.CharacterName));
|
|
|
|
if (player.Antag && colorAntags)
|
|
CharacterLabel.FontColorOverride = rolePrototype?.Color ?? RoleTypePrototype.FallbackColor;
|
|
if (player.IdentityName != player.CharacterName)
|
|
CharacterLabel.Text += $" [{player.IdentityName}]";
|
|
|
|
var roletype = RoleTypeLabel.Text = Loc.GetString(rolePrototype?.Name ?? RoleTypePrototype.FallbackName);
|
|
var subtype = roles.GetRoleSubtypeLabel(rolePrototype?.Name ?? RoleTypePrototype.FallbackName, player.Subtype);
|
|
switch (roleSetting)
|
|
{
|
|
case AdminPlayerTabRoleTypeOption.RoleTypeSubtype:
|
|
RoleTypeLabel.Text = roletype != subtype
|
|
? roletype + " - " +subtype
|
|
: roletype;
|
|
break;
|
|
case AdminPlayerTabRoleTypeOption.SubtypeRoleType:
|
|
RoleTypeLabel.Text = roletype != subtype
|
|
? subtype + " - " + roletype
|
|
: roletype;
|
|
break;
|
|
case AdminPlayerTabRoleTypeOption.RoleType:
|
|
RoleTypeLabel.Text = roletype;
|
|
break;
|
|
default:
|
|
case AdminPlayerTabRoleTypeOption.Subtype:
|
|
RoleTypeLabel.Text = subtype;
|
|
break;
|
|
}
|
|
|
|
if (colorRoles)
|
|
RoleTypeLabel.FontColorOverride = rolePrototype?.Color ?? RoleTypePrototype.FallbackColor;
|
|
BackgroundColorPanel.PanelOverride = styleBoxFlat;
|
|
OverallPlaytimeLabel.Text = player.PlaytimeString;
|
|
}
|
|
}
|