public void Populate(List <JSONObject> markups) { for (int i = 0; i < markups.Count; i++) { MagicUIControl.CreateFromMarkup(string.Format("{0}.{1}", name, i), markups[i], this); } }
public void Populate(List <JSONObject> markups) { for (int i = 0; i < markups.Count; i++) { MagicUIControl.CreateFromMarkup(i.ToString(), markups[i], this); } }
public string ControlCreated(MagicUIControl control) { string key = control.Key; if (key == null) { key = ""; } key = string.Intern(key); List <MagicUIControl> targets = null; if (_notificationTargets.ContainsKey(key)) { targets = _notificationTargets[key]; } else { targets = new List <MagicUIControl>(); _notificationTargets.Add(key, targets); } targets.Add(control); string val = null; if (!string.IsNullOrEmpty(key)) { // TODO LOAD EXISTING SAVED VALUES FROM PLAYER PREFS! // IF NO DEFAULT, GET DEFAULT FROM CONTROL val = control.DefaultValue; if (val != null) { Write(key, val, control); } } return(val); }
public void Write(string key, string val, MagicUIControl exclude = null) { if (string.IsNullOrEmpty(key)) { return; } if (val == null) { return; } _valuesTable[key] = val; DebugManager.Log("{0} = {1}", key, val); List <MagicUIControl> targets = null; if (_notificationTargets.ContainsKey(key)) { targets = _notificationTargets[key]; } if (targets != null && targets.Count > 0) { for (int i = 0; i < targets.Count; i++) { if (targets[i] == exclude) { continue; } targets[i].Value = val; } } }
public static MagicUIControl CreateFromMarkup(string id, JSONObject markup, IMagicUIPanel page) { DebugManager.Log("...{0}: {1}", id, markup); MagicUIControl.ControlType type = markup.GetControlType(); MagicUIControl control = null; switch (type) { case ControlType.Label: control = MagicUILabelControl.Create(); break; case ControlType.Image: control = MagicUIImageControl.Create(); break; case ControlType.Button: control = MagicUIButton.Create(); break; case ControlType.Container: control = MagicUIContainer.Create(); break; case ControlType.Rectangle: control = MagicUIRectangle.Create(); break; case ControlType.Checkbox: control = MagicUICheckbox.Create(); break; case ControlType.TextBox: control = MagicUITextBox.Create(); break; case ControlType.Slider: control = MagicUISlider.Create(); break; default: break; } if (control != null) { control.name = id; control.setContainer(page); control.initialize(markup); control.setExtents(control.calculateExtents(markup.GetRect(), markup.GetAnchors())); int z = markup.GetIntSafely("zOrder", 0); control.setZOrder(z * 10); int link = markup.GetIntSafely("link", int.MinValue); if (link >= -1) { control.setLink(link); } if (control is IMagicUIPanel) { ((IMagicUIPanel)control).Populate(markup["contents"]["children"].list); } control.register(); } return(null); }
public void Write(string key, int val, MagicUIControl exclude = null) { Write(key, val.ToString(), exclude); }
public void Write(MagicUIControl control, int val) { Write(control.Key, val, control); }