1
0

MagicMirrorWindow.xaml.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Content.Shared.Humanoid.Markings;
  2. using Content.Shared.MagicMirror;
  3. using Robust.Client.AutoGenerated;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Client.UserInterface.CustomControls;
  6. using Robust.Client.UserInterface.XAML;
  7. namespace Content.Client.MagicMirror;
  8. [GenerateTypedNameReferences]
  9. public sealed partial class MagicMirrorWindow : DefaultWindow
  10. {
  11. // MMMMMMM
  12. public Action<(int slot, string id)>? OnHairSelected;
  13. public Action<(int slot, Marking marking)>? OnHairColorChanged;
  14. public Action<int>? OnHairSlotRemoved;
  15. public Action? OnHairSlotAdded;
  16. public Action<(int slot, string id)>? OnFacialHairSelected;
  17. public Action<(int slot, Marking marking)>? OnFacialHairColorChanged;
  18. public Action<int>? OnFacialHairSlotRemoved;
  19. public Action? OnFacialHairSlotAdded;
  20. public MagicMirrorWindow()
  21. {
  22. RobustXamlLoader.Load(this);
  23. HairPicker.OnMarkingSelect += args => OnHairSelected!(args);
  24. HairPicker.OnColorChanged += args => OnHairColorChanged!(args);
  25. HairPicker.OnSlotRemove += args => OnHairSlotRemoved!(args);
  26. HairPicker.OnSlotAdd += delegate { OnHairSlotAdded!(); };
  27. FacialHairPicker.OnMarkingSelect += args => OnFacialHairSelected!(args);
  28. FacialHairPicker.OnColorChanged += args => OnFacialHairColorChanged!(args);
  29. FacialHairPicker.OnSlotRemove += args => OnFacialHairSlotRemoved!(args);
  30. FacialHairPicker.OnSlotAdd += delegate { OnFacialHairSlotAdded!(); };
  31. }
  32. public void UpdateState(MagicMirrorUiState state)
  33. {
  34. HairPicker.UpdateData(state.Hair, state.Species, state.HairSlotTotal);
  35. FacialHairPicker.UpdateData(state.FacialHair, state.Species, state.FacialHairSlotTotal);
  36. if (!HairPicker.Visible && !FacialHairPicker.Visible)
  37. {
  38. AddChild(new Label { Text = Loc.GetString("magic-mirror-component-activate-user-has-no-hair") });
  39. }
  40. }
  41. }