Role subtypes (#35359)
This commit is contained in:
@@ -1,42 +1,99 @@
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
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.Configuration;
|
||||
|
||||
namespace Content.Client.Administration.UI.Tabs.PlayerTab;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class PlayerTabEntry : PanelContainer
|
||||
{
|
||||
public NetEntity? PlayerEntity;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public PlayerTabEntry(PlayerInfo player, StyleBoxFlat styleBoxFlat)
|
||||
public PlayerTabEntry(
|
||||
PlayerInfo player,
|
||||
StyleBoxFlat styleBoxFlat,
|
||||
AdminPlayerTabColorOption colorOption,
|
||||
AdminPlayerTabRoleTypeOption roleSetting,
|
||||
AdminPlayerTabSymbolOption symbolSetting)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
RobustXamlLoader.Load(this);
|
||||
var config = IoCManager.Resolve<IConfigurationManager>();
|
||||
var roles = _entMan.System<SharedRoleSystem>();
|
||||
|
||||
UsernameLabel.Text = player.Username;
|
||||
if (!player.Connected)
|
||||
UsernameLabel.StyleClasses.Add("Disabled");
|
||||
JobLabel.Text = player.StartingJob;
|
||||
var separateAntagSymbols = config.GetCVar(CCVars.AdminPlayerlistSeparateSymbols);
|
||||
var genericAntagSymbol = player.Antag ? Loc.GetString("player-tab-antag-prefix") : string.Empty;
|
||||
var roleSymbol = player.Antag ? player.RoleProto.Symbol : string.Empty;
|
||||
var symbol = separateAntagSymbols ? roleSymbol : genericAntagSymbol;
|
||||
|
||||
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 ? player.RoleProto.Symbol : string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
CharacterLabel.Text = Loc.GetString("player-tab-character-name-antag-symbol", ("symbol", symbol), ("name", player.CharacterName));
|
||||
|
||||
if (player.Antag && config.GetCVar(CCVars.AdminPlayerlistHighlightedCharacterColor))
|
||||
if (player.Antag && colorAntags)
|
||||
CharacterLabel.FontColorOverride = player.RoleProto.Color;
|
||||
if (player.IdentityName != player.CharacterName)
|
||||
CharacterLabel.Text += $" [{player.IdentityName}]";
|
||||
RoleTypeLabel.Text = Loc.GetString(player.RoleProto.Name);
|
||||
if (config.GetCVar(CCVars.AdminPlayerlistRoleTypeColor))
|
||||
|
||||
var roletype = RoleTypeLabel.Text = Loc.GetString(player.RoleProto.Name);
|
||||
var subtype = roles.GetRoleSubtypeLabel(player.RoleProto.Name, 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 = player.RoleProto.Color;
|
||||
BackgroundColorPanel.PanelOverride = styleBoxFlat;
|
||||
OverallPlaytimeLabel.Text = player.PlaytimeString;
|
||||
PlayerEntity = player.NetEntity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user