static public int Elements(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { FairyGUI.Utils.XML self = (FairyGUI.Utils.XML)checkSelf(l); var ret = self.Elements(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { FairyGUI.Utils.XML self = (FairyGUI.Utils.XML)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.Elements(a1); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
/// <summary> /// Set strings source. /// </summary> /// <param name="source"></param> public static void SetStringsSource(XML source) { _stringsSource = new Dictionary<string, Dictionary<string, string>>(); XMLList list = source.Elements("string"); foreach (XML cxml in list) { string key = cxml.GetAttribute("name"); string text = cxml.text; int i = key.IndexOf("-"); if (i == -1) continue; string key2 = key.Substring(0, i); string key3 = key.Substring(i + 1); Dictionary<string, string> col = _stringsSource[key2]; if (col == null) { col = new Dictionary<string, string>(); _stringsSource[key2] = col; } col[key3] = text; } }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); SetSize(sourceWidth, sourceHeight); SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; //build real display list foreach (GObject child in _children) { if (child.displayObject != null && child.finalVisible) container.AddChild(child.displayObject); } }
public override void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("layout"); if (str != null) _layout = FieldTypes.ParseListLayoutType(str); else _layout = ListLayoutType.SingleColumn; str = xml.GetAttribute("selectionMode"); if (str != null) selectionMode = FieldTypes.ParseListSelectionMode(str); else selectionMode = ListSelectionMode.Single; OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags); string[] arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _lineGap = xml.GetAttributeInt("lineGap"); _columnGap = xml.GetAttributeInt("colGap"); defaultItem = xml.GetAttribute("defaultItem"); autoResizeItem = xml.GetAttributeBool("autoItemSize", true); XMLList col = xml.Elements("item"); foreach (XML ix in col) { string url = ix.GetAttribute("url"); if (string.IsNullOrEmpty(url)) url = defaultItem; if (string.IsNullOrEmpty(url)) continue; GObject obj = AddItemFromPool(url); if (obj is GButton) { ((GButton)obj).title = ix.GetAttribute("title"); ((GButton)obj).icon = ix.GetAttribute("icon"); } else if (obj is GLabel) { ((GLabel)obj).title = ix.GetAttribute("title"); ((GLabel)obj).icon = ix.GetAttribute("icon"); } } }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = _packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else SetupOverflow(overflow); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } str = xml.GetAttribute("mask"); if (str != null) this.mask = GetChildById(str).displayObject; XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); }
public void Setup(XML xml) { this.name = xml.GetAttribute("name"); _options = xml.GetAttributeInt("options"); this.autoPlay = xml.GetAttributeBool("autoPlay"); if (this.autoPlay) { this.autoPlayRepeat = xml.GetAttributeInt("autoPlayRepeat", 1); this.autoPlayDelay = xml.GetAttributeFloat("autoPlayDelay"); } XMLList col = xml.Elements("item"); foreach (XML cxml in col) { TransitionItem item = new TransitionItem(); _items.Add(item); item.time = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE; item.targetId = cxml.GetAttribute("target", string.Empty); item.type = FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type")); item.tween = cxml.GetAttributeBool("tween"); item.label = cxml.GetAttribute("label"); if (item.tween) { item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE; if (item.time + item.duration > _maxTime) _maxTime = item.time + item.duration; string ease = cxml.GetAttribute("ease"); if (ease != null) item.easeType = FieldTypes.ParseEaseType(ease); item.repeat = cxml.GetAttributeInt("repeat"); item.yoyo = cxml.GetAttributeBool("yoyo"); item.label2 = cxml.GetAttribute("label2"); string v = cxml.GetAttribute("endValue"); if (v != null) { DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue); DecodeValue(item.type, v, item.endValue); } else { item.tween = false; DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value); } } else { if (item.time > _maxTime) _maxTime = item.time; DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value); } } }
public void Setup(XML xml) { XMLList col = xml.Elements("relation"); if (col == null) return; string targetId; GObject target; foreach (XML cxml in col) { targetId = cxml.GetAttribute("target"); if (_owner.parent != null) { if (targetId != null && targetId != "") target = _owner.parent.GetChildById(targetId); else target = _owner.parent; } else { //call from component construction target = ((GComponent)_owner).GetChildById(targetId); } if (target != null) AddItems(target, cxml.GetAttribute("sidePair")); } }