public static void Save <T>(T contents, string fileName) where T : class
 {
     SerializationHelper <T> .Save(contents, fileName);
 }
示例#2
0
        public static void Unpack(Stream stream, int length, string output, long position)
        {
            var gcx = new GCX();

            gcx.Offset = position;
            gcx.Length = length;
            gcx.Magic  = stream.ReadInt32BE();

            while (true)
            {
                var value1 = stream.ReadUInt32BE();
                var value2 = stream.ReadUInt32BE();

                if (value1 == 0 && value2 == 0)
                {
                    break;
                }
                else
                {
                    gcx.Headers.Add(new Header {
                        Unknown1 = value1, Unknown2 = value2
                    });
                }
            }

            var start   = stream.Position;
            var length2 = stream.ReadInt32();
            var endian  = stream.ReadInt32();

            var textStart = stream.ReadInt32() + start;
            var fontStart = stream.ReadInt32() + start;

            while (stream.Position < textStart)
            {
                gcx.Entities.Add(new TextEntity {
                    OffsetValue = stream.ReadUInt32()
                });
            }



            foreach (var item in gcx.Entities)
            {
                var offset = item.OffsetValue & 0xFFFFFF;
                stream.Position = textStart + offset;
                item.Text       = TextTable.GetString(stream.ReadToNull(), TextTable.Empty);
            }

            stream.Position = fontStart;
            var fontLength = stream.ReadInt32();

            if (fontLength > 0)
            {
                gcx.FontData = stream.ReadBytes(fontLength);
            }


            Directory.CreateDirectory(Path.GetDirectoryName(output));

            if (stream.Position < stream.Length)
            {
                File.WriteAllBytes(output + ".seq", stream.ReadBytes(stream.ReadInt32()));
            }

            if (stream.Position < stream.Length)
            {
                File.WriteAllBytes(output + ".unk", stream.ReadBytes(stream.ReadInt32()));
            }

            SerializationHelper.Save(gcx, output + ".xml");
        }
 public static void Save <T>(T contents, TextWriter writer) where T : class
 {
     SerializationHelper <T> .Save(contents, writer);
 }