CrabUI
Loading...
Searching...
No Matches
CUIPropsInterface.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5
6using Barotrauma;
7using Microsoft.Xna.Framework;
8using Microsoft.Xna.Framework.Input;
9using Microsoft.Xna.Framework.Graphics;
10
11namespace CrabUI
12{
13 public class CUIPropsInterface : CUIComponent, IRefreshable
14 {
15 private CUIComponent target;
16 public CUIComponent Target
17 {
18 get => target;
19 set
20 {
21 target = value;
22 Refresh();
23 }
24 }
25 public CUIVerticalList Props { get; set; }
26
27 public void Refresh()
28 {
29 Props.RemoveAllChildren();
30
31 if (Target == null) return;
32
33 CUITypeMetaData meta = CUITypeMetaData.Get(Target.GetType());
34
35 foreach (string key in meta.Serializable.Keys)
36 {
37 Props.Append(new CUITextBlock($"{key} - {meta.Serializable[key].GetValue(Target)}")
38 {
39 IgnoreDebug = true,
40 });
41 }
42 }
43
44 public CUIPropsInterface() : base()
45 {
46 SerializeChildren = false;
47 this["Props"] = Props = new CUIVerticalList()
48 {
49 Relative = new CUINullRect(0, 0, 1, 1),
50 Scrollable = true,
51 };
52
53 IgnoreDebug = true;
54 }
55 }
56}
CUINullRect Relative
Relative to parent size and position, [0..1].
virtual CUIComponent Append(CUIComponent child, string name=null, [CallerMemberName] string memberName="")
Adds children to the end of the list.
bool SerializeChildren
Is this a serialization cutoff point Parent will serialize children down to this component and stop...