Ejemplo n.º 1
0
        public static List <string> Read(FileReader reader, BLOHeader header)
        {
            List <string> values = new List <string>();

            ushort count = reader.ReadUInt16();

            if (count == 0)
            {
                return(values);
            }

            ushort unk        = reader.ReadUInt16(); //0xFFFF
            uint   headerSize = reader.ReadUInt32(); //0x10

            long startpos = reader.Position;

            ushort count2 = reader.ReadUInt16(); //Same as count

            ushort[] offsets = reader.ReadUInt16s((int)count);
            for (int i = 0; i < count; i++)
            {
                reader.SeekBegin(startpos + offsets[i]);
                values.Add(BloResource.Read(reader, header));
            }
            return(values);
        }
Ejemplo n.º 2
0
 public INF1(FileReader reader, BLOHeader header)
 {
     Unknown   = reader.ReadUInt32();
     Width     = reader.ReadUInt16();
     Height    = reader.ReadInt16();
     TintColor = reader.ReadColor8RGBA();
 }
Ejemplo n.º 3
0
        public static void Write(FileWriter writer, string value, BLOHeader header)
        {
            if (header.Resources.ContainsKey(value))
            {
                writer.Write((byte)header.Resources[value]);
            }
            else
            {
                writer.Write((byte)bloResourceType.LocalArchive);
            }

            writer.Write((byte)value.Length);
            writer.WriteString(value);
        }
Ejemplo n.º 4
0
        public static string Read(FileReader reader, BLOHeader header)
        {
            var    type   = (bloResourceType)reader.ReadByte();
            byte   length = reader.ReadByte();
            string name   = reader.ReadString(length, true);

            Console.WriteLine($"{type} {length} {name}");

            if (!header.Resources.ContainsKey(name))
            {
                header.Resources.Add(name, type);
            }
            return(name);
        }
Ejemplo n.º 5
0
        public WIN1(FileReader reader, BLOHeader header) : base(reader, header)
        {
            byte  numParams = reader.ReadByte();
            short transX    = reader.ReadInt16();
            short transY    = reader.ReadInt16();

            Width  = reader.ReadInt16();
            Height = reader.ReadInt16();

            Translate = GetPosition() + new Syroot.Maths.Vector3F(transX, transY, 0);

            Content                      = new BxlytWindowContent(header);
            Content.Material             = new Material();
            Content.Material.TextureMaps = new BxlytTextureRef[0];

            Console.WriteLine($"numParams {numParams}");
            FrameCount = 4;
            WindowKind = WindowKind.Around;

            numParams -= 5;
            if (numParams > 0)
            {
                WindowFrames = new List <BxlytWindowFrame>();
                for (int i = 0; i < 4; i++)
                {
                    string texName = BloResource.Read(reader, header);
                    Console.WriteLine($"texName {texName}");

                    var frame = new WindowFrame(texName);
                    WindowFrames.Add(frame);
                }
            }

            /*       if (numParams > 0) {
             *         PaletteName = BloResource.Read(reader, header);
             *         numParams--;
             *     }
             *
             *     PaletteName = BloResource.Read(reader, header);
             *     byte src = reader.ReadByte();
             *
             *     for (int i = 0; i < 4; i++)
             *     {
             *         var mirror = (byte)((src >> (6 - (i * 2))) & 0x3);
             *         if (mirror == 1)
             *             WindowFrames[i].TextureFlip = WindowFrameTexFlip.FlipV;
             *     }*/
        }
Ejemplo n.º 6
0
        public static void Write(List <string> values, FileWriter writer, BLOHeader header)
        {
            writer.Write(values.Count);
            writer.Write((ushort)0xFFFF);
            writer.Write((ushort)0x10);

            long startpos = writer.Position;

            writer.Write(values.Count);
            writer.Write(new ushort[values.Count]);
            for (int i = 0; i < values.Count; i++)
            {
                writer.WriteUint16Offset(startpos + (i * 4), startpos);
                BloResource.Write(writer, values[i], header);
            }
        }
Ejemplo n.º 7
0
        public static List <Material> ReadMaterials(
            FileReader reader, BLOHeader header)
        {
            List <Material> materials = new List <Material>();

            ushort count = reader.ReadUInt16();

            reader.ReadUInt16(); //0xFF
            uint materialDataOffset = reader.ReadUInt32();

            for (int i = 0; i < count; i++)
            {
                materials.Add(new Material());
            }

            return(materials);
        }
Ejemplo n.º 8
0
        public PAN1(FileReader reader, BLOHeader header) : base()
        {
            byte paramCount = reader.ReadByte();

            Visible = reader.ReadBoolean();
            reader.ReadUInt16();
            Name = reader.ReadString(4, true);

            Left   = reader.ReadUInt16();
            Top    = reader.ReadUInt16();
            Width  = reader.ReadUInt16();
            Height = reader.ReadInt16();

            paramCount -= 6;
            if (paramCount > 0)
            {
                Angle = reader.ReadInt16();
                --paramCount;
            }
            if (paramCount > 0)
            {
                Anchor = (AnchorType)reader.ReadByte();
                --paramCount;
            }
            if (paramCount > 0)
            {
                Alpha = reader.ReadByte();
                --paramCount;
            }
            if (paramCount > 0)
            {
                InfluenceAlpha = reader.ReadBoolean();
                --paramCount;
            }
            Alpha = 255;

            Translate = GetPosition();
            Scale     = new Vector2F(1, 1);
            Rotate    = new Vector3F(0, 0, 0);
        }
Ejemplo n.º 9
0
        public PIC1(FileReader reader, BLOHeader header) : base(reader, header)
        {
            byte numParams = reader.ReadByte();

            if (numParams > 0)
            {
                TextureName = BloResource.Read(reader, header);
                numParams--;
            }
            if (numParams > 0)
            {
                PaletteName = BloResource.Read(reader, header);
                numParams--;
            }
            if (numParams > 0)
            {
                Binding = reader.ReadByte();
                numParams--;
            }

            Material = new Material();

            if (TextureName == string.Empty)
            {
                Material.TextureMaps = new BxlytTextureRef[0];
            }
            else
            {
                Material.TextureMaps    = new BxlytTextureRef[1];
                Material.TextureMaps[0] = new BxlytTextureRef()
                {
                    Name = TextureName,
                };
            }


            TexCoords    = new TexCoord[1];
            TexCoords[0] = new TexCoord();
        }
Ejemplo n.º 10
0
        public PAN2(FileReader reader, BLOHeader header) : base()
        {
            long pos = reader.Position;

            ushort sectionSize = reader.ReadUInt16();
            ushort unk         = reader.ReadUInt16();
            uint   unk2        = reader.ReadUInt32();
            uint   unk3        = reader.ReadUInt32();

            Name = reader.ReadString(0x0C, true);

            Width  = reader.ReadSingle();
            Height = reader.ReadSingle();
            Left   = reader.ReadSingle();
            Top    = reader.ReadSingle();

            Translate = GetPosition();
            Scale     = new Vector2F(1, 1);
            Rotate    = new Vector3F(0, 0, 0);
            Alpha     = 255;
            Visible   = true;

            reader.SeekBegin(pos + sectionSize);
        }
Ejemplo n.º 11
0
        public PIC2(FileReader reader, BLOHeader header) : base(reader, header)
        {
            TexCoords    = new TexCoord[1];
            TexCoords[0] = new TexCoord();

            ushort sectionSize = reader.ReadUInt16();

            Console.WriteLine($"PIC2 {sectionSize}");
            MaterialIndex = reader.ReadUInt16();
            Material      = header.Materials[MaterialIndex];
            uint unk = reader.ReadUInt32();
            //These increase for each material
            ushort index1 = reader.ReadUInt16();
            ushort index2 = reader.ReadUInt16();
            ushort index3 = reader.ReadUInt16();
            ushort index4 = reader.ReadUInt16();

            //I think these are texture coordinates
            TexCoords[0].TopLeft = new Vector2F(
                reader.ReadInt16() / 256f,
                reader.ReadInt16() / 256f);
            TexCoords[0].TopRight = new Vector2F(
                reader.ReadInt16() / 256f,
                reader.ReadInt16() / 256f);
            TexCoords[0].BottomLeft = new Vector2F(
                reader.ReadInt16() / 256f,
                reader.ReadInt16() / 256f);
            TexCoords[0].BottomRight = new Vector2F(
                reader.ReadInt16() / 256f,
                reader.ReadInt16() / 256f);

            ColorTopLeft     = STColor8.FromBytes(reader.ReadBytes(4));
            ColorTopRight    = STColor8.FromBytes(reader.ReadBytes(4));
            ColorBottomLeft  = STColor8.FromBytes(reader.ReadBytes(4));
            ColorBottomRight = STColor8.FromBytes(reader.ReadBytes(4));
        }