EyeColorPicker.cs 884 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Robust.Client.UserInterface;
  2. using Robust.Client.UserInterface.Controls;
  3. namespace Content.Client.Humanoid;
  4. public sealed class EyeColorPicker : Control
  5. {
  6. public event Action<Color>? OnEyeColorPicked;
  7. private readonly ColorSelectorSliders _colorSelectors;
  8. private Color _lastColor;
  9. public void SetData(Color color)
  10. {
  11. _lastColor = color;
  12. _colorSelectors.Color = color;
  13. }
  14. public EyeColorPicker()
  15. {
  16. var vBox = new BoxContainer
  17. {
  18. Orientation = BoxContainer.LayoutOrientation.Vertical
  19. };
  20. AddChild(vBox);
  21. vBox.AddChild(_colorSelectors = new ColorSelectorSliders());
  22. _colorSelectors.OnColorChanged += ColorValueChanged;
  23. }
  24. private void ColorValueChanged(Color newColor)
  25. {
  26. OnEyeColorPicked?.Invoke(newColor);
  27. _lastColor = newColor;
  28. }
  29. }