Пример #1
0
            /// <summary>
            /// Load the valid XAssets for the Localize XAsset Pool.
            /// </summary>
            /// <param name="instance"></param>
            /// <returns>List of Localize XAsset objects.</returns>
            public override List <GameXAsset> Load(JekyllInstance instance)
            {
                List <GameXAsset> results = new List <GameXAsset>();

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

                Entries     = pool.Pool;
                ElementSize = pool.ItemSize;
                PoolSize    = (uint)pool.ItemCount;

                if (IsValidPool(Name, ElementSize, Marshal.SizeOf <LocalizeEntry>()) == false)
                {
                    return(results);
                }

                Dictionary <string, string> entries = new Dictionary <string, string>();

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

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

                    string key = instance.Reader.ReadNullTerminatedString(header.Name).ToUpper();

                    if (entries.TryGetValue(key, out string _))
                    {
                        continue;
                    }

                    string value = instance.Reader.ReadNullTerminatedString(header.Value, nullCheck: true);
                    entries.Add(key, value);

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

                string path = Path.Combine(instance.ExportPath, "localize.json");

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

                using (StreamWriter file = File.CreateText(path))
                {
                    file.Write(JsonConvert.SerializeObject(entries, Formatting.Indented));
                }

                return(results);
            }
Пример #2
0
            /// <summary>
            /// Load the valid XAssets for the Localize XAsset Pool.
            /// </summary>
            /// <param name="instance"></param>
            /// <returns>List of Localize XAsset objects.</returns>
            public override List <GameXAsset> Load(JekyllInstance instance)
            {
                Entries  = instance.Reader.ReadStruct <long>(instance.Game.DBAssetPools + (Marshal.SizeOf <DBAssetPool>() * Index));
                PoolSize = instance.Reader.ReadStruct <int>(instance.Game.DBAssetPoolSizes + (Marshal.SizeOf <DBAssetPoolSize>() * Index));

                Dictionary <string, string> entries = new Dictionary <string, string>();

                Console.WriteLine(PoolSize);

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

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

                    string key = instance.Reader.ReadNullTerminatedString(header.Name).ToUpper();

                    if (entries.TryGetValue(key, out string _))
                    {
                        continue;
                    }

                    string value = instance.Reader.ReadNullTerminatedString(header.Value);
                    entries.Add(key, value);

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

                string path = Path.Combine(instance.ExportPath, "localize.json");

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

                using (StreamWriter file = File.CreateText(path))
                {
                    file.Write(JsonConvert.SerializeObject(entries, Formatting.Indented));
                }

                return(new List <GameXAsset>());
            }