public Parts(ref BinaryStream s) : base(ref s) { vertexColors = new Color[4]; vertexColors[0] = ColorHelper.BytesToColor(s.ReadBytes(4)); // TL vertexColors[1] = ColorHelper.BytesToColor(s.ReadBytes(4)); // TR vertexColors[2] = ColorHelper.BytesToColor(s.ReadBytes(4)); // BL vertexColors[3] = ColorHelper.BytesToColor(s.ReadBytes(4)); // BR materialIndex = s.ReadUInt16(); texCoordCount = s.Read1Byte(); flags = s.Read1Byte(); texCoords = new TexCoord[texCoordCount]; for (int i = 0; i < texCoordCount; i++) { texCoords[i] = new TexCoord( new Vec2(s.ReadSingle(), s.ReadSingle()), // TL new Vec2(s.ReadSingle(), s.ReadSingle()), // TR new Vec2(s.ReadSingle(), s.ReadSingle()), // BL new Vec2(s.ReadSingle(), s.ReadSingle()) // BR ); } }
public TextBox(ref BinaryStream s) : base(ref s) { int startPos = (int)s.BaseStream.Position - 84; bufByteCount = s.ReadUInt16(); stringByteCount = s.ReadUInt16(); materialIndex = s.ReadUInt16(); fontIndex = s.ReadUInt16(); textPosition = s.Read1Byte(); textAlignment = s.Read1Byte(); flags = s.ReadUInt16(); italicsRatio = s.ReadSingle(); textOffset = s.ReadUInt32(); textColors = new Color[2]; textColors[0] = ColorHelper.BytesToColor(s.ReadBytes(4)); // Color 1 textColors[1] = ColorHelper.BytesToColor(s.ReadBytes(4)); // Color 2 fontSize = new Vec2(s.ReadSingle(), s.ReadSingle()); charSpace = s.ReadSingle(); lineSpace = s.ReadSingle(); textIDOffset = s.ReadUInt32(); shadowOffset = new Vec2(s.ReadSingle(), s.ReadSingle()); shadowScale = new Vec2(s.ReadSingle(), s.ReadSingle()); shadowColors = new Color[2]; shadowColors[0] = ColorHelper.BytesToColor(s.ReadBytes(4)); // Color 1 shadowColors[1] = ColorHelper.BytesToColor(s.ReadBytes(4)); // Color 2 shadowItalicsRatio = s.ReadSingle(); lineWidthOffsetOffset = s.ReadUInt32(); perCharacterTransformOffset = s.ReadUInt32(); text = Encoding.ASCII.GetString(s.ReadBytes(stringByteCount)).Replace("\0", ""); if (textIDOffset != 0) { s.BaseStream.Position = startPos + textIDOffset; textID = (int)s.ReadUInt32(); } s.Align(4); // Align everything // Do character transforms later }
public Window(ref BinaryStream s) : base(ref s) { int startPos = (int)s.BaseStream.Position - 84; inflation = new WindowInflation(); inflation.left = s.ReadUInt16(); inflation.right = s.ReadUInt16(); inflation.top = s.ReadUInt16(); inflation.bottom = s.ReadUInt16(); frameSize = new WindowFrameSize(); frameSize.left = s.ReadUInt16(); frameSize.right = s.ReadUInt16(); frameSize.top = s.ReadUInt16(); frameSize.bottom = s.ReadUInt16(); frameCount = s.Read1Byte(); windowFlags = s.Read1Byte(); s.Align(4); // Padding contentOffset = s.ReadUInt32(); frameOffsetTableOffset = s.ReadUInt32(); s.BaseStream.Position = startPos + contentOffset; content = new WindowContent(); content.vertexColors = new Color[4]; content.vertexColors[0] = ColorHelper.BytesToColor(s.ReadBytes(4)); // TL content.vertexColors[1] = ColorHelper.BytesToColor(s.ReadBytes(4)); // TR content.vertexColors[2] = ColorHelper.BytesToColor(s.ReadBytes(4)); // BL content.vertexColors[3] = ColorHelper.BytesToColor(s.ReadBytes(4)); // BR content.materialIndex = s.ReadUInt16(); content.texCoordCount = s.Read1Byte(); s.Align(4); // Padding content.texCoords = new TexCoord[content.texCoordCount]; for (int i = 0; i < content.texCoordCount; i++) { content.texCoords[i] = new TexCoord( new Vec2(s.ReadSingle(), s.ReadSingle()), // TL new Vec2(s.ReadSingle(), s.ReadSingle()), // TR new Vec2(s.ReadSingle(), s.ReadSingle()), // BL new Vec2(s.ReadSingle(), s.ReadSingle()) // BR ); } s.BaseStream.Position = startPos + frameOffsetTableOffset; frameOffsetTable = new uint[frameCount]; for (int i = 0; i < frameCount; i++) { frameOffsetTable[i] = s.ReadUInt32(); } frames = new WindowFrame[frameCount]; for (int i = 0; i < frameCount; i++) { s.BaseStream.Position = startPos + frameOffsetTable[i]; WindowFrame frame = new WindowFrame(); frame.materialIndex = s.ReadUInt16(); frame.textureFlip = s.Read1Byte(); s.Align(4); // Padding frames[i] = frame; } }