2021-07-17 02:37:09 +02:00
|
|
|
|
using Robust.Client.Console;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Administration.UI.CustomControls
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
|
|
|
|
|
public class CommandButton : Button
|
|
|
|
|
|
{
|
|
|
|
|
|
public string? Command { get; set; }
|
|
|
|
|
|
|
2021-07-12 01:32:10 -07:00
|
|
|
|
public CommandButton()
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
|
|
|
|
|
OnPressed += Execute;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool CanPress()
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.IsNullOrEmpty(Command) ||
|
2021-10-10 05:47:15 -05:00
|
|
|
|
IoCManager.Resolve<IClientConGroupController>().CanCommand(Command.Split(' ')[0]);
|
2021-02-17 09:39:31 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void EnteredTree()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!CanPress())
|
|
|
|
|
|
{
|
|
|
|
|
|
Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Execute(ButtonEventArgs obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Default is to execute command
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Command))
|
|
|
|
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(Command);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|