Exemple #1
0
            /// <summary>
            /// Exports the specified RawFile XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                RawFileXAsset header = instance.Reader.ReadStruct <RawFileXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

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

                try
                {
                    MemoryStream DecodedCodeStream = Decode(instance.Reader.ReadBytes(header.Buffer + 2, header.CompressedLen - 2));
                    using FileStream outputStream = new FileStream(path, FileMode.Create);
                    DecodedCodeStream.CopyTo(outputStream);
                }
                catch
                {
                    return(JekyllStatus.Exception);
                }

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #2
0
            /// <summary>
            /// Exports the specified ScriptFile XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                ScriptFileXAsset header = instance.Reader.ReadStruct <ScriptFileXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string addedScriptsFolder = Path.Combine(xasset.Name.Contains("scripts") ? "" : "scripts", xasset.Name);
                string path = Path.Combine(instance.ExportPath, addedScriptsFolder.Contains(".gsc") ? "" : addedScriptsFolder + ".gsc");

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

                MemoryStream DecodedCodeStream = Decode(instance.Reader.ReadBytes(header.Buffer + 2, header.CompressedLen - 2));

                using (var outputStream = new FileStream(path, FileMode.Create))
                {
                    DecodedCodeStream.CopyTo(outputStream);
                }

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #3
0
            /// <summary>
            /// Exports the specified ScriptFile XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                ScriptParseTree header = instance.Reader.ReadStruct <ScriptParseTree>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                try
                {
                    string path = Path.Combine(instance.ExportPath, xasset.Name);
                    Directory.CreateDirectory(Path.GetDirectoryName(path));

                    byte[] buffer = instance.Reader.ReadBytes(header.Buffer, header.Len);
                    File.WriteAllBytes(path, buffer);
                }
                catch
                {
                    return(JekyllStatus.Exception);
                }

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #4
0
            /// <summary>
            /// Exports the specified RawFile XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                RawFileXAsset header = instance.Reader.ReadStruct <RawFileXAsset>(xasset.HeaderAddress);

                string path = Path.Combine(instance.ExportPath, "rawfile/" + xasset.Name);

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

                byte[] buffer = instance.Reader.ReadBytes(header.Buffer, header.Len);

                File.WriteAllBytes(path, buffer);

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #5
0
            /// <summary>
            /// Exports the specified MapEnts XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                MapEntsXAsset header = instance.Reader.ReadStruct <MapEntsXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

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

                File.WriteAllText(path, instance.Reader.ReadNullTerminatedString(header.EntityString));

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #6
0
            /// <summary>
            /// Exports the specified ScriptFile XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                ScriptFileXAsset header = instance.Reader.ReadStruct <ScriptFileXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string addedScriptsFolder = Path.Combine(xasset.Name.Contains("scripts") ? "" : "scripts", xasset.Name);
                string path = Path.Combine(instance.ExportPath, addedScriptsFolder.Contains(".gsc") ? addedScriptsFolder + "bin" : addedScriptsFolder + ".gscbin");

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

                byte[] filename      = Encoding.UTF8.GetBytes(xasset.Name + char.MinValue);
                byte[] compressedLen = BitConverter.GetBytes(header.CompressedLen);
                byte[] len           = BitConverter.GetBytes(header.Len);
                byte[] bytecodeLen   = BitConverter.GetBytes(header.BytecodeLen);
                byte[] buffer        = instance.Reader.ReadBytes(header.Buffer, header.CompressedLen);
                byte[] bytecode      = instance.Reader.ReadBytes(header.Bytecode, header.BytecodeLen);

                byte[] file = new byte[filename.Length + compressedLen.Length + len.Length + bytecodeLen.Length + buffer.Length + bytecode.Length];

                Buffer.BlockCopy(filename, 0, file, 0, filename.Length);
                Buffer.BlockCopy(compressedLen, 0, file, filename.Length, compressedLen.Length);
                Buffer.BlockCopy(len, 0, file, filename.Length + compressedLen.Length, len.Length);
                Buffer.BlockCopy(bytecodeLen, 0, file, filename.Length + compressedLen.Length + len.Length, bytecodeLen.Length);
                Buffer.BlockCopy(buffer, 0, file, filename.Length + compressedLen.Length + len.Length + bytecodeLen.Length, buffer.Length);
                Buffer.BlockCopy(bytecode, 0, file, filename.Length + compressedLen.Length + len.Length + bytecodeLen.Length + buffer.Length, bytecode.Length);

                try
                {
                    File.WriteAllBytes(path, file);
                }
                catch
                {
                    return(JekyllStatus.Exception);
                }

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #7
0
            /// <summary>
            /// Exports the specified StringTable XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                StringTableXAsset header = instance.Reader.ReadStruct <StringTableXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

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

                StringBuilder stringTable = new StringBuilder();

                int index = 0;

                for (int x = 0; x < header.RowCount; x++)
                {
                    for (int y = 0; y < header.ColumnCount; y++)
                    {
                        int    cell  = instance.Reader.ReadInt16(header.CellIndices + (2 * index));
                        string value = instance.Reader.ReadNullTerminatedString(instance.Reader.ReadInt64(header.Strings + (8 * cell)));

                        stringTable.Append(value);

                        if (y != (header.ColumnCount - 1))
                        {
                            stringTable.Append(",");
                        }

                        index++;
                    }

                    stringTable.AppendLine();
                }

                File.WriteAllText(path, stringTable.ToString());

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #8
0
            /// <summary>
            /// Exports the specified StringTable XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                StringTableXAsset header = instance.Reader.ReadStruct <StringTableXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

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

                StringBuilder stringTable = new StringBuilder();

                for (int x = 0; x < header.RowCount; x++)
                {
                    for (int y = 0; y < header.ColumnCount; y++)
                    {
                        uint   data  = instance.Reader.ReadStruct <uint>(header.Values);
                        string value = instance.Reader.ReadNullTerminatedString(data);

                        stringTable.Append(value);

                        if (y != (header.ColumnCount - 1))
                        {
                            stringTable.Append(",");
                        }

                        header.Values += (uint)Marshal.SizeOf <uint>();
                    }

                    stringTable.AppendLine();
                }

                File.WriteAllText(path, stringTable.ToString());

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #9
0
            /// <summary>
            /// Exports the specified TTF XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                TTFDef header = instance.Reader.ReadStruct <TTFDef>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

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

                byte[] buffer = instance.Reader.ReadBytes(header.File, (int)header.FileLen);

                File.WriteAllBytes(path, buffer);

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }
Exemple #10
0
 /// <summary>
 /// Exports the specified Localize XAsset.
 /// </summary>
 /// <param name="xasset"></param>
 /// <param name="instance"></param>
 /// <returns>Status of the export operation.</returns>
 public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
 {
     return(JekyllStatus.Success);
 }
Exemple #11
0
 /// <summary>
 /// Exports the given XAsset from the current game.
 /// </summary>
 public abstract JekyllStatus Export(GameXAsset xasset, JekyllInstance instance);