fish-station/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabHeader.xaml.cs
Vigers Ray 84c607c84a Merge remote-tracking branch 'space-wizards/master'
# Conflicts:
#	Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs
#	Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml
#	Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs
#	Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabHeader.xaml
#	Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabHeader.xaml.cs
#	Content.Server/Administration/Systems/AdminSystem.cs
#	Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
#	Content.Server/Ghost/GhostSystem.cs
#	Resources/Locale/en-US/_strings/administration/antag.ftl
#	Resources/Locale/en-US/_strings/administration/commands/adminnotes.ftl
#	Resources/Locale/en-US/_strings/construction/components/block-anchor-component.ftl
#	Resources/Locale/en-US/_strings/power/commands.ftl
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/clothesmate.yml
#	Resources/Textures/Interface/Misc/job_icons.rsi/meta.json
#	Resources/Textures/Objects/Specific/Hydroponics/aloe.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/apple.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/chili.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/corn.rsi/meta.json
#	Resources/Textures/Objects/Specific/Hydroponics/corn.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/eggplant.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/eggy.rsi/meta.json
#	Resources/Textures/Objects/Specific/Hydroponics/lemon.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/onion_red.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/potato.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/sugarcane.rsi/produce.png
#	Resources/Textures/Objects/Specific/Hydroponics/tomato.rsi/produce.png
2025-03-27 20:37:49 +03:00

116 lines
3.3 KiB
C#

using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
namespace Content.Client.Administration.UI.Tabs.PlayerTab;
[GenerateTypedNameReferences]
public sealed partial class PlayerTabHeader : Control
{
public event Action<Header>? OnHeaderClicked;
public PlayerTabHeader()
{
RobustXamlLoader.Load(this);
UsernameLabel.OnKeyBindDown += UsernameClicked;
CharacterLabel.OnKeyBindDown += CharacterClicked;
JobLabel.OnKeyBindDown += JobClicked;
SponsorLabel.OnKeyBindDown += SponsorClicked; // Sunrise-Sponsors
RoleTypeLabel.OnKeyBindDown += RoleTypeClicked;
PlaytimeLabel.OnKeyBindDown += PlaytimeClicked;
}
public Label GetHeader(Header header)
{
return header switch
{
Header.Username => UsernameLabel,
Header.Character => CharacterLabel,
Header.Job => JobLabel,
Header.Sponsor => SponsorLabel, // Sunrise-Sponsors
Header.RoleType => RoleTypeLabel,
Header.Playtime => PlaytimeLabel,
_ => throw new ArgumentOutOfRangeException(nameof(header), header, null)
};
}
public void ResetHeaderText()
{
UsernameLabel.Text = Loc.GetString("player-tab-username");
CharacterLabel.Text = Loc.GetString("player-tab-character");
JobLabel.Text = Loc.GetString("player-tab-job");
SponsorLabel.Text = Loc.GetString("player-tab-sponsor"); // Sunrise-Sponsors
RoleTypeLabel.Text = Loc.GetString("player-tab-roletype");
PlaytimeLabel.Text = Loc.GetString("player-tab-playtime");
}
private void HeaderClicked(GUIBoundKeyEventArgs args, Header header)
{
if (args.Function != EngineKeyFunctions.UIClick)
{
return;
}
OnHeaderClicked?.Invoke(header);
args.Handle();
}
private void UsernameClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.Username);
}
private void CharacterClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.Character);
}
private void JobClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.Job);
}
private void RoleTypeClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.RoleType);
}
// Sunrise-Sponsors-Start
private void SponsorClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.Sponsor);
}
// Sunrise-Sponsors-End
private void PlaytimeClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.Playtime);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
UsernameLabel.OnKeyBindDown -= UsernameClicked;
CharacterLabel.OnKeyBindDown -= CharacterClicked;
JobLabel.OnKeyBindDown -= JobClicked;
RoleTypeLabel.OnKeyBindDown -= RoleTypeClicked;
PlaytimeLabel.OnKeyBindDown -= PlaytimeClicked;
}
}
public enum Header
{
Username,
Character,
Job,
Sponsor, // Sunrise-Sponsors
RoleType,
Playtime
}
}