static public int ReadString(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { FairyGUI.Utils.ByteBuffer self = (FairyGUI.Utils.ByteBuffer)checkSelf(l); var ret = self.ReadString(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { FairyGUI.Utils.ByteBuffer self = (FairyGUI.Utils.ByteBuffer)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); var ret = self.ReadString(a1); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
/// <summary> /// /// </summary> /// <returns></returns> public bool GetNextEntry(ZipEntry entry) { if (_index >= _entryCount) { return(false); } _stream.position = _pos + 28; int len = _stream.ReadUshort(); int len2 = _stream.ReadUshort() + _stream.ReadUshort(); _stream.position = _pos + 46; string name = _stream.ReadString(len); name = name.Replace("\\", "/"); entry.name = name; if (name[name.Length - 1] == '/') //directory { entry.isDirectory = true; entry.compress = 0; entry.crc = 0; entry.size = entry.sourceSize = 0; entry.offset = 0; } else { entry.isDirectory = false; _stream.position = _pos + 10; entry.compress = _stream.ReadUshort(); _stream.position = _pos + 16; entry.crc = _stream.ReadUint(); entry.size = _stream.ReadInt(); entry.sourceSize = _stream.ReadInt(); _stream.position = _pos + 42; entry.offset = _stream.ReadInt() + 30 + len; } _pos += 46 + len + len2; _index++; return(true); }
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; } }