using Content.Client.ContextMenu.UI; using Content.Shared.Verbs; using Robust.Client.UserInterface.Controls; using Robust.Client.Utility; using Robust.Shared.Utility; namespace Content.Client.Verbs.UI { /// /// Slight extension of that uses a SpriteSpecifier for it's icon and provides /// constructors that take verbs or verb categories. /// public partial class VerbMenuElement : ContextMenuElement { public const string StyleClassVerbInteractionText = "InteractionVerb"; public const string StyleClassVerbActivationText = "ActivationVerb"; public const string StyleClassVerbAlternativeText = "AlternativeVerb"; public const string StyleClassVerbOtherText = "OtherVerb"; public const float VerbTooltipDelay = 0.5f; // Setters to provide access to children generated by XAML. public bool IconVisible { set => Icon.Visible = value; } public bool TextVisible { set => Label.Visible = value; } // Top quality variable naming public Verb? Verb; public VerbType Type; public VerbMenuElement(string? text, SpriteSpecifier? icon, VerbType verbType) : base(text) { Icon.AddChild(new TextureRect() { Texture = icon?.Frame0(), Stretch = TextureRect.StretchMode.KeepAspectCentered }); Type = verbType; // Set text font style based on verb type switch (verbType) { case VerbType.Interaction: Label.SetOnlyStyleClass(StyleClassVerbInteractionText); break; case VerbType.Activation: Label.SetOnlyStyleClass(StyleClassVerbActivationText); break; case VerbType.Alternative: Label.SetOnlyStyleClass(StyleClassVerbAlternativeText); break; default: Label.SetOnlyStyleClass(StyleClassVerbOtherText); break; } } public VerbMenuElement(Verb verb, VerbType verbType) : this(verb.Text, verb.Icon, verbType) { ToolTip = verb.Message; TooltipDelay = VerbTooltipDelay; Disabled = verb.Disabled; Verb = verb; } public VerbMenuElement(VerbCategory category, VerbType verbType) : this(category.Text, category.Icon, verbType) { } } }