Example #1
0
        private static Vector4 GetBorder(string def, string name)
        {
            XML     xml       = new XML(def);
            XML     resources = xml.GetNode("packageDescription").GetNode("resources");
            XMLList nodes     = resources.Elements("image");

            foreach (XML node in nodes)
            {
                string id = node.GetAttribute("id");
                if (!id.Equals(name))
                {
                    continue;
                }
                if (node.GetAttribute("scale", string.Empty) != "9grid")
                {
                    break;
                }
                string[] s      = node.GetAttributeArray("size");
                string[] v      = node.GetAttributeArray("scale9grid");
                float    left   = float.Parse(v[0]);
                float    top    = float.Parse(v[1]);
                float    width  = float.Parse(v[2]);
                float    height = float.Parse(v[3]);
                float    right  = float.Parse(s[0]) - (left + width);
                float    bottom = float.Parse(s[1]) - (top + height);
                return(new Vector4(left, bottom, right, top));
            }
            return(Vector4.zero);
        }
Example #2
0
        public void Setup(XML xml)
        {
            XMLList col = xml.Elements("relation");
            if (col == null)
                return;

            string targetId;
            GObject target;
            foreach (XML cxml in col)
            {
                targetId = cxml.GetAttribute("target");
                if (_owner.parent != null)
                {
                    if (targetId != null && targetId != "")
                        target = _owner.parent.GetChildById(targetId);
                    else
                        target = _owner.parent;
                }
                else
                {
                    //call from component construction
                    target = ((GComponent)_owner).GetChildById(targetId);
                }
                if (target != null)
                    AddItems(target, cxml.GetAttribute("sidePair"));
            }
        }
Example #3
0
        public void Parse(string text)
        {
            XML     xml      = new XML(text);
            XMLList dtoNodes = xml.Elements("structs")[0].Elements();

            foreach (XML dtoNode in dtoNodes)              //parse structs
            {
                if (!this.CreateStruct(ushort.Parse(dtoNode.GetAttribute("id")), dtoNode.GetAttribute("name"), out DTOEntry dto))
                {
                    this.ParseField(dto, dtoNode, dtoNodes);
                }
            }
            XMLList moduleNodes = xml.Elements("modules")[0].Elements();

            foreach (XML moduleNode in moduleNodes)               //parse modules
            {
                ModuleEntry module = new ModuleEntry();
                module.id  = moduleNode.GetAttribute("id");
                module.key = moduleNode.GetAttribute("key");
                this._modules.Add(module);

                XMLList packetNodes = moduleNode.Elements();
                foreach (XML packetNode in packetNodes)                   //parse packets
                {
                    PacketEntry packet = new PacketEntry(module);
                    packet.id  = packetNode.GetAttribute("cmd");
                    packet.key = packetNode.GetAttribute("key");
                    packet.dto = this.FindDTO(packetNode.GetAttribute("struct"));
                    module.packets.Add(packet);
                }
            }
        }
        public static void SetStringsSource(XML source)
        {
            _stringsSource = new Dictionary <string, Dictionary <string, string> >();
            XMLList list = source.Elements("string");

            foreach (XML cxml in list)
            {
                string key  = cxml.GetAttribute("name");
                string text = cxml.text;
                int    i    = key.IndexOf("-");
                if (i == -1)
                {
                    continue;
                }

                string key2 = key.Substring(0, i);
                string key3 = key.Substring(i + 1);
                Dictionary <string, string> col = _stringsSource[key2];
                if (col == null)
                {
                    col = new Dictionary <string, string>();
                    _stringsSource[key2] = col;
                }
                col[key3] = text;
            }
        }
Example #5
0
        public HttpResponseMessage Get()
        {
            var api  = Api.INSTANCE;
            var user = api.RequireAuthentication(Request);

            var result = new XMLList <AvatarData>("The-Sims-Online");

            using (var db = api.DAFactory.Get())
            {
                var avatars = db.Avatars.GetSummaryByUserId(user.UserID);

                foreach (var avatar in avatars)
                {
                    result.Add(new AvatarData
                    {
                        ID             = avatar.avatar_id,
                        Name           = avatar.name,
                        ShardName      = api.Shards.GetById(avatar.shard_id).Name,
                        HeadOutfitID   = avatar.head,
                        BodyOutfitID   = avatar.body,
                        AppearanceType = (AvatarAppearanceType)Enum.Parse(typeof(AvatarAppearanceType), avatar.skin_tone.ToString()),
                        Description    = avatar.description,
                        LotId          = avatar.lot_id,
                        LotName        = avatar.lot_name,
                        LotLocation    = avatar.lot_location
                    });
                }
            }

            return(ApiResponse.Xml(HttpStatusCode.OK, result));
        }
Example #6
0
        public void Setup(XML xml)
        {
            XMLList col = xml.Elements("relation");

            if (col == null)
            {
                return;
            }

            foreach (XML cxml in col)
            {
                string  targetId = cxml.GetAttribute("target");
                GObject target;
                if (this._owner.parent != null)
                {
                    target = !string.IsNullOrEmpty(targetId) ? this._owner.parent.GetChildById(targetId) : this._owner.parent;
                }
                else
                {
                    //call from component construction
                    target = (( GComponent )this._owner).GetChildById(targetId);
                }
                if (target != null)
                {
                    this.AddItems(target, cxml.GetAttribute("sidePair"));
                }
            }
        }
Example #7
0
    public XMLList Filter(string selector)
    {
        bool allFit = true;

        _tmpList.Clear();
        int cnt = rawList.Count;

        for (int i = 0; i < cnt; i++)
        {
            XML xml = rawList[i];
            if (xml.name == selector)
            {
                _tmpList.Add(xml);
            }
            else
            {
                allFit = false;
            }
        }

        if (allFit)
        {
            return(this);
        }
        else
        {
            XMLList ret = new XMLList(_tmpList);
            _tmpList = new List <XML>();
            return(ret);
        }
    }
Example #8
0
 public XMLList Elements(string selector)
 {
     if (_children == null)
     {
         _children = new XMLList();
     }
     return(_children.Filter(selector));
 }
Example #9
0
 public XMLList Elements()
 {
     if (_children == null)
     {
         _children = new XMLList();
     }
     return(_children);
 }
        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++;
            }
        }
Example #11
0
 private static XML FindId(XMLList root, string selector)
 {
     foreach (XML xml in root)
     {
         if (xml.GetAttribute("name") == selector)
         {
             return(xml);
         }
     }
     return(null);
 }
        public IActionResult Get()
        {
            var api = Api.INSTANCE;

            var result = new XMLList <ShardStatusItem>("Shard-Status-List");
            var shards = api.Shards.All;

            foreach (var shard in shards)
            {
                result.Add(shard);
            }
            return(ApiResponse.Xml(HttpStatusCode.OK, result));
        }
Example #13
0
        private void ParseInternalStructs()
        {
            XML     xml      = new XML(Resources.internal_structs);
            XMLList dtoNodes = xml.Elements("structs")[0].Elements();

            foreach (XML dtoNode in dtoNodes)
            {
                if (!this.CreateStruct(ushort.Parse(dtoNode.GetAttribute("id")), dtoNode.GetAttribute("name"), true, out DTOEntry dto))
                {
                    this.ParseField(dto, dtoNode, dtoNodes);
                }
            }
        }
Example #14
0
        void LoadMovieClip(PackageItem item)
        {
            string str = GetDesc(item.id + ".xml");
            XML    xml = new XML(str);

            string[] 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++;
            }
        }
Example #15
0
        private void ExportDisplay(XML dataXml, string[] _path)
        {
            XMLList childrens = dataXml.Elements();

            foreach (XML child in childrens)
            {
                var typeName     = child.name;
                var attrbuteName = child.GetAttribute("name");

                if (typeName == "text")
                {
                    if (child.GetAttributeBool("input"))
                    {
                        panel.AddComponentScript(new ComponentScript(ComponentType.TextInput, attrbuteName, _path));
                    }
                    else
                    {
                        panel.AddComponentScript(new ComponentScript(ComponentType.Text, attrbuteName, _path));
                    }
                }
                else if (typeName == "richtext")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Richtext, attrbuteName, _path));
                }
                else if (typeName == "loader")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Loader, attrbuteName, _path));
                }
                else if (typeName == "image")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Image, attrbuteName, _path));
                }
                else if (typeName == "graph")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Graph, attrbuteName, _path));
                }
                else if (typeName == "list")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.List, attrbuteName, _path));
                }
                else if (typeName == "group")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Group, attrbuteName, _path));
                }
                else if (typeName == "component")
                {
                    ExportComponent(child, _path);
                }
            }
        }
        override public void Setup_AfterAdd(XML cxml)
        {
            base.Setup_AfterAdd(cxml);

            XML xml = cxml.GetNode("ComboBox");

            if (xml == null)
            {
                return;
            }

            string str;

            str = xml.GetAttribute("titleColor");
            if (str != null)
            {
                this.titleColor = ToolSet.ConvertFromHtmlColor(str);
            }
            visibleItemCount = xml.GetAttributeInt("visibleItemCount", visibleItemCount);
            _popupDirection  = xml.GetAttribute("direction", _popupDirection);

            XMLList col = xml.Elements("item");

            _items  = new string[col.Count];
            _values = new string[col.Count];
            int i = 0;

            foreach (XML ix in col)
            {
                _items[i]  = ix.GetAttribute("title");
                _values[i] = ix.GetAttribute("value");
                i++;
            }

            str = xml.GetAttribute("title");
            if (str != null && str.Length > 0)
            {
                this.text      = str;
                _selectedIndex = Array.IndexOf(_items, str);
            }
            else if (_items.Length > 0)
            {
                _selectedIndex = 0;
                this.text      = _items[0];
            }
            else
            {
                _selectedIndex = -1;
            }
        }
Example #17
0
        public void Setup(XML xml)
        {
            this.name = xml.GetAttribute("name");
            _options  = xml.GetAttributeInt("options");
            XMLList col = xml.Elements("item");

            foreach (XML cxml in col)
            {
                TransitionItem item = new TransitionItem();
                _items.Add(item);

                item.time     = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE;
                item.targetId = cxml.GetAttribute("target", string.Empty);
                item.type     = FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type"));
                item.tween    = cxml.GetAttributeBool("tween");
                item.label    = cxml.GetAttribute("label");
                if (item.tween)
                {
                    item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE;

                    string ease = cxml.GetAttribute("ease");
                    if (ease != null)
                    {
                        item.easeType = FieldTypes.ParseEaseType(ease);
                    }

                    item.repeat = cxml.GetAttributeInt("repeat");
                    item.yoyo   = cxml.GetAttributeBool("yoyo");
                    item.label2 = cxml.GetAttribute("label2");

                    string v = cxml.GetAttribute("endValue");
                    if (v != null)
                    {
                        DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue);
                        DecodeValue(item.type, v, item.endValue);
                    }
                    else
                    {
                        item.tween = false;
                        DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value);
                    }
                }
                else
                {
                    DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value);
                }
            }
        }
Example #18
0
        public List <ShardStatusItem> ShardStatus()
        {
            var client = Client();

            var request = new RestRequest("cityselector/shard-status.jsp");

            var response = client.Execute(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new Exception("Unknown error during ShardStatus");
            }

            var aotDummy = new XMLList <ShardStatusItem>();
            List <ShardStatusItem> result = (List <ShardStatusItem>)XMLUtils.Parse <XMLList <ShardStatusItem> >(response.Content);

            return(result);
        }
Example #19
0
        public List <AvatarData> AvatarDataServlet()
        {
            var client = Client();

            var request = new RestRequest("cityselector/app/AvatarDataServlet");

            var response = client.Execute(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new Exception("Unknown error during AvatarDataServlet");
            }

            var aotDummy             = new XMLList <AvatarData>();
            List <AvatarData> result = (List <AvatarData>)XMLUtils.Parse <XMLList <AvatarData> >(response.Content);

            return(result);
        }
Example #20
0
		void LoadComponentChildren(PackageItem item)
		{
			XML listNode = item.componentData.GetNode("displayList");
			if (listNode != null)
			{
				XMLList col = listNode.Elements();
				int dcnt = col.Count;
				item.displayList = new DisplayListItem[dcnt];
				DisplayListItem di;
				for (int i = 0; i < dcnt; i++)
				{
					XML cxml = col[i];

					string src = cxml.GetAttribute("src");
					if (src != null)
					{
						string pkgId = cxml.GetAttribute("pkg");
						UIPackage pkg;
						if (pkgId != null && pkgId != item.owner.id)
							pkg = UIPackage.GetById(pkgId);
						else
							pkg = item.owner;

						PackageItem pi = pkg != null ? pkg.GetItem(src) : null;
						if (pi != null)
							di = new DisplayListItem(pi, null);
						else
							di = new DisplayListItem(null, cxml.name);
					}
					else
					{
						if (cxml.name == "text" && cxml.GetAttributeBool("input", false))
							di = new DisplayListItem(null, "inputtext");
						else
							di = new DisplayListItem(null, cxml.name);
					}

					di.desc = cxml;
					item.displayList[i] = di;
				}
			}
			else
				item.displayList = new DisplayListItem[0];
		}
Example #21
0
        private void ParseField(IFieldHolder parent, XML parentNode, XMLList nodeElements)
        {
            XMLList fieldNodes = parentNode.Elements();

            foreach (XML fieldNode in fieldNodes)               //parse packets
            {
                switch (fieldNode.name)
                {
                case "field":
                    FieldEntry field = new FieldEntry();
                    field.id   = fieldNode.GetAttribute("id");
                    field.type = fieldNode.GetAttribute("type");
                    parent.AddField(field);
                    if (field.type == "alist")
                    {
                        string dtoName    = fieldNode.GetAttribute("struct");
                        XML    subDTONode = FindId(nodeElements, dtoName);
                        if (!this.CreateStruct(ushort.Parse(subDTONode.GetAttribute("id")), dtoName, false, out DTOEntry subDTO))
                        {
                            this.ParseField(subDTO, subDTONode, nodeElements);
                        }
                        field.subDTO = subDTO;
                    }
                    break;

                case "conditions":
                    XMLList conditionNodes = fieldNode.Elements();
                    foreach (XML conditionNode in conditionNodes)
                    {
                        Condition condition = new Condition(parent);
                        condition.key    = conditionNode.GetAttribute("key");
                        condition.values = conditionNode.GetAttribute("value").Split(',');
                        parent.conditions.Add(condition);
                        this.ParseField(condition, conditionNode, nodeElements);
                    }
                    break;
                }
            }
        }
Example #22
0
        private void Export(XML dataXml, string[] _path)
        {
            XMLList childrens = dataXml.Elements();

            foreach (XML child in childrens)
            {
                var typeName     = child.name;
                var attrbuteName = child.GetAttribute("name");

                if (typeName == "controller")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Controller, attrbuteName, _path));
                }
                else if (typeName == "transition")
                {
                    panel.AddComponentScript(new ComponentScript(ComponentType.Transition, attrbuteName, _path));
                }
                else if (typeName == "displayList")
                {
                    ExportDisplay(child, _path);
                }
            }
        }
Example #23
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 #24
0
        override public void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;

            str = xml.GetAttribute("layout");
            if (str != null)
            {
                _layout = FieldTypes.ParseListLayoutType(str);
            }
            else
            {
                _layout = ListLayoutType.SingleColumn;
            }

            str = xml.GetAttribute("selectionMode");
            if (str != null)
            {
                selectionMode = FieldTypes.ParseListSelectionMode(str);
            }
            else
            {
                selectionMode = ListSelectionMode.Single;
            }

            OverflowType overflow;

            str = xml.GetAttribute("overflow");
            if (str != null)
            {
                overflow = FieldTypes.ParseOverflowType(str);
            }
            else
            {
                overflow = OverflowType.Visible;
            }

            ScrollType scroll;

            str = xml.GetAttribute("scroll");
            if (str != null)
            {
                scroll = FieldTypes.ParseScrollType(str);
            }
            else
            {
                scroll = ScrollType.Vertical;
            }

            ScrollBarDisplayType scrollBarDisplay;

            str = xml.GetAttribute("scrollBar");
            if (str != null)
            {
                scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
            }
            else
            {
                scrollBarDisplay = ScrollBarDisplayType.Default;
            }

            int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

            Margin scrollBarMargin = new Margin();

            str = xml.GetAttribute("scrollBarMargin");
            if (str != null)
            {
                scrollBarMargin.Parse(str);
            }

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

            SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags);

            string[] arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
            {
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));
            }

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

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

            XMLList col = xml.Elements("item");

            foreach (XML ix in col)
            {
                string url = ix.GetAttribute("url");
                if (string.IsNullOrEmpty(url))
                {
                    url = defaultItem;
                }
                if (string.IsNullOrEmpty(url))
                {
                    continue;
                }

                GObject obj = AddItemFromPool(url);
                if (obj is GButton)
                {
                    ((GButton)obj).title = ix.GetAttribute("title");
                    ((GButton)obj).icon  = ix.GetAttribute("icon");
                }
                else if (obj is GLabel)
                {
                    ((GLabel)obj).title = ix.GetAttribute("title");
                    ((GLabel)obj).icon  = ix.GetAttribute("icon");
                }
            }
        }
Example #25
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();
        }
Example #26
0
        public CitySelectorController(IDAFactory DAFactory, ApiServerConfiguration config, JWTFactory jwt, IShardsDomain shardsDomain) : base("/cityselector")
        {
            JsonWebToken.JWTTokenAuthentication.Enable(this, jwt);

            var str   = GetServerVersion();
            var split = str.LastIndexOf('-');

            VersionName = str;
            if (split != -1)
            {
                VersionName   = str.Substring(0, split);
                VersionNumber = str.Substring(split + 1);
            }

            try
            {
                using (var file = File.Open("updateUrl.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    var reader = new StreamReader(file);
                    DownloadURL = reader.ReadLine();
                    reader.Close();
                }
            } catch (Exception)
            {
                DownloadURL = ""; // couldn't find info from the watchdog
            }

            //Take the auth ticket, establish trust and then create a cookie (reusing JWT)
            this.Get["/app/InitialConnectServlet"] = _ =>
            {
                var ticketValue = this.Request.Query["ticket"];
                var version     = this.Request.Query["version"];

                if (ticketValue == null)
                {
                    return(Response.AsXml(new XMLErrorMessage(ERROR_MISSING_TOKEN_CODE, ERROR_MISSING_TOKEN_MSG)));
                }

                using (var db = DAFactory.Get())
                {
                    var ticket = db.AuthTickets.Get((string)ticketValue);
                    if (ticket == null)
                    {
                        return(Response.AsXml(new XMLErrorMessage(ERROR_MISSING_TOKEN_CODE, ERROR_MISSING_TOKEN_MSG)));
                    }


                    db.AuthTickets.Delete((string)ticketValue);
                    if (ticket.date + config.AuthTicketDuration < Epoch.Now)
                    {
                        return(Response.AsXml(new XMLErrorMessage(ERROR_EXPIRED_TOKEN_CODE, ERROR_EXPIRED_TOKEN_MSG)));
                    }

                    /** Is it a valid account? **/
                    var user = db.Users.GetById(ticket.user_id);
                    if (user == null)
                    {
                        return(Response.AsXml(new XMLErrorMessage(ERROR_MISSING_TOKEN_CODE, ERROR_MISSING_TOKEN_MSG)));
                    }

                    //Use JWT to create and sign an auth cookies
                    var session = new JWTUserIdentity()
                    {
                        UserID   = user.user_id,
                        UserName = user.username
                    };

                    var token = jwt.CreateToken(session);
                    return(Response.AsXml(new UserAuthorized()
                    {
                        FSOBranch = VersionName,
                        FSOVersion = VersionNumber,
                        FSOUpdateUrl = DownloadURL
                    })
                           .WithCookie("fso", token.Token));
                }
            };

            //Return a list of the users avatars
            this.Get["/app/AvatarDataServlet"] = _ =>
            {
                this.RequiresAuthentication();
                var user = (JWTUserIdentity)this.Context.CurrentUser;

                var result = new XMLList <AvatarData>("The-Sims-Online");

                using (var db = DAFactory.Get())
                {
                    var avatars = db.Avatars.GetSummaryByUserId(user.UserID);

                    foreach (var avatar in avatars)
                    {
                        result.Add(new AvatarData {
                            ID             = avatar.avatar_id,
                            Name           = avatar.name,
                            ShardName      = shardsDomain.GetById(avatar.shard_id).Name,
                            HeadOutfitID   = avatar.head,
                            BodyOutfitID   = avatar.body,
                            AppearanceType = (AvatarAppearanceType)Enum.Parse(typeof(AvatarAppearanceType), avatar.skin_tone.ToString()),
                            Description    = avatar.description,
                            LotId          = avatar.lot_id,
                            LotName        = avatar.lot_name,
                            LotLocation    = avatar.lot_location
                        });
                    }
                }

                return(Response.AsXml(result));
            };

            this.Get["/app/ShardSelectorServlet"] = _ =>
            {
                this.RequiresAuthentication();
                var user = (JWTUserIdentity)this.Context.CurrentUser;

                var shardName = this.Request.Query["shardName"];
                var avatarId  = this.Request.Query["avatarId"];
                if (avatarId == null)
                {
                    //Using 0 to mean no avatar for CAS
                    avatarId = "0";
                }

                using (var db = DAFactory.Get())
                {
                    ShardStatusItem shard = shardsDomain.GetByName(shardName);
                    if (shard != null)
                    {
                        var tryIP = Request.Headers["X-Forwarded-For"].FirstOrDefault();
                        if (tryIP != null)
                        {
                            tryIP = tryIP.Substring(tryIP.LastIndexOf(',') + 1).Trim();
                        }
                        var ip = tryIP ?? this.Request.UserHostAddress;

                        uint avatarDBID = uint.Parse(avatarId);

                        if (avatarDBID != 0)
                        {
                            var avatar = db.Avatars.Get(avatarDBID);
                            if (avatar == null)
                            {
                                //can't join server with an avatar that doesn't exist
                                return(Response.AsXml(new XMLErrorMessage(ERROR_AVATAR_NOT_FOUND_CODE, ERROR_AVATAR_NOT_FOUND_MSG)));
                            }
                            if (avatar.user_id != user.UserID || avatar.shard_id != shard.Id)
                            {
                                //make sure we own the avatar we're trying to connect with
                                LOG.Info("SECURITY: Invalid avatar login attempt from " + ip + ", user " + user.UserID);
                                return(Response.AsXml(new XMLErrorMessage(ERROR_AVATAR_NOT_YOURS_CODE, ERROR_AVATAR_NOT_YOURS_MSG)));
                            }
                        }

                        var ban = db.Bans.GetByIP(ip);
                        if (ban != null || db.Users.GetById(user.UserID)?.is_banned != false)
                        {
                            return(Response.AsXml(new XMLErrorMessage(ERROR_BANNED_CODE, ERROR_BANNED_MSG)));
                        }

                        /** Make an auth ticket **/
                        var ticket = new ShardTicket
                        {
                            ticket_id = Guid.NewGuid().ToString().Replace("-", ""),
                            user_id   = user.UserID,
                            avatar_id = avatarDBID,
                            date      = Epoch.Now,
                            ip        = ip
                        };

                        db.Users.UpdateConnectIP(ticket.user_id, ip);
                        db.Shards.CreateTicket(ticket);

                        var result = new ShardSelectorServletResponse();
                        result.PreAlpha = false;

                        result.Address      = shard.PublicHost;
                        result.PlayerID     = user.UserID;
                        result.Ticket       = ticket.ticket_id;
                        result.ConnectionID = ticket.ticket_id;
                        result.AvatarID     = avatarId;

                        return(Response.AsXml(result));
                    }
                    else
                    {
                        return(Response.AsXml(new XMLErrorMessage(ERROR_SHARD_NOT_FOUND_CODE, ERROR_SHARD_NOT_FOUND_MSG)));
                    }
                }
            };

            //Get a list of shards (cities)
            this.Get["/shard-status.jsp"] = _ =>
            {
                var result = new XMLList <ShardStatusItem>("Shard-Status-List");
                var shards = shardsDomain.All;

                foreach (var shard in shards)
                {
                    var status = Protocol.CitySelector.ShardStatus.Down;

                    /*switch (shard.Status)
                     * {
                     *  case Database.DA.Shards.ShardStatus.Up:
                     *      status = Protocol.CitySelector.ShardStatus.Up;
                     *      break;
                     *  case Database.DA.Shards.ShardStatus.Full:
                     *      status = Protocol.CitySelector.ShardStatus.Full;
                     *      break;
                     *  case Database.DA.Shards.ShardStatus.Frontier:
                     *      status = Protocol.CitySelector.ShardStatus.Frontier;
                     *      break;
                     *  case Database.DA.Shards.ShardStatus.Down:
                     *      status = Protocol.CitySelector.ShardStatus.Down;
                     *      break;
                     *  case Database.DA.Shards.ShardStatus.Closed:
                     *      status = Protocol.CitySelector.ShardStatus.Closed;
                     *      break;
                     *  case Database.DA.Shards.ShardStatus.Busy:
                     *      status = Protocol.CitySelector.ShardStatus.Busy;
                     *      break;
                     * }*/

                    result.Add(shard);
                }

                return(Response.AsXml(result));
            };
        }
Example #27
0
        void LoadPackage()
        {
            string str = this.LoadString("sprites.bytes");

            string[] arr = str.Split(sep1);
            int      cnt = arr.Length;

            for (int i = 1; i < cnt; i++)
            {
                str = arr[i];
                if (str.Length == 0)
                {
                    continue;
                }

                string[]    arr2     = str.Split(sep2);
                AtlasSprite sprite   = new AtlasSprite();
                string      itemId   = arr2[0];
                int         binIndex = int.Parse(arr2[1]);
                if (binIndex >= 0)
                {
                    sprite.atlas = "atlas" + binIndex;
                }
                else
                {
                    int pos = itemId.IndexOf("_");
                    if (pos == -1)
                    {
                        sprite.atlas = "atlas_" + itemId;
                    }
                    else
                    {
                        sprite.atlas = "atlas_" + itemId.Substring(0, pos);
                    }
                }
                sprite.rect.x      = int.Parse(arr2[2]);
                sprite.rect.y      = int.Parse(arr2[3]);
                sprite.rect.width  = int.Parse(arr2[4]);
                sprite.rect.height = int.Parse(arr2[5]);
                sprite.rotated     = arr2[6] == "1";
                _sprites[itemId]   = sprite;
            }

            str = GetDesc("package.xml");
            XML xml = new XML(str);

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

            XML rxml = xml.GetNode("resources");

            if (rxml == null)
            {
                throw new Exception("Invalid package xml");
            }

            XMLList resources = rxml.Elements();

            _itemsById   = new Dictionary <string, PackageItem>();
            _itemsByName = new Dictionary <string, PackageItem>();
            PackageItem pi;

            foreach (XML cxml in resources)
            {
                pi      = new PackageItem();
                pi.type = FieldTypes.ParsePackageItemType(cxml.name);
                pi.id   = cxml.GetAttribute("id");
                pi.name = cxml.GetAttribute("name");
                pi.file = cxml.GetAttribute("file");
                str     = cxml.GetAttribute("size");
                if (str != null)
                {
                    arr       = str.Split(sep0);
                    pi.width  = int.Parse(arr[0]);
                    pi.height = int.Parse(arr[1]);
                }
                switch (pi.type)
                {
                case PackageItemType.Image:
                {
                    string scale = cxml.GetAttribute("scale");
                    if (scale == "9grid")
                    {
                        arr = cxml.GetAttributeArray("scale9grid");
                        if (arr != null)
                        {
                            Rect rect = new Rect();
                            rect.x        = int.Parse(arr[0]);
                            rect.y        = int.Parse(arr[1]);
                            rect.width    = int.Parse(arr[2]);
                            rect.height   = int.Parse(arr[3]);
                            pi.scale9Grid = rect;
                        }
                    }
                    else if (scale == "tile")
                    {
                        pi.scaleByTile = true;
                    }
                    break;
                }
                }
                pi.owner = this;
                _items.Add(pi);
                _itemsById[pi.id] = pi;
                if (pi.name != null)
                {
                    _itemsByName[pi.name] = pi;
                }
            }

            cnt = _items.Count;
            for (int i = 0; i < cnt; i++)
            {
                pi = _items[i];
                if (pi.type == PackageItemType.Font)
                {
                    pi.Load();
                    FontManager.RegisterFont(pi.bitmapFont, null);
                }
                else
                {
                    GetItemAsset(pi);
                }
            }

            if (_resBundle != null)
            {
                _resBundle.Unload(false);
                _resBundle = null;
            }
        }
Example #28
0
        void TranslateComponent(XML xml, Dictionary <string, string> strings)
        {
            XML listNode = xml.GetNode("displayList");

            if (listNode == null)
            {
                return;
            }

            XMLList col = listNode.Elements();

            foreach (XML cxml in col)
            {
                string ename     = cxml.name;
                string elementId = cxml.GetAttribute("id");
                string value;
                if (cxml.hasAttribute("tooltips"))
                {
                    if (strings.TryGetValue(elementId + "-tips", out value))
                    {
                        cxml.SetAttribute("tooltips", value);
                    }
                }

                if (ename == "text" || ename == "richtext")
                {
                    if (strings.TryGetValue(elementId, out value))
                    {
                        cxml.SetAttribute("text", value);
                    }
                }
                else if (ename == "list")
                {
                    XMLList items = cxml.Elements("item");
                    int     j     = 0;
                    foreach (XML exml in items)
                    {
                        if (strings.TryGetValue(elementId + "-" + j, out value))
                        {
                            exml.SetAttribute("title", value);
                        }
                        j++;
                    }
                }
                else if (ename == "component")
                {
                    XML dxml = cxml.GetNode("Button");
                    if (dxml != null)
                    {
                        if (strings.TryGetValue(elementId, out value))
                        {
                            dxml.SetAttribute("title", value);
                        }
                        if (strings.TryGetValue(elementId + "-0", out value))
                        {
                            dxml.SetAttribute("selectedTitle", value);
                        }
                    }
                    else
                    {
                        dxml = cxml.GetNode("Label");
                        if (dxml != null)
                        {
                            if (strings.TryGetValue(elementId, out value))
                            {
                                dxml.SetAttribute("title", value);
                            }
                        }
                        else
                        {
                            dxml = cxml.GetNode("ComboBox");
                            if (dxml != null)
                            {
                                if (strings.TryGetValue(elementId, out value))
                                {
                                    dxml.SetAttribute("title", value);
                                }

                                XMLList items = dxml.Elements("item");
                                int     j     = 0;
                                foreach (XML exml in items)
                                {
                                    if (strings.TryGetValue(elementId + "-" + j, out value))
                                    {
                                        exml.SetAttribute("title", value);
                                    }
                                    j++;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #29
0
        public void Setup(XML xml)
        {
            this.name     = xml.GetAttribute("name");
            this._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();
                this._items.Add(item);

                item.time     = cxml.GetAttributeInt("time") / 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 = cxml.GetAttributeInt("duration") / FRAME_RATE;
                    if (item.time + item.duration > this._maxTime)
                    {
                        this._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)
                    {
                        this.DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue);
                        this.DecodeValue(item.type, v, item.endValue);
                    }
                    else
                    {
                        item.tween = false;
                        this.DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value);
                    }
                }
                else
                {
                    if (item.time > this._maxTime)
                    {
                        this._maxTime = item.time;
                    }
                    this.DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value);
                    if (item.type == TransitionActionType.Shake)
                    {
                        item.tween = true;
                    }
                }
            }
        }
        /// <summary>
        /// Example for the useage of the new XML library
        /// Use the hashtable if you don't need nested XML (like the standard xml responses)
        /// If you need nested XML, use the XMLPair class. The Key-parameter is String.
        /// As value the following types can be used to achieve nesting: XMLPair, XMLPair[] and Hashtable
        /// </summary>
        /// <param name="e"></param>
        /// <param name="h"></param>
        /// <returns></returns>
        private void MultipleXML(Request e, Hashtable returnHashtable)
        {
            returnHashtable.Add("UseTheHashtable", "If you don't need nested XML");

            XMLList Phones = new XMLList("Phones");
            Phones.Attributes.Add("ExampleAttribute1", "NeonMika");
            Phones.Attributes.Add("ExampleAttribute2", 1992);
            XMLList BluePhones = new XMLList("BluePhones");
            XMLList BlackPhones = new XMLList("BlackPhones");
            XMLList MokiaRumia = new XMLList("Phone");
            XMLList LangsumTalaxy = new XMLList("Phone");
            MokiaRumia.Add(new XMLPair("Name", "Mokia Rumia"));
            MokiaRumia.Add(new XMLPair("PhoneNumber", 436603541897));
            XMLList WirelessConnections = new XMLList("WirelessConnections");
            WirelessConnections.Add(new XMLPair("WLAN", true));
            WirelessConnections.Add(new XMLPair("Bluetooth", false));
            MokiaRumia.Add(WirelessConnections);
            WirelessConnections.Clear( );
            WirelessConnections.Add(new XMLPair("WLAN", false));
            WirelessConnections.Add(new XMLPair("Bluetooth", true));
            LangsumTalaxy.Add(new XMLPair("Name", "Langsum Talaxy"));
            LangsumTalaxy.Add(new XMLPair("PhoneNumber", 436603541122));
            LangsumTalaxy.Add(WirelessConnections);

            Phones.Add(MokiaRumia);
            Phones.Add(LangsumTalaxy);

            returnHashtable.Add("Phones", Phones);
        }
Example #31
0
		void LoadPackage()
		{
			string[] arr = null;
			string str;

			str = LoadString("sprites.bytes");
			if (str == null)
			{
				Debug.LogError("FairyGUI: cannot load package from '" + _assetNamePrefix + "'");
				return;
			}

			_loadingPackage = true;

			arr = str.Split('\n');
			int cnt = arr.Length;
			for (int i = 1; i < cnt; i++)
			{
				str = arr[i];
				if (str.Length == 0)
					continue;

				string[] arr2 = str.Split(' ');
				AtlasSprite sprite = new AtlasSprite();
				string itemId = arr2[0];
				int binIndex = int.Parse(arr2[1]);
				if (binIndex >= 0)
					sprite.atlas = "atlas" + binIndex;
				else
				{
					int pos = itemId.IndexOf("_");
					if (pos == -1)
						sprite.atlas = "atlas_" + itemId;
					else
						sprite.atlas = "atlas_" + itemId.Substring(0, pos);
				}
				sprite.rect.x = int.Parse(arr2[2]);
				sprite.rect.y = int.Parse(arr2[3]);
				sprite.rect.width = int.Parse(arr2[4]);
				sprite.rect.height = int.Parse(arr2[5]);
				sprite.rotated = arr2[6] == "1";
				_sprites[itemId] = sprite;
			}

			byte[] hittestData = LoadBinary("hittest.bytes");
			if (hittestData != null)
			{
				ByteBuffer ba = new ByteBuffer(hittestData);
				while (ba.bytesAvailable)
				{
					PixelHitTestData pht = new PixelHitTestData();
					_hitTestDatas[ba.ReadString()] = pht;
					pht.Load(ba);
				}
			}

			if (!_descPack.TryGetValue("package.xml", out str))
				throw new Exception("FairyGUI: invalid package '" + _assetNamePrefix + "'");

			XML xml = new XML(str);

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

			XML rxml = xml.GetNode("resources");
			if (rxml == null)
				throw new Exception("FairyGUI: invalid package xml '" + _assetNamePrefix + "'");

			XMLList resources = rxml.Elements();

			_itemsById = new Dictionary<string, PackageItem>();
			_itemsByName = new Dictionary<string, PackageItem>();
			PackageItem pi;

			foreach (XML cxml in resources)
			{
				pi = new PackageItem();
				pi.owner = this;
				pi.type = FieldTypes.ParsePackageItemType(cxml.name);
				pi.id = cxml.GetAttribute("id");
				pi.name = cxml.GetAttribute("name");
				pi.exported = cxml.GetAttributeBool("exported");
				pi.file = cxml.GetAttribute("file");
				str = cxml.GetAttribute("size");
				if (str != null)
				{
					arr = str.Split(',');
					pi.width = int.Parse(arr[0]);
					pi.height = int.Parse(arr[1]);
				}
				switch (pi.type)
				{
					case PackageItemType.Image:
						{
							string scale = cxml.GetAttribute("scale");
							if (scale == "9grid")
							{
								arr = cxml.GetAttributeArray("scale9grid");
								if (arr != null)
								{
									Rect rect = new Rect();
									rect.x = int.Parse(arr[0]);
									rect.y = int.Parse(arr[1]);
									rect.width = int.Parse(arr[2]);
									rect.height = int.Parse(arr[3]);
									pi.scale9Grid = rect;

									pi.tileGridIndice = cxml.GetAttributeInt("gridTile");
								}
							}
							else if (scale == "tile")
								pi.scaleByTile = true;
							break;
						}

					case PackageItemType.Font:
						{
							pi.bitmapFont = new BitmapFont(pi);
							FontManager.RegisterFont(pi.bitmapFont, null);
							break;
						}
				}
				_items.Add(pi);
				_itemsById[pi.id] = pi;
				if (pi.name != null)
					_itemsByName[pi.name] = pi;
			}

			bool preloadAll = Application.isPlaying;
			if (preloadAll)
			{
				cnt = _items.Count;
				for (int i = 0; i < cnt; i++)
					GetItemAsset(_items[i]);

				_descPack = null;
				_sprites = null;
			}
			else
				_items.Sort(ComparePackageItem);

			if (_resBundle != null)
			{
				_resBundle.Unload(false);
				_resBundle = null;
			}

			_loadingPackage = false;
		}