2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
20 public partial class CUIComponent
27 public CUIComponentProps
CUIProps {
get;
set; } =
new();
30 public class CUIComponentProps
37 foreach (var child
in host.Children)
40 if (v.HasValue && !child.IgnoreParentZIndex)
42 child.ZIndex = v.Value + 1;
48 public CUIProp<bool> IgnoreEvents =
new CUIProp<bool>()
52 foreach (var child
in host.Children)
54 if (!child.IgnoreParentEventIgnorance) child.IgnoreEvents = v;
59 public CUIProp<bool> Visible =
new CUIProp<bool>()
64 foreach (var child
in host.Children)
66 if (!child.IgnoreParentVisibility) child.Visible = v;
71 public CUIProp<bool> Revealed =
new CUIProp<bool>()
78 host.IgnoreEvents = !v;
82 public CUIProp<CUIBool2> Ghost =
new CUIProp<CUIBool2>()
88 public CUIProp<bool> CullChildren =
new CUIProp<bool>()
92 host.HideChildrenOutsideFrame = v;
96 public CUIProp<CUI3DOffset> ChildrenOffset =
new CUIProp<CUI3DOffset>()
99 Value =
new CUI3DOffset(0, 0, 1),
100 Validate = (v, host) => host.ChildOffsetBounds.Check(v),
103 foreach (var child
in host.Children)
105 if (!child.Fixed) child.Scale = v.Z;
110 public CUIProp<bool> ResizeToSprite =
new CUIProp<bool>()
117 host.Absolute = host.Absolute with
119 Width = host.BackgroundSprite.SourceRect.Width,
120 Height = host.BackgroundSprite.SourceRect.Height,
127 public CUIProp<CUIBool2> FillEmptySpace =
new CUIProp<CUIBool2>()
132 public CUIProp<CUIBool2> FitContent =
new CUIProp<CUIBool2>()
138 public CUIProp<CUINullRect> Absolute =
new CUIProp<CUINullRect>()
144 public CUIProp<CUINullRect> AbsoluteMin =
new CUIProp<CUINullRect>()
150 public CUIProp<CUINullRect> AbsoluteMax =
new CUIProp<CUINullRect>()
156 public CUIProp<CUINullRect> Relative =
new CUIProp<CUINullRect>()
160 public CUIProp<CUINullRect> RelativeMin =
new CUIProp<CUINullRect>()
164 public CUIProp<CUINullRect> RelativeMax =
new CUIProp<CUINullRect>()
168 public CUIProp<CUINullRect> CrossRelative =
new CUIProp<CUINullRect>()
173 #region Graphic Props --------------------------------------------------------
177 public CUIProp<PaletteOrder> Palette =
new CUIProp<PaletteOrder>()
183 CUIGlobalStyleResolver.OnComponentStyleChanged(host);
191 public CUIProp<CUISprite> BackgroundSprite =
new CUIProp<CUISprite>()
193 Value = CUISprite.Default,
195 Validate = (v, host) => v ?? CUISprite.Default,
198 if (host.ResizeToSprite)
200 host.Absolute = host.Absolute with
202 Width = v.SourceRect.Width,
203 Height = v.SourceRect.Height,
207 if (host.IgnoreTransparent)
209 Rectangle bounds = host.BackgroundSprite.Texture.Bounds;
210 host.TextureData =
new Color[bounds.Width * bounds.Height];
211 host.BackgroundSprite.Texture.GetData<Color>(host.TextureData);
216 public CUIProp<bool> IgnoreTransparent =
new CUIProp<bool>()
222 Rectangle bounds = host.BackgroundSprite.Texture.Bounds;
223 host.TextureData =
new Color[bounds.Width * bounds.Height];
224 host.BackgroundSprite.Texture.GetData<Color>(host.TextureData);
228 host.TextureData =
null;
233 public CUIProp<Color> BackgroundColor =
new CUIProp<Color>()
238 host.BackgroundVisible = v != Color.Transparent;
242 public CUIProp<Color> OutlineColor =
new CUIProp<Color>()
247 host.OutlineVisible = v != Color.Transparent;
251 public CUIProp<Vector2> Padding =
new CUIProp<Vector2>()
253 Value =
new Vector2(2, 2),
CUIComponentProps CUIProps
Just a wrapper for CUIProps idk how to separate them better.
Wrapper object for prop value, setters, side effects, metadata etc.