GetAttribute() public method

public GetAttribute ( string attrName ) : string
attrName string
return string
示例#1
0
        public override void Setup_BeforeAdd(Utils.XML xml)
        {
            base.Setup_BeforeAdd(xml);

            _promptText             = xml.GetAttribute("prompt");
            _textField.restrict     = xml.GetAttribute("restrict");
            _textField.maxLength    = xml.GetAttributeInt("maxLength", int.MaxValue);
            _textField.keyboardType = xml.GetAttributeInt("keyboardType");
        }
示例#2
0
        public override void Setup_BeforeAdd(Utils.XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str = xml.GetAttribute("prompt");

            if (str != null)
            {
                inputTextField.promptText = str;
            }
            inputTextField.displayAsPassword = xml.GetAttributeBool("password", false);
            inputTextField.restrict          = xml.GetAttribute("restrict");
            inputTextField.maxLength         = xml.GetAttributeInt("maxLength", int.MaxValue);
            inputTextField.keyboardType      = xml.GetAttributeInt("keyboardType");
        }
 static public int GetAttribute(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             FairyGUI.Utils.XML self = (FairyGUI.Utils.XML)checkSelf(l);
             System.String      a1;
             checkType(l, 2, out a1);
             var ret = self.GetAttribute(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             FairyGUI.Utils.XML self = (FairyGUI.Utils.XML)checkSelf(l);
             System.String      a1;
             checkType(l, 2, out a1);
             System.String a2;
             checkType(l, 3, out a2);
             var ret = self.GetAttribute(a1, a2);
             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));
     }
 }
示例#4
0
        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("values");
            string[] values = null;
            if (str != null)
                values = str.Split(jointChar1);

            if (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);
        }
示例#5
0
        public override void Setup_BeforeAdd(XML xml)
        {
            string str;
            string type = xml.GetAttribute("type");
            if (type != null && type != "empty")
            {
                _shape = new Shape();
                _shape.gOwner = this;
                displayObject = _shape;
            }

            base.Setup_BeforeAdd(xml);

            if (_shape != null)
            {
                int lineSize;
                str = xml.GetAttribute("lineSize");
                if (str != null)
                    lineSize = int.Parse(str);
                else
                    lineSize = 1;

                Color lineColor;
                str = xml.GetAttribute("lineColor");
                if (str != null)
                    lineColor = ToolSet.ConvertFromHtmlColor(str);
                else
                    lineColor = Color.black;

                Color fillColor;
                str = xml.GetAttribute("fillColor");
                if (str != null)
                    fillColor = ToolSet.ConvertFromHtmlColor(str);
                else
                    fillColor = Color.white;

                if (type == "rect")
                    DrawRect(this.width, this.height, lineSize, lineColor, fillColor);
                else
                    DrawEllipse(this.width, this.height, fillColor);
            }
        }
示例#6
0
        void LoadMovieClip(PackageItem item)
        {
            string str = _descPack[item.id + ".xml"];
            XML xml = new XML(str);
            string[] arr = null;

            str = xml.GetAttribute("interval");
            if (str != null)
                item.interval = float.Parse(str) / 1000f;
            item.swing = xml.GetAttributeBool("swing", false);
            str = xml.GetAttribute("repeatDelay");
            if (str != null)
                item.repeatDelay = float.Parse(str) / 1000f;
            int frameCount = xml.GetAttributeInt("frameCount");
            item.frames = new MovieClip.Frame[frameCount];

            int i = 0;
            string spriteId;
            XML frameNode;
            MovieClip.Frame frame;
            AtlasSprite sprite;

            XMLList.Enumerator et = xml.GetNode("frames").GetEnumerator();
            while (et.MoveNext())
            {
                frameNode = et.Current;
                frame = new MovieClip.Frame();

                arr = frameNode.GetAttributeArray("rect");
                frame.rect = new Rect(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
                str = frameNode.GetAttribute("addDelay");
                if (str != null)
                    frame.addDelay = float.Parse(str) / 1000f;

                str = frameNode.GetAttribute("sprite");
                if (str != null)
                    spriteId = item.id + "_" + str;
                else if (frame.rect.width != 0)
                    spriteId = item.id + "_" + i;
                else
                    spriteId = null;

                if (spriteId != null && _sprites.TryGetValue(spriteId, out sprite))
                {
                    PackageItem atlasItem = _itemsById[sprite.atlas];
                    if (atlasItem != null)
                    {
                        if (item.texture == null)
                            item.texture = (NTexture)GetItemAsset(atlasItem);
                        frame.uvRect = new Rect(sprite.rect.x / item.texture.width * item.texture.uvRect.width,
                            1 - sprite.rect.yMax * item.texture.uvRect.height / item.texture.height,
                            sprite.rect.width * item.texture.uvRect.width / item.texture.width,
                            sprite.rect.height * item.texture.uvRect.height / item.texture.height);
                    }
                }
                item.frames[i] = frame;
                i++;
            }
        }
示例#7
0
        void LoadPackage()
        {
            string[] arr = null;
            string str;

            str = LoadString("sprites.bytes");
            if (str == null)
            {
                Debug.LogError("FairyGUI: cannot load package from " + _assetNamePrefix);
                return;
            }
            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;
            }

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

            str = _descPack["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.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(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;
                        }

                    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;
            }
        }
示例#8
0
        public virtual void Setup_AfterAdd(XML xml)
        {
            string str;

            str = xml.GetAttribute("group");
            if (str != null)
                group = parent.GetChildById(str) as GGroup;

            XMLList.Enumerator et = xml.GetEnumerator();
            XML cxml;
            int index;
            while (et.MoveNext())
            {
                cxml = et.Current;
                if (GearXMLKeys.TryGetValue(cxml.name, out index))
                    GetGear(index).Setup(cxml);
            }
        }
示例#9
0
        void LoadMovieClip(PackageItem item)
        {
            string str = GetDesc(item.id + ".xml");
            XML xml = new XML(str);
            string[] arr = null;

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                item.pivot.x = int.Parse(arr[0]);
                item.pivot.y = int.Parse(arr[1]);
            }
            str = xml.GetAttribute("interval");
            if (str != null)
                item.interval = float.Parse(str) / 1000f;
            item.swing = xml.GetAttributeBool("swing", false);
            str = xml.GetAttribute("repeatDelay");
            if (str != null)
                item.repeatDelay = float.Parse(str) / 1000f;
            int frameCount = xml.GetAttributeInt("frameCount");
            item.frames = new Frame[frameCount];

            XMLList frameNodes = xml.GetNode("frames").Elements();

            int i = 0;
            foreach (XML frameNode in frameNodes)
            {
                Frame frame = new Frame();
                arr = frameNode.GetAttributeArray("rect");
                frame.rect = new Rect(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
                str = frameNode.GetAttribute("addDelay");
                if (str != null)
                    frame.addDelay = float.Parse(str) / 1000f;

                AtlasSprite sprite;
                if (_sprites.TryGetValue(item.id + "_" + i, out sprite))
                    frame.texture = CreateSpriteTexture(sprite);
                item.frames[i] = frame;
                i++;
            }
        }
示例#10
0
        private GObject ConstructChild(XML xml)
        {
            string pkgId = xml.GetAttribute("pkg");
            UIPackage thisPkg = _packageItem.owner;
            UIPackage pkg;
            if (pkgId != null && pkgId != thisPkg.id)
            {
                pkg = UIPackage.GetById(pkgId);
                if (pkg == null)
                    return null;
            }
            else
                pkg = thisPkg;

            string src = xml.GetAttribute("src");
            if (src != null)
            {
                PackageItem pi = pkg.GetItem(src);
                if (pi == null)
                    return null;

                GObject g = pkg.CreateObject(pi, null);
                return g;
            }
            else
            {
                GObject g;
                if (xml.name == "text" && xml.GetAttributeBool("input", false))
                    g = new GTextInput();
                else
                    g = UIObjectFactory.NewObject(xml.name);
                return g;
            }
        }
示例#11
0
        public override 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);
        }
示例#12
0
        public override void Setup_AfterAdd(XML xml)
        {
            base.Setup_AfterAdd(xml);

            XML cxml = xml.GetNode("gearColor");
            if (cxml != null)
                gearColor.Setup(cxml);

            UpdateTextFormat();

            string str = xml.GetAttribute("text");
            if (str != null && str.Length > 0)
                this.text = str;
        }
        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();
        }
示例#14
0
        public void Setup(XML xml)
        {
            string[] arr;

            name = xml.GetAttribute("name");
            autoRadioGroupDepth = xml.GetAttributeBool("autoRadioGroupDepth");

            arr = xml.GetAttributeArray("pages");
            if (arr != null)
            {
                int cnt = arr.Length;
                for (int i = 0; i < cnt; i += 2)
                {
                    _pageIds.Add(arr[i]);
                    _pageNames.Add(arr[i + 1]);
                }
            }

            arr = xml.GetAttributeArray("transitions");
            if (arr != null)
            {
                _pageTransitions = new List<PageTransition>();

                int cnt = arr.Length;
                for (int i = 0; i < cnt; i++)
                {
                    string str = arr[i];

                    PageTransition pt = new PageTransition();
                    int k = str.IndexOf("=");
                    pt.transitionName = str.Substring(k + 1);
                    str = str.Substring(0, k);
                    k = str.IndexOf("-");
                    pt.toIndex = int.Parse(str.Substring(k + 1));
                    str = str.Substring(0, k);
                    if (str == "*")
                        pt.fromIndex = -1;
                    else
                        pt.fromIndex = int.Parse(str);
                    _pageTransitions.Add(pt);
                }
            }

            if (parent != null && _pageIds.Count >= 0)
                _selectedIndex = 0;
            else
                _selectedIndex = -1;
        }
示例#15
0
        public virtual void Setup_AfterAdd(XML xml)
        {
            XML cxml = null;
            string str;

            str = xml.GetAttribute("group");
            if (str != null)
                group = parent.GetChildById(str) as GGroup;

            cxml = xml.GetNode("gearDisplay");
            if (cxml != null)
                gearDisplay.Setup(cxml);

            cxml = xml.GetNode("gearXY");
            if (cxml != null)
                gearXY.Setup(cxml);

            cxml = xml.GetNode("gearSize");
            if (cxml != null)
                gearSize.Setup(cxml);

            cxml = xml.GetNode("gearLook");
            if (cxml != null)
                gearLook.Setup(cxml);
        }
示例#16
0
        public virtual void Setup_BeforeAdd(XML xml)
        {
            string str;
            string[] arr;

            id = xml.GetAttribute("id");
            name = xml.GetAttribute("name");

            arr = xml.GetAttributeArray("xy");
            if (arr != null)
                this.SetXY(int.Parse(arr[0]), int.Parse(arr[1]));

            arr = xml.GetAttributeArray("size");
            if (arr != null)
            {
                initWidth = int.Parse(arr[0]);
                initHeight = int.Parse(arr[1]);
                SetSize(initWidth, initHeight);
            }

            arr = xml.GetAttributeArray("scale");
            if (arr != null)
                SetScale(float.Parse(arr[0]), float.Parse(arr[1]));

            str = xml.GetAttribute("rotation");
            if (str != null)
                this.rotation = int.Parse(str);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
                this.SetPivot(int.Parse(arr[0]), int.Parse(arr[1]));

            str = xml.GetAttribute("alpha");
            if (str != null)
                this.alpha = float.Parse(str);

            this.touchable = xml.GetAttributeBool("touchable", true);
            this.visible = xml.GetAttributeBool("visible", true);
            this.grayed = xml.GetAttributeBool("grayed", false);
            str = xml.GetAttribute("tooltips");
            if (str != null)
                this.tooltips = str;
        }
示例#17
0
        public override 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);
        }
示例#18
0
        public override 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);

            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();
        }
示例#19
0
文件: GImage.cs 项目: yinlei/Fishing
        public override 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);

            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;
            }
        }
示例#20
0
        public override 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);
            }
        }
示例#21
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);
            }
        }
示例#22
0
        public override 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();
        }
示例#23
0
        void LoadPackage()
        {
            string[] arr = null;
            string str;

            str = LoadString("sprites.bytes");
            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;
            }
        }
示例#24
0
        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");
                }
            }
        }
示例#25
0
        public override void Setup_BeforeAdd(Utils.XML xml)
        {
            base.Setup_BeforeAdd(xml);

            _promptText = xml.GetAttribute("prompt");
        }
示例#26
0
        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            string[] arr;

            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;

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(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]));

            _lineGap = xml.GetAttributeInt("lineGap");
            _columnGap = xml.GetAttributeInt("colGap");
            _lineItemCount = xml.GetAttributeInt("lineItemCount");
            defaultItem = xml.GetAttribute("defaultItem");

            autoResizeItem = xml.GetAttributeBool("autoItemSize", true);

            XMLList.Enumerator et = xml.GetEnumerator("item");
            while (et.MoveNext())
            {
                XML ix = et.Current;
                string url = ix.GetAttribute("url");
                if (string.IsNullOrEmpty(url))
                {
                    url = defaultItem;
                    if (string.IsNullOrEmpty(url))
                        continue;
                }

                GObject obj = GetFromPool(url);
                if (obj != null)
                {
                    AddChild(obj);
                    str = ix.GetAttribute("title");
                    if (str != null)
                        obj.text = str;
                    str = ix.GetAttribute("icon");
                    if (str != null)
                        obj.icon = str;
                    str = ix.GetAttribute("name");
                    if (str != null)
                        obj.name = str;
                }
            }
        }
示例#27
0
        public virtual void Setup_BeforeAdd(XML xml)
        {
            string str;
            string[] arr;

            id = xml.GetAttribute("id");
            name = xml.GetAttribute("name");

            arr = xml.GetAttributeArray("xy");
            if (arr != null)
                this.SetXY(int.Parse(arr[0]), int.Parse(arr[1]));

            arr = xml.GetAttributeArray("size");
            if (arr != null)
            {
                initWidth = int.Parse(arr[0]);
                initHeight = int.Parse(arr[1]);
                SetSize(initWidth, initHeight, true);
            }

            arr = xml.GetAttributeArray("scale");
            if (arr != null)
                SetScale(float.Parse(arr[0]), float.Parse(arr[1]));

            arr = xml.GetAttributeArray("skew");
            if (arr != null)
                this.skew = new Vector2(float.Parse(arr[0]), float.Parse(arr[1]));

            str = xml.GetAttribute("rotation");
            if (str != null)
                this.rotation = int.Parse(str);

            arr = xml.GetAttributeArray("pivot");
            if (arr != null)
            {
                float f1 = float.Parse(arr[0]);
                float f2 = float.Parse(arr[1]);
                //处理旧版本的兼容性(旧版本发布的值是坐标值,新版本是比例,一般都小于2)
                if (f1 > 2)
                {
                    if (sourceWidth != 0)
                        f1 = f1 / sourceWidth;
                    else
                        f1 = 0;
                }
                if (f2 > 2)
                {
                    if (sourceHeight != 0)
                        f2 = f2 / sourceHeight;
                    else
                        f2 = 0;
                }
                this.SetPivot(f1, f2, xml.GetAttributeBool("anchor"));
            }
            else
                this.SetPivot(0, 0, false);

            str = xml.GetAttribute("alpha");
            if (str != null)
                this.alpha = float.Parse(str);

            this.touchable = xml.GetAttributeBool("touchable", true);
            this.visible = xml.GetAttributeBool("visible", true);
            this.grayed = xml.GetAttributeBool("grayed", false);

            str = xml.GetAttribute("blend");
            if (str != null)
                this.blendMode = FieldTypes.ParseBlendMode(str);

            str = xml.GetAttribute("filter");
            if (str != null)
            {
                switch (str)
                {
                    case "color":
                        ColorFilter cf = new ColorFilter();
                        this.filter = cf;
                        arr = xml.GetAttributeArray("filterData");
                        cf.AdjustBrightness(float.Parse(arr[0]));
                        cf.AdjustContrast(float.Parse(arr[1]));
                        cf.AdjustSaturation(float.Parse(arr[2]));
                        cf.AdjustHue(float.Parse(arr[3]));
                        break;
                }
            }

            str = xml.GetAttribute("tooltips");
            if (str != null)
                this.tooltips = str;
        }
示例#28
0
        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 && values != null)
                {
                    for (int i = 0; i < values.Length; i++)
                        AddStatus(pages[i], values[i]);
                }
                str = xml.GetAttribute("default");
                if (str != null)
                    AddStatus(null, str);
            }
        }
示例#29
0
        void LoadMovieClip(PackageItem item)
        {
            string str = _descPack[item.id + ".xml"];
            XML xml = new XML(str);
            string[] arr = null;

            str = xml.GetAttribute("interval");
            if (str != null)
                item.interval = float.Parse(str) / 1000f;
            item.swing = xml.GetAttributeBool("swing", false);
            str = xml.GetAttribute("repeatDelay");
            if (str != null)
                item.repeatDelay = float.Parse(str) / 1000f;
            int frameCount = xml.GetAttributeInt("frameCount");
            item.frames = new MovieClip.Frame[frameCount];

            XMLList frameNodes = xml.GetNode("frames").Elements();

            int i = 0;
            foreach (XML frameNode in frameNodes)
            {
                MovieClip.Frame frame = new MovieClip.Frame();
                arr = frameNode.GetAttributeArray("rect");
                frame.rect = new Rect(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
                str = frameNode.GetAttribute("addDelay");
                if (str != null)
                    frame.addDelay = float.Parse(str) / 1000f;

                AtlasSprite sprite;
                if (_sprites.TryGetValue(item.id + "_" + i, out sprite))
                {
                    PackageItem atlasItem = _itemsById[sprite.atlas];
                    if (atlasItem != null)
                    {
                        if (item.texture == null)
                            item.texture = (NTexture)GetItemAsset(atlasItem);
                        frame.uvRect = new Rect(sprite.rect.x / item.texture.width * item.texture.uvRect.width,
                            1 - sprite.rect.yMax * item.texture.uvRect.height / item.texture.height,
                            sprite.rect.width * item.texture.uvRect.width / item.texture.width,
                            sprite.rect.height * item.texture.uvRect.height / item.texture.height);
                    }
                }
                item.frames[i] = frame;
                i++;
            }
        }
示例#30
0
        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);
                }
            }
        }