20 public GUISoundType ClickSound {
get;
set; } = GUISoundType.Select;
21 [CUISerializable]
public bool PlaySound {
get;
set; } =
true;
23 [CUISerializable]
public Color DisabledColor {
get;
set; }
24 [CUISerializable]
public Color OnColor {
get;
set; }
25 [CUISerializable]
public Color OnHoverColor {
get;
set; }
26 [CUISerializable]
public Color OffColor {
get;
set; }
27 [CUISerializable]
public Color OffHoverColor {
get;
set; }
29 public Color MasterColor
33 OffColor = value.Multiply(0.5f);
34 OffHoverColor = value;
35 OnColor = value.Multiply(0.9f);
40 public Color MasterColorOpaque
44 OffColor =
new Color((
int)(value.R * 0.5f), (
int)(value.G * 0.5f), (
int)(value.B * 0.5f), value.A);
45 OffHoverColor = value;
46 OnColor =
new Color((
int)(value.R * 0.9f), (
int)(value.G * 0.9f), (
int)(value.B * 0.9f), value.A); ;
53 public new Color BackgroundColor {
get =>
CUIProps.BackgroundColor.Value;
set =>
CUIProps.BackgroundColor.SetValue(value); }
56 private string onText;
57 private string offText;
62 set { onText = value;
if (State && onText !=
null) Text = onText; }
69 set { offText = value;
if (!State && offText !=
null) Text = offText; }
72 public event Action<bool> OnStateChange;
73 public Action<bool> AddOnStateChange {
set { OnStateChange += value; } }
75 [CUISerializable]
public bool ToggleOnClick {
get;
set; } =
true;
84 if (state && OnText !=
null) Text = OnText;
85 if (!state && OffText !=
null) Text = OffText;
89 public override void Draw(SpriteBatch spriteBatch)
93 BackgroundColor = DisabledColor;
99 if (MouseOver) BackgroundColor = OnHoverColor;
100 else BackgroundColor = OnColor;
104 if (MouseOver) BackgroundColor = OffHoverColor;
105 else BackgroundColor = OffColor;
109 base.Draw(spriteBatch);
114 ConsumeMouseClicks =
true;
115 ConsumeDragAndDrop =
true;
125 OnMouseDown += (e) =>
129 if (PlaySound) SoundPlayer.PlayUISound(ClickSound);
133 OnStateChange?.Invoke(State);
139 public CUIToggleButton(
string text) : this()
Vector2 TextAlign
A Vector2 ([0..1],[0..1])