18 public GUISoundType ClickSound {
get;
set; } = GUISoundType.TickBox;
20 public event Action<bool> OnStateChange;
21 public void AddOnStateChange(Action<bool> callback) => OnStateChange += callback;
25 public CUISprite HoverOffSprite {
get;
set; }
26 public CUISprite HoverOnSprite {
get;
set; }
27 public CUISprite DisabledSprite {
get;
set; }
29 private bool state;
public bool State
34 if (state == value)
return;
40 public override bool Disabled
50 public virtual void ChangeSprite()
75 Border.Color = Color.Transparent;
76 ConsumeMouseClicks =
true;
77 ConsumeDragAndDrop =
true;
83 SourceRect =
new Rectangle(0, 0, 32, 32),
88 SourceRect =
new Rectangle(32, 0, 32, 32),
93 SourceRect =
new Rectangle(64, 0, 32, 32),
97 SourceRect =
new Rectangle(96, 0, 32, 32),
102 SourceRect =
new Rectangle(128, 0, 32, 32),
107 OnMouseDown += (e) =>
109 if (Disabled)
return;
111 SoundPlayer.PlayUISound(ClickSound);
113 OnStateChange?.Invoke(State);
117 OnMouseEnter += (e) => ChangeSprite();
118 OnMouseLeave += (e) => ChangeSprite();
122 if (o is
bool b) State = b;
record CUICommand(string Name, object Data=null)
Can be dispatched up the component tree to notify parent about something add pass some event data wit...