mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
35 lines
778 B
C#
35 lines
778 B
C#
using Robust.Client.Console;
|
|
|
|
namespace Content.Client._White.UserInterface.Buttons;
|
|
|
|
[Virtual]
|
|
public class WhiteCommandButton : WhiteLobbyTextButton
|
|
{
|
|
public string? Command { get; set; }
|
|
|
|
public WhiteCommandButton()
|
|
{
|
|
OnPressed += Execute;
|
|
}
|
|
|
|
private bool CanPress()
|
|
{
|
|
return string.IsNullOrEmpty(Command) ||
|
|
IoCManager.Resolve<IClientConGroupController>().CanCommand(Command.Split(' ')[0]);
|
|
}
|
|
|
|
protected override void EnteredTree()
|
|
{
|
|
if (!CanPress())
|
|
{
|
|
Visible = false;
|
|
}
|
|
}
|
|
|
|
protected virtual void Execute(ButtonEventArgs obj)
|
|
{
|
|
if (!string.IsNullOrEmpty(Command))
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(Command);
|
|
}
|
|
}
|