Exemplo n.º 1
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)Entries.Count);
            aw.Write((int)4);

            Entries.ForEach(x => aw.Write((ulong)x));
        }
Exemplo n.º 2
0
        internal void WriteData(AwesomeWriter aw)
        {
            aw.Write((ulong)_filePath);
            aw.Write((ulong)_directoryPath);
            aw.Write((ulong)Type);
            aw.BaseStream.Position += 8;

            WriteObjectData(aw);
        }
Exemplo n.º 3
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)Version);
            aw.WriteNullString(PackageName, 256);
            aw.Write((int)Entries.Count);
            aw.Write((int)4);

            foreach (string entry in Entries)
            {
                aw.WriteNullString(entry, 256);
            }
        }
Exemplo n.º 4
0
        internal void WriteData(AwesomeWriter aw)
        {
            aw.Write((int)Entries.Count);
            aw.Write((int)4);

            foreach (IndexEntry entry in Entries)
            {
                aw.Write((ulong)entry.FilePath);
                aw.Write((uint)entry.Offset);
                aw.BaseStream.Position += 4;
            }
        }
Exemplo n.º 5
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var propAnim = data as PropAnim;

            var version = Magic();

            // Hacky way to support GDRB
            if (version == 11 && IsGRDRBAnim(propAnim))
            {
                version = 12;
            }

            aw.Write(version);

            // Write meta
            aw.Write((int)2);
            aw.Write((string)propAnim.AnimName);
            aw.BaseStream.Position += 5; // Skip zeros

            aw.Write((int)4);
            aw.Write((float)propAnim.TotalTime);
            aw.Write((int)1);

            if (version >= 12)
            {
                aw.Write((byte)0x00);
            }

            // Write director groups
            aw.Write(propAnim.DirectorGroups.Count);
            foreach (var group in propAnim.DirectorGroups)
            {
                WriteGroupEvent(group, aw);
            }
        }
Exemplo n.º 6
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)Version);
            aw.Write((int)Entries.Count);
            aw.Write((int)4); // Should always be 4

            long nextPackageOffset = aw.BaseStream.Position + (Entries.Count * 24);

            // Writes index2 entries
            foreach (Index2Entry entry in Entries)
            {
                aw.Write((long)entry.FilePath.Key);
                aw.Write((long)entry.Type.Key);
                aw.Write((int)entry.PackageEntries.Count);
                aw.Write((int)(nextPackageOffset - aw.BaseStream.Position));

                nextPackageOffset += entry.PackageEntries.Count * 248;
            }

            // Writes package entries
            foreach (var entry in Entries.SelectMany(x => x.PackageEntries))
            {
                aw.Write((ulong)entry.Package);
                aw.WriteNullString(entry.ExternalFilePath, 240);
            }
        }
Exemplo n.º 7
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((ulong)InstrumentType);
            aw.Write((ulong)Difficulty);
            aw.BaseStream.Position += 8; // Should be zero'd

            InstrumentTuning.WriteData(aw, Tuning);
            aw.Write((int)TrackPaths.Count);
            aw.Write((int)4);

            foreach (HKey path in TrackPaths)
            {
                aw.Write((ulong)path);
            }
        }
Exemplo n.º 8
0
        private static void PatchXPR2Header(byte[] header, int t, int tOffset, int h, int hOffset, int w, int wOffset)
        {
            using (AwesomeWriter aw = new AwesomeWriter(new MemoryStream(header), true))
            {
                // Encodes texture size, height, and width
                aw.Seek(tOffset, SeekOrigin.Begin);
                aw.Write((int)t);

                aw.Seek(hOffset, SeekOrigin.Begin);
                aw.Write((short)((h >> 3) - 1));

                aw.Seek(wOffset, SeekOrigin.Begin);
                aw.Write((short)((w - 1) | 0xE000));
            }
        }
Exemplo n.º 9
0
 internal static void WriteData(AwesomeWriter aw, InstrumentTuning tuning)
 {
     // 40 bytes
     aw.Write((ulong)tuning.Name);
     aw.Write((int)(tuning.String1 << 8 | tuning.String1Alt));
     aw.Write((int)(tuning.String2 << 8 | tuning.String2Alt));
     aw.Write((int)(tuning.String3 << 8 | tuning.String3Alt));
     aw.Write((int)(tuning.String4 << 8 | tuning.String4Alt));
     aw.Write((int)(tuning.String5 << 8 | tuning.String5Alt));
     aw.Write((int)(tuning.String6 << 8 | tuning.String6Alt));
     aw.Write((int)(tuning.String7 << 8 | tuning.String7Alt));
     aw.Write((int)(tuning.String8 << 8 | tuning.String8Alt));
 }
Exemplo n.º 10
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var view = data as View;

            // TODO: Add version check
            var version = Magic();

            aw.Write(version);

            MiloSerializer.WriteToStream(aw.BaseStream, view.Anim);
            MiloSerializer.WriteToStream(aw.BaseStream, view.Trans);
            MiloSerializer.WriteToStream(aw.BaseStream, view.Draw);

            aw.Write((string)view.MainView);
            aw.Write((float)view.LODHeight);
            aw.Write((float)view.LODWidth);
        }
Exemplo n.º 11
0
        private byte[] CreateData()
        {
            var stringBlob = CreateStringBlob(out var stringOffsets);

            using (var ms = new MemoryStream())
            {
                using (var aw = new AwesomeWriter(ms, true))
                {
                    // Writes entry count + blob size
                    aw.Write((int)Entries.Count);
                    aw.Write((int)stringBlob.Length);

                    // Writes entries
                    foreach (var entry in Entries)
                    {
                        aw.Write((float)entry.Start);
                        aw.Write((int)entry.Modifier);
                        aw.Write((float)entry.Length);
                        aw.Write(stringOffsets.ContainsKey(entry.Text) ? stringOffsets[entry.Text] : entry.Data);
                    }

                    // Writes string blob
                    aw.Write(stringBlob);
                }

                return(ms.ToArray());
            }
        }
Exemplo n.º 12
0
        private byte[] CreateData()
        {
            using (AwesomeWriter aw = new AwesomeWriter(new MemoryStream(), BigEndian))
            {
                aw.Write((int)_version);
                // TODO: Implement directory type + name writing

                aw.Write(Entries.Count);

                // Writes entry type + name
                foreach (AbstractEntry entry in Entries)
                {
                    aw.Write(entry.Type);
                    aw.Write(entry.Name);
                }

                if (_version == MiloVersion.V10)
                {
                    aw.Write((int)0);
                }

                // Writes data from each entry
                foreach (AbstractEntry entry in Entries)
                {
                    aw.Write(entry.Data);
                    aw.Write(ADDE_PADDING);
                }

                return(((MemoryStream)(aw.BaseStream)).ToArray());
            }
        }
Exemplo n.º 13
0
        public void SaveToStream(AwesomeWriter aw)
        {
            var version = Embedded ? 0 : 1;

            aw.Write((byte)1); // Always 1

            if (Encoding == DTBEncoding.FME)
            {
                aw.Write((int)0); // Always 0
            }
            if (Encoding != DTBEncoding.RBVR)
            {
                aw.Write((short)Items.Count);
                aw.Write((int)version);
            }
            else
            {
                aw.Write((int)version);
                aw.Write((short)Items.Count);
                aw.Write((short)1); // Always 1?
            }

            int lineNumber = 1;

            foreach (DTBItem item in Items)
            {
                WriteItem(aw, item, ref lineNumber);
            }
        }
Exemplo n.º 14
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var tex = data as Tex;

            // TODO: Add version check
            var version = Magic();

            aw.Write((int)version);

            if (MiloSerializer.Info.Version >= 25)
            {
                aw.Write((int)1); // Definitely needed!
            }
            if (version >= 10)
            {
                aw.Write(new byte[9]);
            }

            aw.Write((int)tex.Width);
            aw.Write((int)tex.Height);
            aw.Write((int)tex.Bpp);

            aw.Write(tex.ExternalPath);
            aw.Write((float)tex.IndexF);
            aw.Write((int)tex.Index);

            aw.Write((bool)tex.UseExternal);
            if (tex.Bitmap != null)
            {
                MiloSerializer.WriteToStream(aw.BaseStream, tex.Bitmap);
            }

            /*
             * if (!tex.UseExternal && tex.Bitmap != null)
             * {
             *  aw.Write(false);
             *  MiloSerializer.WriteToStream(aw.BaseStream, tex.Bitmap);
             * }
             * else
             * {
             *  aw.Write(true);
             * }*/
        }
Exemplo n.º 15
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)13);
            aw.Write((int)24);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (EventEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((ulong)ev.EventName);
                aw.Write((int)0);
                aw.Write((int)ev.Index);
            }
        }
Exemplo n.º 16
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)8);
            aw.Write((int)32);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (VoxEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);

                aw.Write((int)(ev.Pitch << 8 | ev.PitchAlt));
                aw.BaseStream.Position += 4; // Always 0

                aw.Write((ulong)ev.Lyric);
                aw.Write((int)ev.NoteType);
                aw.Write((int)0); // Always 0
            }
        }
Exemplo n.º 17
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var bytes = data as MiloObjectBytes;

            if (bytes.Data == null)
            {
                return;
            }

            aw.Write(bytes.Data);
        }
Exemplo n.º 18
0
        public void WriteToStream(Stream stream)
        {
            using (AwesomeWriter aw = new AwesomeWriter(stream, BigEndian))
            {
                aw.Write((int)10); // TODO: Save version
                aw.Write((int)1);

                aw.BaseStream.Position += 9;
                aw.Write((int)Image.Width);
                aw.Write((int)Image.Height);
                aw.Write((int)((Image.Encoding == ImageEncoding.DXT1) ? 4 : 8));

                //aw.Write("NO_EXTERNAL_PATH");
                aw.Write(ExternalPath);
                aw.Write((float)-8.0f);
                aw.Write((int)1);
                aw.Write((byte)0x01); // Use embedded

                aw.Write(Image.WriteToBytes());
            }
        }
Exemplo n.º 19
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)0);
            aw.Write((int)16);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (TimeSignatureEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((int)ev.Beat);
                aw.Write((int)ev.Measure);
            }
        }
Exemplo n.º 20
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var bitmap = data as HMXBitmap;

            aw.Write((byte)0x01);

            aw.Write((byte)bitmap.Bpp);
            aw.Write((int)bitmap.Encoding);
            aw.Write((byte)bitmap.MipMaps);

            aw.Write((short)bitmap.Width);
            aw.Write((short)bitmap.Height);
            aw.Write((short)bitmap.BPL);

            aw.Write(new byte[19]);

            byte[] bytes = new byte[CalculateTextureByteSize(bitmap.Encoding, bitmap.Width, bitmap.Height, bitmap.Bpp, bitmap.MipMaps)];
            Array.Copy(bitmap.RawData, bytes, bytes.Length);
            aw.Write(bytes);
        }
Exemplo n.º 21
0
        public void WriteToStream(Stream stream)
        {
            long startOffset;
            int  size;

            var data = CreateData();
            var hash = Crc32Algorithm.Compute(data);

            var aw = new AwesomeWriter(stream, true);

            startOffset = stream.Position;

            aw.Write((int)Version);
            aw.Write((int)hash); // CRC-32 hash

            aw.Write(data);
            size = (int)(stream.Position - startOffset);
            if (size % 4 != 0)
            {
                // Write byte difference
                var remain = new byte[4 - (size % 4)];
                aw.Write(remain);
            }
        }
Exemplo n.º 22
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)2);
            aw.Write((int)12);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (SpreadEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((float)ev.Speed);
            }
        }
Exemplo n.º 23
0
        private byte[] CreateChunk(ZObject obj, bool bigEndian, ref long offset)
        {
            using (AwesomeWriter aw = new AwesomeWriter(new MemoryStream(), bigEndian))
            {
                obj.WriteData(aw);

                // Ensures chunk size is always divisible by 4
                if (aw.BaseStream.Position % 4 != 0)
                {
                    aw.Write(new byte[4 - (aw.BaseStream.Position % 4)]);
                }

                offset += aw.BaseStream.Position + 8; // 8 = Chunk Magic + Size
                return(((MemoryStream)aw.BaseStream).ToArray());
            }
        }
Exemplo n.º 24
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)7);
            aw.Write((int)16);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (AudioEffectEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((ulong)ev.EffectPath);
            }
        }
Exemplo n.º 25
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)12);
            aw.Write((int)16);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (WhammyEntry ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((long)0);
            }
        }
Exemplo n.º 26
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)3);
            aw.Write((int)16);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (TextEvent ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
                aw.Write((ulong)ev.EventName);
            }
        }
Exemplo n.º 27
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var draw = data as Draw;

            // TODO: Add version check
            var version = Magic();

            aw.Write(version);

            aw.Write((bool)draw.Showing);

            aw.Write((int)draw.Drawables.Count);
            draw.Drawables.ForEach(x => aw.Write((string)x));

            // Write boundry
            aw.Write(draw.Boundry.X);
            aw.Write(draw.Boundry.Y);
            aw.Write(draw.Boundry.Z);
            aw.Write(draw.Boundry.Radius);
        }
Exemplo n.º 28
0
        protected override void WriteObjectData(AwesomeWriter aw)
        {
            aw.Write((int)10);
            aw.Write((int)8);
            aw.Write((int)Events.Count);
            aw.Write((int)4);

            foreach (TimeEvent ev in Events)
            {
                aw.Write((float)ev.Start);
                aw.Write((float)ev.End);
            }
        }
Exemplo n.º 29
0
        private void WriteToStream(Stream stream)
        {
            ResetStringTables();

            AwesomeWriter aw          = new AwesomeWriter(stream, BigEndian);
            long          startOffset = aw.BaseStream.Position;
            long          offset      = startOffset + 24 + (_objects.Count * 16);

            var chunks = _objects.Select(x => new
            {
                Path          = x.FilePath,
                Offset        = offset,
                Data          = CreateChunk(x, BigEndian, ref offset),
                IsStringTable = (x is StringTable)
            }).ToArray();

            aw.Write((int)MAGIC_RIFF);
            aw.Write((uint)(offset - (startOffset + 8)));

            Index index = new Index()
            {
                Entries = new List <IndexEntry>(chunks.Select(x => new IndexEntry()
                {
                    FilePath = x.Path,
                    Offset   = (uint)x.Offset
                }
                                                              ))
            };

            // Writes index chunk
            aw.Write((int)MAGIC_INDX);
            aw.Write((int)(8 + (index.Entries.Count * 16)));
            index.WriteData(aw);

            // Writes other zobjects and string tables
            foreach (var chunk in chunks)
            {
                aw.Write((int)(chunk.IsStringTable ? MAGIC_STBL : MAGIC_ZOBJ));
                aw.Write((int)chunk.Data.Length);
                aw.Write(chunk.Data);
            }
        }
Exemplo n.º 30
0
        public override void WriteToStream(AwesomeWriter aw, ISerializable data)
        {
            var anim = data as Anim;

            // TODO: Add version check
            var version = Magic();

            aw.Write(version);

            aw.Write((int)anim.AnimEntries.Count);
            anim.AnimEntries.ForEach(x =>
            {
                aw.Write((string)x.Name);
                aw.Write((float)x.F1);
                aw.Write((float)x.F2);
            });

            aw.Write((int)anim.Animatables.Count);
            anim.Animatables.ForEach(x => aw.Write((string)x));
        }