示例#1
0
        protected override Boolean LoadInternal()
        {
            Int32  battleZoneId = FF9TextToolAccessor.GetBattleZoneId();
            String path         = EmbadedTextResources.GetCurrentPath("/Battle/" + battleZoneId + ".mes");

            String[] text = EmbadedSentenseLoader.LoadSentense(path);
            if (text != null)
            {
                FF9TextToolAccessor.SetBattleText(text);
            }
            return(true);
        }
示例#2
0
        private static Boolean ReadEmbadedText(Int32 fieldZoneId, out String[] text)
        {
            String path = EmbadedTextResources.GetCurrentPath("/Field/" + FF9TextToolInterceptor.GetFieldTextFileName(fieldZoneId) + ".mes");
            String raw  = EmbadedSentenseLoader.LoadText(path);

            if (raw != null)
            {
                raw  = TextOpCodeModifier.Modify(raw);
                text = FF9TextToolInterceptor.ExtractSentense(raw);
                return(true);
            }

            text = null;
            return(false);
        }
示例#3
0
        public void Export()
        {
            try
            {
                String directory = ModTextResources.Export.FieldsDirectory;
                if (Directory.Exists(directory))
                {
                    Log.Warning($"[{nameof(FieldExporter)}] Some fields refer to each other. They should be exported together.");
                    Log.Warning($"[{nameof(FieldExporter)}] Export was skipped bacause the directory already exists: [{directory}].");
                    return;
                }

                Log.Message($"[{nameof(FieldExporter)}] Exporting...");
                FieldFormatter formatter = new FieldFormatter();

                foreach (KeyValuePair <Int32, String> pair in FF9DBAll.EventDB)
                {
                    Int32 fieldZoneId = pair.Key;

                    String path = EmbadedTextResources.GetCurrentPath("/Field/" + GetFieldTextFileName(fieldZoneId) + ".mes");
                    String text = EmbadedSentenseLoader.LoadText(path);
                    if (text == null)
                    {
                        continue;
                    }

                    String name = fieldZoneId.ToString("D4", CultureInfo.InvariantCulture) + '_' + pair.Value;
                    text = TextOpCodeModifier.Modify(text);
                    String[] lines = FF9TextToolInterceptor.ExtractSentense(text);

                    TxtEntry[] commands = formatter.Build(name, lines);

                    Directory.CreateDirectory(directory);
                    String outputPath = Path.Combine(directory, name + ".strings");
                    TxtWriter.WriteStrings(outputPath, commands);
                }

                ExportTags(directory, formatter);

                Log.Message($"[{nameof(FieldExporter)}] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{nameof(FieldExporter)}] Failed to export resource.");
            }
        }
示例#4
0
        private void Initialize()
        {
            Dictionary <String, String> dic;

            if (!TryLoadReplacements(out dic))
            {
                return;
            }

            Log.Message($"[{TypeName}] Loading...");

            foreach (KeyValuePair <String, Int32> pair in FF9BattleDB.SceneData)
            {
                Int32 index = pair.Value;
                if (index == 220 || index == 238) // Junk?
                {
                    continue;
                }

                String   path = EmbadedTextResources.GetCurrentPath("/Battle/" + index + ".mes");
                String[] text = EmbadedSentenseLoader.LoadSentense(path);
                if (text != null)
                {
                    for (Int32 i = 0; i < text.Length; i++)
                    {
                        String key = BattleFormatter.GetKey(text[i]);
                        String value;
                        if (dic.TryGetValue(key, out value))
                        {
                            text[i] = value;
                        }
                    }
                }

                _cache[index] = text;
            }

            _initialized = true;
        }
示例#5
0
        protected override TxtEntry[] PrepareEntries()
        {
            Dictionary <String, String> dic = new Dictionary <String, String>(1024);

            foreach (KeyValuePair <String, Int32> pair in FF9BattleDB.SceneData)
            {
                Int32 index = pair.Value;
                if (index == 220 || index == 238) // Junk?
                {
                    continue;
                }

                String   path = EmbadedTextResources.GetCurrentPath("/Battle/" + index + ".mes");
                String[] text = EmbadedSentenseLoader.LoadSentense(path);
                if (text == null)
                {
                    continue;
                }

                foreach (String line in text)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    String key = BattleFormatter.GetKey(line);
                    if (!dic.ContainsKey(key))
                    {
                        dic.Add(key, BattleFormatter.GetValue(line));
                    }
                }
            }

            return(dic.Select(p => new TxtEntry {
                Prefix = p.Key, Value = p.Value
            }).ToArray());
        }
        private static void ExportSceneSafe(String battleSceneName)
        {
            try
            {
                String relativePath    = "BattleMap/BattleScene/EVT_BATTLE_" + battleSceneName + '/';
                String outputDirectory = Path.Combine(Configuration.Export.Path, relativePath);
                String outputPath      = outputDirectory + "Main.json";
                if (File.Exists(outputPath))
                {
                    //Log.Warning($"[BattleSceneExporter] Export was skipped bacause a file already exists: [{outputPath}].");
                    //return;
                }

                Log.Message("[BattleSceneExporter] Exporting [{0}]...", battleSceneName);

                Int32    battleZoneId    = FF9BattleDB.SceneData["BSC_" + battleSceneName];
                String   textEmbadedPath = EmbadedTextResources.GetCurrentPath("/Battle/" + battleZoneId + ".mes");
                String[] text            = EmbadedSentenseLoader.LoadSentense(textEmbadedPath);

                BTL_SCENE btlScene = new BTL_SCENE();
                btlScene.ReadBattleScene(battleSceneName);

                String directoryPath = Path.GetDirectoryName(outputPath);
                if (directoryPath != null)
                {
                    Directory.CreateDirectory(directoryPath);
                }

                SerializeScene(btlScene, outputDirectory, text);
                CompileScene(outputDirectory);

                Log.Message("[BattleSceneExporter] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[BattleSceneExporter] Failed to export map [{0}].", battleSceneName);
            }
        }