PdaSettingsButton.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Robust.Client.AutoGenerated;
  2. using Robust.Client.Graphics;
  3. using Robust.Client.UserInterface.Controls;
  4. using Robust.Client.UserInterface.XAML;
  5. namespace Content.Client.PDA;
  6. [GenerateTypedNameReferences]
  7. public sealed partial class PdaSettingsButton : ContainerButton
  8. {
  9. public const string StylePropertyFgColor = "foregroundColor";
  10. public const string StylePropertyBgColor = "backgroundColor";
  11. public const string NormalBgColor = "#313138";
  12. public const string HoverColor = "#3E6C45";
  13. public const string PressedColor = "#3E6C45";
  14. public const string DisabledFgColor = "#5a5a5a";
  15. public const string EnabledFgColor = "#FFFFFF";
  16. private readonly StyleBoxFlat _styleBox = new()
  17. {
  18. BackgroundColor = Color.FromHex("#25252a")
  19. };
  20. public string? Text
  21. {
  22. get => OptionName.Text;
  23. set => OptionName.Text = value;
  24. }
  25. public string? Description
  26. {
  27. get => OptionDescription.Text;
  28. set => OptionDescription.Text = value;
  29. }
  30. public Color BackgroundColor
  31. {
  32. get => _styleBox.BackgroundColor;
  33. set => _styleBox.BackgroundColor = value;
  34. }
  35. public Color? ForegroundColor
  36. {
  37. get => OptionName.FontColorOverride;
  38. set
  39. {
  40. OptionName.FontColorOverride = value;
  41. OptionDescription.FontColorOverride = value;
  42. }
  43. }
  44. public PdaSettingsButton()
  45. {
  46. RobustXamlLoader.Load(this);
  47. Panel.PanelOverride = _styleBox;
  48. }
  49. protected override void Draw(DrawingHandleScreen handle)
  50. {
  51. base.Draw(handle);
  52. if (TryGetStyleProperty<Color>(StylePropertyBgColor, out var bgColor))
  53. BackgroundColor = bgColor;
  54. if (TryGetStyleProperty<Color>(StylePropertyFgColor, out var fgColor))
  55. ForegroundColor = fgColor;
  56. }
  57. }