Converts AdminMenu to partially use XAML (#3231)

This commit is contained in:
Leo
2021-02-17 09:39:31 -03:00
committed by GitHub
parent c435b5150d
commit 48eea211bc
33 changed files with 1029 additions and 927 deletions

View File

@@ -0,0 +1,38 @@
#nullable enable
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
namespace Content.Client.UserInterface.AdminMenu.CustomControls
{
public class CommandButton : Button
{
public string? Command { get; set; }
public CommandButton() : base()
{
OnPressed += Execute;
}
protected virtual bool CanPress()
{
return string.IsNullOrEmpty(Command) ||
IoCManager.Resolve<IClientConGroupController>().CanCommand(Command);
}
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);
}
}
}