Esempio n. 1
0
            /// <summary>
            /// Exports the given asset from this pool
            /// </summary>
            public HydraStatus Export(GameAsset asset, HydraInstance instance)
            {
                var header = instance.Reader.ReadStruct <StringTableAsset>(asset.HeaderAddress);

                if (asset.Name != instance.Reader.ReadNullTerminatedString(header.NamePointer))
                {
                    return(HydraStatus.MemoryChanged);
                }

                string path = Path.Combine("exported_files", instance.Game.Name, asset.Name);

                // Create path
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                // Read read table (raw size will = (RowCount * ColumnCount) * sizeof(StringTableCell) (which is 16)
                byte[] buffer = instance.Reader.ReadBytes(header.CellsPointer, (header.RowCount * header.ColumnCount) * 16);
                // Output result
                var result = new StringBuilder();

                // Loop through rows
                for (int x = 0; x < header.RowCount; x++)
                {
                    // Loop through columns for this row
                    for (int y = 0; y < header.ColumnCount; y++)
                    {
                        // Add cell
                        result.Append(instance.Reader.ReadNullTerminatedString(Bytes.BytesToStruct <StringTableAsset.Cell>(buffer, ((x * header.ColumnCount) + y) * 16).StringPointer) + ",");
                    }
                    // Create new line
                    result.AppendLine();
                }
                // Write result
                File.WriteAllText(path, result.ToString());

                return(HydraStatus.Success);
            }