2022-02-13 20:20:58 -07:00
|
|
|
using Content.Shared.Verbs;
|
2025-03-30 12:06:43 +00:00
|
|
|
using Robust.Client.GameObjects;
|
2022-02-13 20:20:58 -07:00
|
|
|
using Robust.Client.UserInterface.Controls;
|
2025-03-22 03:22:01 +01:00
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2022-02-13 20:20:58 -07:00
|
|
|
using Robust.Client.Utility;
|
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Examine;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Buttons that show up in the examine tooltip to specify more detailed
|
|
|
|
|
/// ways to examine an item.
|
|
|
|
|
/// </summary>
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ExamineButton : ContainerButton
|
2022-02-13 20:20:58 -07:00
|
|
|
{
|
|
|
|
|
public const string StyleClassExamineButton = "examine-button";
|
|
|
|
|
|
|
|
|
|
public const int ElementHeight = 32;
|
|
|
|
|
public const int ElementWidth = 32;
|
|
|
|
|
|
|
|
|
|
private const int Thickness = 4;
|
|
|
|
|
|
|
|
|
|
public TextureRect Icon;
|
|
|
|
|
|
|
|
|
|
public ExamineVerb Verb;
|
2025-03-30 12:06:43 +00:00
|
|
|
private SpriteSystem _sprite;
|
2022-02-13 20:20:58 -07:00
|
|
|
|
2025-03-30 12:06:43 +00:00
|
|
|
public ExamineButton(ExamineVerb verb, SpriteSystem spriteSystem)
|
2022-02-13 20:20:58 -07:00
|
|
|
{
|
|
|
|
|
Margin = new Thickness(Thickness, Thickness, Thickness, Thickness);
|
|
|
|
|
|
|
|
|
|
SetOnlyStyleClass(StyleClassExamineButton);
|
|
|
|
|
|
|
|
|
|
Verb = verb;
|
2025-03-30 12:06:43 +00:00
|
|
|
_sprite = spriteSystem;
|
2022-02-13 20:20:58 -07:00
|
|
|
|
|
|
|
|
if (verb.Disabled)
|
|
|
|
|
{
|
|
|
|
|
Disabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-22 03:22:01 +01:00
|
|
|
TooltipSupplier = sender =>
|
|
|
|
|
{
|
|
|
|
|
var label = new RichTextLabel();
|
|
|
|
|
label.SetMessage(FormattedMessage.FromMarkupOrThrow(verb.Message ?? verb.Text));
|
|
|
|
|
|
|
|
|
|
var tooltip = new Tooltip();
|
|
|
|
|
tooltip.GetChild(0).Children.Clear();
|
|
|
|
|
tooltip.GetChild(0).Children.Add(label);
|
|
|
|
|
|
|
|
|
|
return tooltip;
|
|
|
|
|
};
|
2022-02-13 20:20:58 -07:00
|
|
|
|
|
|
|
|
Icon = new TextureRect
|
|
|
|
|
{
|
|
|
|
|
SetWidth = ElementWidth,
|
|
|
|
|
SetHeight = ElementHeight
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-26 18:48:57 +11:00
|
|
|
if (verb.Icon != null)
|
2022-02-13 20:20:58 -07:00
|
|
|
{
|
2025-03-30 12:06:43 +00:00
|
|
|
Icon.Texture = _sprite.Frame0(verb.Icon);
|
2022-02-13 20:20:58 -07:00
|
|
|
Icon.Stretch = TextureRect.StretchMode.KeepAspectCentered;
|
|
|
|
|
|
|
|
|
|
AddChild(Icon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|