Ejemplo n.º 1
0
            /// <summary>
            /// Load the valid XAssets for the StringTable XAsset Pool.
            /// </summary>
            /// <param name="instance"></param>
            /// <returns>List of StringTable XAsset objects.</returns>
            public override List <GameXAsset> Load(JekyllInstance instance)
            {
                List <GameXAsset> results = new List <GameXAsset>();

                Entries  = instance.Reader.ReadStruct <long>(instance.Game.DBAssetPools + (Marshal.SizeOf <DBAssetPool>() * Index));
                PoolSize = instance.Reader.ReadStruct <int>(instance.Game.DBAssetPoolSizes + (Marshal.SizeOf <DBAssetPoolSize>() * Index));

                for (int i = 0; i < PoolSize; i++)
                {
                    StringTableXAsset header = instance.Reader.ReadStruct <StringTableXAsset>(Entries + Marshal.SizeOf <DBAssetPool>() + (i * Marshal.SizeOf <StringTableXAsset>()));

                    if (IsNullXAsset(header.Name))
                    {
                        continue;
                    }
                    else if (instance.Reader.ReadNullTerminatedString(header.Name).EndsWith(".csv") is false)
                    {
                        continue;
                    }

                    results.Add(new GameXAsset()
                    {
                        Name          = instance.Reader.ReadNullTerminatedString(header.Name),
                        Type          = Name,
                        Size          = ElementSize,
                        XAssetPool    = this,
                        HeaderAddress = Entries + Marshal.SizeOf <DBAssetPool>() + (i * Marshal.SizeOf <StringTableXAsset>()),
                    });
                }

                return(results);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Load the valid XAssets for the StringTable XAsset Pool.
            /// </summary>
            /// <param name="instance"></param>
            /// <returns>List of StringTable XAsset objects.</returns>
            public override List <GameXAsset> Load(JekyllInstance instance)
            {
                List <GameXAsset> results = new List <GameXAsset>();

                DBAssetPool pool = instance.Reader.ReadStruct <DBAssetPool>(instance.Game.DBAssetPools + (Index * Marshal.SizeOf <DBAssetPool>()));

                Entries     = pool.Entries;
                ElementSize = pool.ElementSize;
                PoolSize    = pool.PoolSize;

                for (int i = 0; i < PoolSize; i++)
                {
                    StringTableXAsset header = instance.Reader.ReadStruct <StringTableXAsset>(Entries + (i * ElementSize));

                    if (IsNullXAsset(header.Name))
                    {
                        continue;
                    }

                    results.Add(new GameXAsset()
                    {
                        Name          = instance.Reader.ReadNullTerminatedString(header.Name),
                        Type          = Name,
                        Size          = ElementSize,
                        XAssetPool    = this,
                        HeaderAddress = Entries + (i * ElementSize),
                    });
                }

                return(results);
            }
Ejemplo n.º 3
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);
            }
Ejemplo n.º 4
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);
            }