Setup() public method

public Setup ( XML xml ) : void
xml FairyGUI.Utils.XML
return void
 static public int Setup(IntPtr l)
 {
     try {
         FairyGUI.Transition self = (FairyGUI.Transition)checkSelf(l);
         FairyGUI.Utils.XML  a1;
         checkType(l, 2, out a1);
         self.Setup(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int Setup(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Transition obj  = (FairyGUI.Transition)ToLua.CheckObject(L, 1, typeof(FairyGUI.Transition));
         FairyGUI.Utils.XML  arg0 = (FairyGUI.Utils.XML)ToLua.CheckObject(L, 2, typeof(FairyGUI.Utils.XML));
         obj.Setup(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Setup(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Transition       obj  = (FairyGUI.Transition)ToLua.CheckObject <FairyGUI.Transition>(L, 1);
         FairyGUI.Utils.ByteBuffer arg0 = (FairyGUI.Utils.ByteBuffer)ToLua.CheckObject <FairyGUI.Utils.ByteBuffer>(L, 2);
         obj.Setup(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #4
0
        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);
        }
Example #5
0
        internal void ConstructFromResource(List <GObject> objectPool, int poolIndex)
        {
            if (!packageItem.translated)
            {
                packageItem.translated = true;
                TranslationHelper.TranslateComponent(packageItem);
            }

            ByteBuffer buffer = packageItem.rawData;

            buffer.Seek(0, 0);

            underConstruct = true;

            sourceWidth  = buffer.ReadInt();
            sourceHeight = buffer.ReadInt();
            initWidth    = sourceWidth;
            initHeight   = sourceHeight;

            SetSize(sourceWidth, sourceHeight);

            if (buffer.ReadBool())
            {
                minWidth  = buffer.ReadInt();
                maxWidth  = buffer.ReadInt();
                minHeight = buffer.ReadInt();
                maxHeight = buffer.ReadInt();
            }

            if (buffer.ReadBool())
            {
                float f1 = buffer.ReadFloat();
                float f2 = buffer.ReadFloat();
                SetPivot(f1, f2, buffer.ReadBool());
            }

            if (buffer.ReadBool())
            {
                _margin.top    = buffer.ReadInt();
                _margin.bottom = buffer.ReadInt();
                _margin.left   = buffer.ReadInt();
                _margin.right  = buffer.ReadInt();
            }

            OverflowType overflow = (OverflowType)buffer.ReadByte();

            if (overflow == OverflowType.Scroll)
            {
                int savedPos = buffer.position;
                buffer.Seek(0, 7);
                SetupScroll(buffer);
                buffer.position = savedPos;
            }
            else
            {
                SetupOverflow(overflow);
            }

            if (buffer.ReadBool())             //clipSoftness
            {
                buffer.Skip(8);
            }

            _buildingDisplayList = true;

            buffer.Seek(0, 1);

            int controllerCount = buffer.ReadShort();

            for (int i = 0; i < controllerCount; i++)
            {
                int nextPos = buffer.ReadShort();
                nextPos += buffer.position;

                Controller controller = new Controller();
                _controllers.Add(controller);
                controller.parent = this;
                controller.Setup(buffer);

                buffer.position = nextPos;
            }

            buffer.Seek(0, 2);

            GObject child;
            int     childCount = buffer.ReadShort();

            for (int i = 0; i < childCount; i++)
            {
                int dataLen = buffer.ReadShort();
                int curPos  = buffer.position;

                if (objectPool != null)
                {
                    child = objectPool[poolIndex + i];
                }
                else
                {
                    buffer.Seek(curPos, 0);

                    ObjectType type  = (ObjectType)buffer.ReadByte();
                    string     src   = buffer.ReadS();
                    string     pkgId = buffer.ReadS();

                    PackageItem pi = null;
                    if (src != null)
                    {
                        UIPackage pkg;
                        if (pkgId != null)
                        {
                            pkg = UIPackage.GetById(pkgId);
                        }
                        else
                        {
                            pkg = packageItem.owner;
                        }

                        pi = pkg != null?pkg.GetItem(src) : null;
                    }

                    if (pi != null)
                    {
                        child             = UIObjectFactory.NewObject(pi);
                        child.packageItem = pi;
                        child.ConstructFromResource();
                    }
                    else
                    {
                        child = UIObjectFactory.NewObject(type);
                    }
                }

                child.underConstruct = true;
                child.Setup_BeforeAdd(buffer, curPos);
                child.InternalSetParent(this);
                _children.Add(child);

                buffer.position = curPos + dataLen;
            }

            buffer.Seek(0, 3);
            this.relations.Setup(buffer, true);

            buffer.Seek(0, 2);
            buffer.Skip(2);

            for (int i = 0; i < childCount; i++)
            {
                int nextPos = buffer.ReadShort();
                nextPos += buffer.position;

                buffer.Seek(buffer.position, 3);
                _children[i].relations.Setup(buffer, false);

                buffer.position = nextPos;
            }

            buffer.Seek(0, 2);
            buffer.Skip(2);

            for (int i = 0; i < childCount; i++)
            {
                int nextPos = buffer.ReadShort();
                nextPos += buffer.position;

                child = _children[i];
                child.Setup_AfterAdd(buffer, buffer.position);
                child.underConstruct = false;

                buffer.position = nextPos;
            }

            buffer.Seek(0, 4);

            buffer.Skip(2);             //customData
            this.opaque = buffer.ReadBool();
            int maskId = buffer.ReadShort();

            if (maskId != -1)
            {
                this.mask = GetChildAt(maskId).displayObject;
                buffer.ReadBool();                 //reversedMask
            }
            string hitTestId = buffer.ReadS();

            if (hitTestId != null)
            {
                PackageItem pi = packageItem.owner.GetItem(hitTestId);
                if (pi != null && pi.pixelHitTestData != null)
                {
                    int i1 = buffer.ReadInt();
                    int i2 = buffer.ReadInt();
                    this.rootContainer.hitArea = new PixelHitTest(pi.pixelHitTestData, i1, i2, sourceWidth, sourceHeight);
                }
            }

            buffer.Seek(0, 5);

            int transitionCount = buffer.ReadShort();

            for (int i = 0; i < transitionCount; i++)
            {
                int nextPos = buffer.ReadShort();
                nextPos += buffer.position;

                Transition trans = new Transition(this);
                trans.Setup(buffer);
                _transitions.Add(trans);

                buffer.position = nextPos;
            }

            if (_transitions.Count > 0)
            {
                this.onAddedToStage.Add(__addedToStage);
                this.onRemovedFromStage.Add(__removedFromStage);
            }

            ApplyAllControllers();

            _buildingDisplayList = false;
            underConstruct       = false;

            BuildNativeDisplayList();
            SetBoundsChangedFlag();

            if (packageItem.objectType != ObjectType.Component)
            {
                ConstructExtension(buffer);
            }

            OnConstruct();
        }
Example #6
0
        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);
            }
        }
Example #7
0
        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 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();
        }
Example #9
0
        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);
                }
            }
        }
Example #10
0
        internal void ConstructFromResource(List<GObject> objectPool, int poolIndex)
        {
            this.gameObjectName = packageItem.name;

            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.InternalSetParent(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;
                if (child.displayObject != null)
                    ToolSet.SetParent(child.displayObject.cachedTransform, this.displayObject.cachedTransform);
            }

            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);
        }