public static SpriteFont Read(string resName) { try { List<RectBox> xGlyphs = new List<RectBox>(), xCropping = new List<RectBox>(); List<Char> xChars = new List<Char>(); int xSpacingV; float xSpacingH; List<float[]> xKerning = new List<float[]>(); ArrayByte arrays = new ArrayByte(Resources.OpenResource(resName), ArrayByte.BIG_ENDIAN); int size = arrays.ReadInt(); LImage image = LImage.CreateImage(arrays.ReadByteArray(size)); int count = arrays.ReadInt(); while (count-- > 0) { xGlyphs.Add(new RectBox(arrays.ReadInt(), arrays.ReadInt(), arrays.ReadInt(), arrays.ReadInt())); xCropping.Add(new RectBox(arrays.ReadInt(), arrays.ReadInt(), arrays.ReadInt(), arrays.ReadInt())); xChars.Add((char)arrays.ReadInt()); } xSpacingV = arrays.ReadInt(); xSpacingH = arrays.ReadFloat(); count = arrays.ReadInt(); while (count-- > 0) { xKerning.Add(new float[] { arrays.ReadFloat(), arrays.ReadFloat(), arrays.ReadFloat() }); } arrays.Dispose(); return new SpriteFont(new LTexture(GLLoader.GetTextureData(image), Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR), xGlyphs, xCropping, xChars, xSpacingV, xSpacingH, xKerning, 'A'); } catch (Exception e) { Loon.Utils.Debugging.Log.Exception(e); } return null; }
public static LPKTable[] ReadLPKTable(ArrayByte dis, int fileTableNumber) { LPKTable[] fileTable = new LPKTable[fileTableNumber]; for (int i = 0; i < fileTableNumber; i++) { LPKTable ft = new LPKTable(); ft.SetFileName(dis.ReadByteArray(LPKHeader.LF_FILE_LENGTH)); ft.SetFileSize(dis.ReadLong()); ft.SetOffSet(dis.ReadLong()); fileTable[i] = ft; } return fileTable; }
public static LPKHeader ReadHeader(ArrayByte dis) { LPKHeader header = new LPKHeader(); header.SetPAKIdentity(dis.ReadInt()); byte[] pass = dis.ReadByteArray(LPKHeader.LF_PASSWORD_LENGTH); header.SetPassword(pass); header.SetVersion(dis.ReadFloat()); header.SetTables(dis.ReadLong()); return header; }