Exemple #1
0
            public void Write(FileWriter writer)
            {
                RecalculateMaterialReferences();

                writer.SetByteOrder(IsBigEndian);
                writer.WriteSignature(Magic);
                if (Magic == "TYLR")
                {
                    writer.ReverseMagic = true;
                }
                writer.Write(ByteOrderMark);
                writer.Write((ushort)Version);
                writer.Write(uint.MaxValue);   //Reserve space for file size later
                writer.Write(HeaderSize);
                writer.Write(ushort.MaxValue); //Reserve space for section count later

                int sectionCount = 1;

                WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));
                if (TextureList != null && TextureList.Textures.Count > 0)
                {
                    WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                    sectionCount++;
                }
                if (FontList != null && FontList.Fonts.Count > 0)
                {
                    WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                    sectionCount++;
                }
                if (MaterialList != null && MaterialList.Materials.Count > 0)
                {
                    WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                    sectionCount++;
                }

                WritePanes(writer, RootPane, this, ref sectionCount);
                WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

                //Write the total section count
                using (writer.TemporarySeek(14, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((ushort)sectionCount);
                }

                //Write the total file size
                using (writer.TemporarySeek(8, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((uint)writer.BaseStream.Length);
                }
            }
Exemple #2
0
        public void Write(FileWriter writer)
        {
            RecalculateMaterialReferences();

            Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;

            foreach (var pane in PaneLookup.Values)
            {
                if (pane is PIC1)
                {
                    ((PIC1)pane).MaterialIndex = (ushort)MaterialList.Materials.IndexOf(((PIC1)pane).Material);
                }
            }

            writer.SetByteOrder(true);
            writer.WriteSignature(Magic);
            if (!IsBigEndian)
            {
                writer.Write((ushort)0xFFFE);
            }
            else
            {
                writer.Write((ushort)0xFEFF);
            }
            writer.SetByteOrder(IsBigEndian);
            writer.Write(HeaderSize);
            writer.Write(Version);
            writer.Write(uint.MaxValue);   //Reserve space for file size later
            writer.Write(ushort.MaxValue); //Reserve space for section count later
            writer.Seek(2);                //padding

            int sectionCount = 1;

            WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));

            if (UserData != null && UserData.Entries?.Count > 0)
            {
                WriteSection(writer, "usd1", UserData, () => UserData.Write(writer, this));
                sectionCount++;
            }

            if (TextureList != null && TextureList.Textures.Count > 0)
            {
                WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                sectionCount++;
            }
            if (FontList != null && FontList.Fonts.Count > 0)
            {
                WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                sectionCount++;
            }
            if (MaterialList != null && MaterialList.Materials.Count > 0)
            {
                WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                sectionCount++;
            }

            WritePanes(writer, RootPane, this, ref sectionCount);
            WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

            foreach (var section in UnknownSections)
            {
                WriteSection(writer, section.Signature, section, () => section.Write(writer, this));
                sectionCount++;
            }

            //Write the total section count
            using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
            {
                writer.Write((ushort)sectionCount);
            }

            //Write the total file size
            using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
            {
                writer.Write((uint)writer.BaseStream.Length);
            }
        }
Exemple #3
0
            public void Write(FileWriter writer)
            {
                Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;

                writer.SetByteOrder(true);
                writer.WriteSignature(Magic);
                if (!IsBigEndian)
                {
                    writer.Write((ushort)0xFFFE);
                }
                else
                {
                    writer.Write((ushort)0xFEFF);
                }
                writer.SetByteOrder(IsBigEndian);
                writer.Write(HeaderSize);
                writer.Write(Version);
                writer.Write(uint.MaxValue);   //Reserve space for file size later
                writer.Write(ushort.MaxValue); //Reserve space for section count later
                writer.Seek(2);                //padding

                int sectionCount = 1;

                WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));

                /*if (UserData != null && UserData.Entries?.Count > 0)
                 * {
                 *  WriteSection(writer, "usd1", UserData, () => UserData.Write(writer, this));
                 *  sectionCount++;
                 * }*/

                if (TextureList != null && TextureList.Textures.Count > 0)
                {
                    WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                    sectionCount++;
                }
                if (FontList != null && FontList.Fonts.Count > 0)
                {
                    WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                    sectionCount++;
                }
                if (MaterialList != null && MaterialList.Materials.Count > 0)
                {
                    WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                    sectionCount++;
                }

                WritePanes(writer, RootPane, this, ref sectionCount);
                WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

                //Write the total section count
                using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((ushort)sectionCount);
                }

                //Write the total file size
                using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((uint)writer.BaseStream.Length);
                }
            }