public UIScript(GraphicsDevice gd, UIContainer target) { this.gd = gd; this.target = target; this.targetType = target.GetType(); Strings = new Dictionary <string, string>(); Textures = new Dictionary <string, Texture2D>(); Components = new Dictionary <string, UIElement>(); NodesByID = new Dictionary <string, UINode>(); NamedObjects = new Dictionary <string, object>(); ControlSettings = new Dictionary <string, UINode>(); }
public void LinkMembers(UIContainer target, bool addUIElements) { var fields = target.GetType().GetProperties(); foreach (var field in fields) { if (NamedObjects.ContainsKey(field.Name)) { var value = NamedObjects[field.Name]; field.SetValue(target, value, new object[] {}); if (value is UIElement && addUIElements) { var uiValue = (UIElement)value; if (uiValue.Parent != null) { uiValue.Parent.Remove(uiValue); } target.Add(uiValue); } } } }