ExamineButton.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Content.Client.ContextMenu.UI;
  2. using Content.Client.Stylesheets;
  3. using Content.Shared.Verbs;
  4. using Robust.Client.AutoGenerated;
  5. using Robust.Client.Graphics;
  6. using Robust.Client.UserInterface.Controls;
  7. using Robust.Client.UserInterface.XAML;
  8. using Robust.Client.Utility;
  9. using Robust.Shared.Utility;
  10. namespace Content.Client.Examine;
  11. /// <summary>
  12. /// Buttons that show up in the examine tooltip to specify more detailed
  13. /// ways to examine an item.
  14. /// </summary>
  15. public sealed class ExamineButton : ContainerButton
  16. {
  17. public const string StyleClassExamineButton = "examine-button";
  18. public const int ElementHeight = 32;
  19. public const int ElementWidth = 32;
  20. private const int Thickness = 4;
  21. public TextureRect Icon;
  22. public ExamineVerb Verb;
  23. public ExamineButton(ExamineVerb verb)
  24. {
  25. Margin = new Thickness(Thickness, Thickness, Thickness, Thickness);
  26. SetOnlyStyleClass(StyleClassExamineButton);
  27. Verb = verb;
  28. if (verb.Disabled)
  29. {
  30. Disabled = true;
  31. }
  32. ToolTip = verb.Message ?? verb.Text;
  33. Icon = new TextureRect
  34. {
  35. SetWidth = ElementWidth,
  36. SetHeight = ElementHeight
  37. };
  38. if (verb.Icon != null)
  39. {
  40. Icon.Texture = verb.Icon.Frame0();
  41. Icon.Stretch = TextureRect.StretchMode.KeepAspectCentered;
  42. AddChild(Icon);
  43. }
  44. }
  45. }