2using System.Collections.Generic;
4using System.Reflection;
7using Microsoft.Xna.Framework;
8using Microsoft.Xna.Framework.Input;
9using Microsoft.Xna.Framework.Graphics;
11using Barotrauma.Extensions;
21 public GUISoundType ClickSound {
get;
set; } = GUISoundType.Select;
22 [CUISerializable]
public bool PlaySound {
get;
set; } =
true;
23 [CUISerializable]
public Color DisabledColor {
get;
set; }
24 [CUISerializable]
public Color InactiveColor {
get;
set; }
25 [CUISerializable]
public Color MouseOverColor {
get;
set; }
26 [CUISerializable]
public Color MousePressedColor {
get;
set; }
27 [CUISerializable]
public bool AutoUpdateColor {
get;
set; } =
true;
36 InactiveColor = value.Multiply(0.7f);
37 MouseOverColor = value.Multiply(0.9f);
38 MousePressedColor = value;
43 public Color MasterColorOpaque
47 InactiveColor =
new Color((
int)(value.R * 0.7f), (
int)(value.G * 0.7f), (
int)(value.B * 0.7f), value.A);
48 MouseOverColor =
new Color((
int)(value.R * 0.9f), (
int)(value.G * 0.9f), (
int)(value.B * 0.9f), value.A);
49 MousePressedColor = value;
60 get =>
CUIProps.BackgroundColor.Value;
61 set =>
CUIProps.BackgroundColor.SetValue(value);
64 public void DetermineColor()
66 if (!AutoUpdateColor)
return;
79 public override void Draw(SpriteBatch spriteBatch)
82 base.Draw(spriteBatch);
87 ConsumeMouseClicks =
true;
88 ConsumeDragAndDrop =
true;
95 if (PlaySound) SoundPlayer.PlayUISound(ClickSound);
104 OnMouseOff += (e) => DetermineColor();
105 OnMouseOn += (e) => DetermineColor();
110 public CUIButton(
string text) : this()
virtual bool Disabled
Usually means - non interactable, e.g. unclickable gray button.
CUIComponentProps CUIProps
Just a wrapper for CUIProps idk how to separate them better.
string Command
This command will be dispatched up when some component specific event happens.
void DispatchUp(CUICommand command)
Dispathes command up the component tree until someone consumes it.
Action OnStyleApplied
Use it to e.g. update component color.
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...