Replace VerbTypes with verb classes (#6525)

This commit is contained in:
Leon Friedrich
2022-02-10 15:30:59 +13:00
committed by GitHub
parent 0cd2c2fa9d
commit 1c9ffdc78c
60 changed files with 409 additions and 405 deletions

View File

@@ -1,8 +1,11 @@
using Content.Client.ContextMenu.UI;
using Content.Shared.Verbs;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
using Robust.Shared.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Client.Verbs.UI
{
@@ -12,10 +15,6 @@ namespace Content.Client.Verbs.UI
/// </summary>
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 string StyleClassVerbMenuConfirmationTexture = "verbMenuConfirmationTexture";
public const float VerbTooltipDelay = 0.5f;
@@ -27,50 +26,37 @@ namespace Content.Client.Verbs.UI
// 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)
public VerbMenuElement(Verb verb) : base(verb.Text)
{
ToolTip = verb.Message;
TooltipDelay = VerbTooltipDelay;
Disabled = verb.Disabled;
Verb = verb;
Label.SetOnlyStyleClass(verb.TextStyleClass);
if (verb.ConfirmationPopup)
{
ExpansionIndicator.SetOnlyStyleClass(StyleClassVerbMenuConfirmationTexture);
ExpansionIndicator.Visible = true;
}
Icon.AddChild(new TextureRect()
{
Texture = verb.Icon?.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered
});
}
public VerbMenuElement(VerbCategory category, VerbType verbType) : this(category.Text, category.Icon, verbType) { }
public VerbMenuElement(VerbCategory category, string styleClass) : base(category.Text)
{
Label.SetOnlyStyleClass(styleClass);
Icon.AddChild(new TextureRect()
{
Texture = category.Icon?.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered
});
}
}
}