override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("frame"); if (str != null) { _content.currentFrame = int.Parse(str); } _content.playing = xml.GetAttributeBool("playing", true); str = xml.GetAttribute("color"); if (str != null) { this.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("flip"); if (str != null) { _content.flip = FieldTypes.ParseFlipType(str); } }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("color"); if (str != null) { _content.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("flip"); if (str != null) { _content.flip = FieldTypes.ParseFlipType(str); } str = xml.GetAttribute("fillMethod"); if (str != null) { _content.fillMethod = FieldTypes.ParseFillMethod(str); } if (_content.fillMethod != FillMethod.None) { _content.fillOrigin = xml.GetAttributeInt("fillOrigin"); _content.fillClockwise = xml.GetAttributeBool("fillClockwise", true); _content.fillAmount = (float)xml.GetAttributeInt("fillAmount", 100) / 100; } }
override public void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("Button"); string str; str = xml.GetAttribute("mode"); if (str != null) { _mode = FieldTypes.ParseButtonMode(str); } else { _mode = ButtonMode.Common; } str = xml.GetAttribute("sound"); if (str != null) { sound = UIPackage.GetItemAssetByURL(str) as AudioClip; } str = xml.GetAttribute("volume"); if (str != null) { soundVolumeScale = float.Parse(str) / 100f; } str = xml.GetAttribute("downEffect"); if (str != null) { _downEffect = str == "dark" ? 1 : (str == "scale" ? 2 : 0); _downEffectValue = xml.GetAttributeFloat("downEffectValue"); } _buttonController = GetController("button"); _titleObject = GetChild("title"); _iconObject = GetChild("icon"); if (_mode == ButtonMode.Common) { SetState(UP); } displayObject.onRollOver.Add(__rollover); displayObject.onRollOut.Add(__rollout); displayObject.onTouchBegin.Add(__touchBegin); displayObject.onTouchEnd.Add(__touchEnd); displayObject.onRemovedFromStage.Add(__removedFromStage); displayObject.onClick.Add(__click); }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("url"); if (str != null) { _url = str; } str = xml.GetAttribute("align"); if (str != null) { _align = FieldTypes.ParseAlign(str); } str = xml.GetAttribute("vAlign"); if (str != null) { _verticalAlign = FieldTypes.ParseVerticalAlign(str); } str = xml.GetAttribute("fill"); if (str != null) { _fill = FieldTypes.ParseFillType(str); } _autoSize = xml.GetAttributeBool("autoSize", false); str = xml.GetAttribute("errorSign"); if (str != null) { showErrorSign = str == "true"; } _playing = xml.GetAttributeBool("playing", true); str = xml.GetAttribute("color"); if (str != null) { this.color = ToolSet.ConvertFromHtmlColor(str); } if (_url != null) { LoadContent(); } }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("layout"); if (str != null) { _layout = FieldTypes.ParseGroupLayoutType(str); _lineGap = xml.GetAttributeInt("lineGap"); _columnGap = xml.GetAttributeInt("colGap"); } }
public void Setup(XML xml) { this.name = xml.GetAttribute("name"); _options = xml.GetAttributeInt("options"); 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; 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 { DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value); } } }
override public void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("Slider"); string str; str = xml.GetAttribute("titleType"); if (str != null) { _titleType = FieldTypes.ParseProgressTitleType(str); } else { _titleType = ProgressTitleType.Percent; } _reverse = xml.GetAttributeBool("reverse"); _titleObject = GetChild("title") as GTextField; _barObjectH = GetChild("bar"); _barObjectV = GetChild("bar_v"); _gripObject = GetChild("grip"); if (_barObjectH != null) { _barMaxWidth = _barObjectH.width; _barMaxWidthDelta = this.width - _barMaxWidth; _barStartX = _barObjectH.x; } if (_barObjectV != null) { _barMaxHeight = _barObjectV.height; _barMaxHeightDelta = this.height - _barMaxHeight; _barStartY = _barObjectV.y; } if (_gripObject != null) { _gripObject.onTouchBegin.Add(__gripTouchBegin); _gripObject.onTouchMove.Add(__gripTouchMove); _gripObject.onTouchEnd.Add(__gripTouchEnd); } onTouchBegin.Add(__barTouchBegin); }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("color"); if (str != null) { this.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("flip"); if (str != null) { _content.flip = FieldTypes.ParseFlipType(str); } }
override public void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("Slider"); string str; str = xml.GetAttribute("titleType"); if (str != null) { _titleType = FieldTypes.ParseProgressTitleType(str); } else { _titleType = ProgressTitleType.Percent; } _titleObject = GetChild("title") as GTextField; _barObjectH = GetChild("bar"); _barObjectV = GetChild("bar_v"); _aniObject = GetChild("ani") as GMovieClip; _gripObject = GetChild("grip"); if (_barObjectH != null) { _barMaxWidth = _barObjectH.width; _barMaxWidthDelta = this.width - _barMaxWidth; } if (_barObjectV != null) { _barMaxHeight = _barObjectV.height; _barMaxHeightDelta = this.height - _barMaxHeight; } if (_gripObject != null) { _gripObject.displayObject.onMouseDown.Add(__gripMouseDown); } }
override public void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("ProgressBar"); string str; str = xml.GetAttribute("titleType"); if (str != null) { _titleType = FieldTypes.ParseProgressTitleType(str); } else { _titleType = ProgressTitleType.Percent; } _reverse = xml.GetAttributeBool("reverse", false); _titleObject = GetChild("title") as GTextField; _barObjectH = GetChild("bar"); _barObjectV = GetChild("bar_v"); _aniObject = GetChild("ani") as GMovieClip; if (_barObjectH != null) { _barMaxWidth = _barObjectH.width; _barMaxWidthDelta = this.width - _barMaxWidth; _barStartX = _barObjectH.x; } if (_barObjectV != null) { _barMaxHeight = _barObjectV.height; _barMaxHeightDelta = this.height - _barMaxHeight; _barStartY = _barObjectV.y; } Update(); }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); TextFormat tf = _textField.textFormat; string str; str = xml.GetAttribute("font"); if (str != null) { tf.font = str; } str = xml.GetAttribute("fontSize"); if (str != null) { tf.size = int.Parse(str); } str = xml.GetAttribute("color"); if (str != null) { tf.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("align"); if (str != null) { this.align = FieldTypes.ParseAlign(str); } str = xml.GetAttribute("vAlign"); if (str != null) { this.verticalAlign = FieldTypes.ParseVerticalAlign(str); } str = xml.GetAttribute("leading"); if (str != null) { tf.lineSpacing = int.Parse(str); } str = xml.GetAttribute("letterSpacing"); if (str != null) { tf.letterSpacing = int.Parse(str); } _ubbEnabled = xml.GetAttributeBool("ubb", false); str = xml.GetAttribute("autoSize"); if (str != null) { this.autoSize = FieldTypes.ParseAutoSizeType(str); } tf.underline = xml.GetAttributeBool("underline", false); tf.italic = xml.GetAttributeBool("italic", false); tf.bold = xml.GetAttributeBool("bold", false); this.singleLine = xml.GetAttributeBool("singleLine", false); str = xml.GetAttribute("strokeColor"); if (str != null) { this.strokeColor = ToolSet.ConvertFromHtmlColor(str); this.stroke = xml.GetAttributeInt("strokeSize", 1); } str = xml.GetAttribute("shadowColor"); if (str != null) { this.strokeColor = ToolSet.ConvertFromHtmlColor(str); this.shadowOffset = xml.GetAttributeVector("shadowOffset"); } _textField.textFormat = tf; }
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.Enumerator et = xml.GetEnumerator("item"); while (et.MoveNext()) { XML cxml = et.Current; 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); } } }
internal void ConstructFromResource(List <GObject> objectPool, int poolIndex) { XML xml = packageItem.componentData; 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.Enumerator et = xml.GetEnumerator("controller"); Controller controller; while (et.MoveNext()) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(et.Current); } GObject child; DisplayListItem[] displayList = packageItem.displayList; int childCount = displayList.Length; for (int i = 0; i < childCount; i++) { DisplayListItem di = displayList[i]; if (objectPool != null) { child = objectPool[poolIndex + i]; } else { if (di.packageItem != null) { di.packageItem.Load(); child = UIObjectFactory.NewObject(di.packageItem); child.packageItem = di.packageItem; child.ConstructFromResource(); } else { child = UIObjectFactory.NewObject(di.type); } } child.underConstruct = true; child.Setup_BeforeAdd(di.desc); child.parent = this; _children.Add(child); } this.relations.Setup(xml); for (int i = 0; i < childCount; i++) { _children[i].relations.Setup(displayList[i].desc); } for (int i = 0; i < childCount; i++) { child = _children[i]; child.Setup_AfterAdd(displayList[i].desc); child.underConstruct = false; } str = xml.GetAttribute("mask"); if (str != null) { this.mask = GetChildById(str).displayObject; } et = xml.GetEnumerator("transition"); while (et.MoveNext()) { Transition trans = new Transition(this); trans.Setup(et.Current); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); SetBoundsChangedFlag(); ConstructFromXML(xml); }
void LoadPackage() { string[] arr = null; string str; str = LoadString("sprites.bytes"); if (str == null) { Debug.LogError("FairyGUI: cannot load package from '" + _assetNamePrefix + "'"); return; } _loadingPackage = true; arr = str.Split('\n'); int cnt = arr.Length; for (int i = 1; i < cnt; i++) { str = arr[i]; if (str.Length == 0) continue; string[] arr2 = str.Split(' '); AtlasSprite sprite = new AtlasSprite(); string itemId = arr2[0]; int binIndex = int.Parse(arr2[1]); if (binIndex >= 0) sprite.atlas = "atlas" + binIndex; else { int pos = itemId.IndexOf("_"); if (pos == -1) sprite.atlas = "atlas_" + itemId; else sprite.atlas = "atlas_" + itemId.Substring(0, pos); } sprite.rect.x = int.Parse(arr2[2]); sprite.rect.y = int.Parse(arr2[3]); sprite.rect.width = int.Parse(arr2[4]); sprite.rect.height = int.Parse(arr2[5]); sprite.rotated = arr2[6] == "1"; _sprites[itemId] = sprite; } byte[] hittestData = LoadBinary("hittest.bytes"); if (hittestData != null) { ByteBuffer ba = new ByteBuffer(hittestData); while (ba.bytesAvailable) { PixelHitTestData pht = new PixelHitTestData(); _hitTestDatas[ba.ReadString()] = pht; pht.Load(ba); } } if (!_descPack.TryGetValue("package.xml", out str)) throw new Exception("FairyGUI: invalid package '" + _assetNamePrefix + "'"); XML xml = new XML(str); id = xml.GetAttribute("id"); name = xml.GetAttribute("name"); XML rxml = xml.GetNode("resources"); if (rxml == null) throw new Exception("FairyGUI: invalid package xml '" + _assetNamePrefix + "'"); XMLList resources = rxml.Elements(); _itemsById = new Dictionary<string, PackageItem>(); _itemsByName = new Dictionary<string, PackageItem>(); PackageItem pi; foreach (XML cxml in resources) { pi = new PackageItem(); pi.owner = this; pi.type = FieldTypes.ParsePackageItemType(cxml.name); pi.id = cxml.GetAttribute("id"); pi.name = cxml.GetAttribute("name"); pi.exported = cxml.GetAttributeBool("exported"); pi.file = cxml.GetAttribute("file"); str = cxml.GetAttribute("size"); if (str != null) { arr = str.Split(','); pi.width = int.Parse(arr[0]); pi.height = int.Parse(arr[1]); } switch (pi.type) { case PackageItemType.Image: { string scale = cxml.GetAttribute("scale"); if (scale == "9grid") { arr = cxml.GetAttributeArray("scale9grid"); if (arr != null) { Rect rect = new Rect(); rect.x = int.Parse(arr[0]); rect.y = int.Parse(arr[1]); rect.width = int.Parse(arr[2]); rect.height = int.Parse(arr[3]); pi.scale9Grid = rect; pi.tileGridIndice = cxml.GetAttributeInt("gridTile"); } } else if (scale == "tile") pi.scaleByTile = true; break; } case PackageItemType.Font: { pi.bitmapFont = new BitmapFont(pi); FontManager.RegisterFont(pi.bitmapFont, null); break; } } _items.Add(pi); _itemsById[pi.id] = pi; if (pi.name != null) _itemsByName[pi.name] = pi; } bool preloadAll = Application.isPlaying; if (preloadAll) { cnt = _items.Count; for (int i = 0; i < cnt; i++) GetItemAsset(_items[i]); _descPack = null; _sprites = null; } else _items.Sort(ComparePackageItem); if (_resBundle != null) { _resBundle.Unload(false); _resBundle = null; } _loadingPackage = false; }
void LoadPackage() { string str = this.LoadString("sprites.bytes"); string[] arr = str.Split(sep1); int cnt = arr.Length; for (int i = 1; i < cnt; i++) { str = arr[i]; if (str.Length == 0) { continue; } string[] arr2 = str.Split(sep2); AtlasSprite sprite = new AtlasSprite(); string itemId = arr2[0]; int binIndex = int.Parse(arr2[1]); if (binIndex >= 0) { sprite.atlas = "atlas" + binIndex; } else { int pos = itemId.IndexOf("_"); if (pos == -1) { sprite.atlas = "atlas_" + itemId; } else { sprite.atlas = "atlas_" + itemId.Substring(0, pos); } } sprite.rect.x = int.Parse(arr2[2]); sprite.rect.y = int.Parse(arr2[3]); sprite.rect.width = int.Parse(arr2[4]); sprite.rect.height = int.Parse(arr2[5]); sprite.rotated = arr2[6] == "1"; _sprites[itemId] = sprite; } str = GetDesc("package.xml"); XML xml = new XML(str); id = xml.GetAttribute("id"); name = xml.GetAttribute("name"); XML rxml = xml.GetNode("resources"); if (rxml == null) { throw new Exception("Invalid package xml"); } XMLList resources = rxml.Elements(); _itemsById = new Dictionary <string, PackageItem>(); _itemsByName = new Dictionary <string, PackageItem>(); PackageItem pi; foreach (XML cxml in resources) { pi = new PackageItem(); pi.type = FieldTypes.ParsePackageItemType(cxml.name); pi.id = cxml.GetAttribute("id"); pi.name = cxml.GetAttribute("name"); pi.file = cxml.GetAttribute("file"); str = cxml.GetAttribute("size"); if (str != null) { arr = str.Split(sep0); pi.width = int.Parse(arr[0]); pi.height = int.Parse(arr[1]); } switch (pi.type) { case PackageItemType.Image: { string scale = cxml.GetAttribute("scale"); if (scale == "9grid") { arr = cxml.GetAttributeArray("scale9grid"); if (arr != null) { Rect rect = new Rect(); rect.x = int.Parse(arr[0]); rect.y = int.Parse(arr[1]); rect.width = int.Parse(arr[2]); rect.height = int.Parse(arr[3]); pi.scale9Grid = rect; } } else if (scale == "tile") { pi.scaleByTile = true; } break; } } pi.owner = this; _items.Add(pi); _itemsById[pi.id] = pi; if (pi.name != null) { _itemsByName[pi.name] = pi; } } cnt = _items.Count; for (int i = 0; i < cnt; i++) { pi = _items[i]; if (pi.type == PackageItemType.Font) { pi.Load(); FontManager.RegisterFont(pi.bitmapFont, null); } else { GetItemAsset(pi); } } if (_resBundle != null) { _resBundle.Unload(false); _resBundle = null; } }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; str = xml.GetAttribute("url"); if (str != null) { _url = str; } str = xml.GetAttribute("align"); if (str != null) { _align = FieldTypes.ParseAlign(str); } str = xml.GetAttribute("vAlign"); if (str != null) { _verticalAlign = FieldTypes.ParseVerticalAlign(str); } str = xml.GetAttribute("fill"); if (str != null) { _fill = FieldTypes.ParseFillType(str); } _autoSize = xml.GetAttributeBool("autoSize", false); str = xml.GetAttribute("errorSign"); if (str != null) { showErrorSign = str == "true"; } str = xml.GetAttribute("frame"); if (str != null) { _content.currentFrame = int.Parse(str); } _content.playing = xml.GetAttributeBool("playing", true); str = xml.GetAttribute("color"); if (str != null) { _content.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("fillMethod"); if (str != null) { _content.fillMethod = FieldTypes.ParseFillMethod(str); } if (_content.fillMethod != FillMethod.None) { _content.fillOrigin = xml.GetAttributeInt("fillOrigin"); _content.fillClockwise = xml.GetAttributeBool("fillClockwise", true); _content.fillAmount = (float)xml.GetAttributeInt("fillAmount", 100) / 100; } if (_url != null) { LoadContent(); } }
virtual public 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) { string str; _controller = _owner.parent.GetController(xml.GetAttribute("controller")); if (_controller == null) { return; } Init(); string[] pages = xml.GetAttributeArray("pages"); if (pages != null) { foreach (string s in pages) { pageSet.AddById(s); } } str = xml.GetAttribute("tween"); if (str != null) { tween = true; } str = xml.GetAttribute("ease"); if (str != null) { easeType = FieldTypes.ParseEaseType(str); } str = xml.GetAttribute("duration"); if (str != null) { tweenTime = float.Parse(str); } str = xml.GetAttribute("delay"); if (str != null) { delay = float.Parse(str); } str = xml.GetAttribute("values"); string[] values = null; if (str != null) { values = str.Split(jointChar1); } if (pages != null && values != null) { for (int i = 0; i < values.Length; i++) { str = values[i]; if (str != "-") { AddStatus(pages[i], str); } } } str = xml.GetAttribute("default"); if (str != null) { AddStatus(null, str); } }
virtual public 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); } } }
override public void Setup_BeforeAdd(XML xml) { base.Setup_BeforeAdd(xml); string str; this.displayAsPassword = xml.GetAttributeBool("password", false); str = xml.GetAttribute("font"); if (str != null) { _textFormat.font = str; } str = xml.GetAttribute("fontSize"); if (str != null) { _textFormat.size = int.Parse(str); } str = xml.GetAttribute("color"); if (str != null) { _textFormat.color = ToolSet.ConvertFromHtmlColor(str); } str = xml.GetAttribute("align"); if (str != null) { _align = FieldTypes.ParseAlign(str); } str = xml.GetAttribute("vAlign"); if (str != null) { _verticalAlign = FieldTypes.ParseVerticalAlign(str); } str = xml.GetAttribute("leading"); if (str != null) { _textFormat.lineSpacing = int.Parse(str); } str = xml.GetAttribute("letterSpacing"); if (str != null) { _textFormat.letterSpacing = int.Parse(str); } _ubbEnabled = xml.GetAttributeBool("ubb", false); str = xml.GetAttribute("autoSize"); if (str != null) { this.autoSize = FieldTypes.ParseAutoSizeType(str); } _textFormat.underline = xml.GetAttributeBool("underline", false); _textFormat.italic = xml.GetAttributeBool("italic", false); _textFormat.bold = xml.GetAttributeBool("bold", false); _singleLine = xml.GetAttributeBool("singleLine", false); str = xml.GetAttribute("strokeColor"); if (str != null) { _strokeColor = ToolSet.ConvertFromHtmlColor(str); _stroke = xml.GetAttributeInt("strokeSize", 1); } }
override public 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 void Setup(XML xml) { string str; _controller = _owner.parent.GetController(xml.GetAttribute("controller")); if (_controller == null) { return; } Init(); str = xml.GetAttribute("tween"); if (str != null) { tween = true; } str = xml.GetAttribute("ease"); if (str != null) { easeType = FieldTypes.ParseEaseType(str); } str = xml.GetAttribute("duration"); if (str != null) { tweenTime = float.Parse(str); } str = xml.GetAttribute("delay"); if (str != null) { delay = float.Parse(str); } if (this is GearDisplay) { string[] pages = xml.GetAttributeArray("pages"); if (pages != null) { ((GearDisplay)this).pages = pages; } } else { string[] pages = xml.GetAttributeArray("pages"); string[] values = xml.GetAttributeArray("values", '|'); if (pages != null) { int cnt1 = pages.Length; int cnt2 = values != null ? values.Length : 0; for (int i = 0; i < cnt1; i++) { if (i < cnt2) { str = values[i]; } else { str = string.Empty; } AddStatus(pages[i], str); } } str = xml.GetAttribute("default"); if (str != null) { AddStatus(null, str); } } }