Exemplo n.º 1
0
 private static void ExportCustomTags(FieldFormatter formatter)
 {
     TxtEntry[] generalNames = formatter.Names.General;
     if (generalNames != null)
     {
         TxtWriter.WriteStrings(ModTextResources.Export.FieldTags, generalNames);
     }
 }
Exemplo n.º 2
0
        private static void ExportTags(String directory, FieldFormatter formatter)
        {
            if (directory == null)
            {
                return;
            }

            ExportCustomTags(formatter);
            ExportFieldTags(directory, formatter);
        }
Exemplo n.º 3
0
        private static void ExportFieldTags(String directory, FieldFormatter formatter)
        {
            Dictionary <String, TxtEntry[]> fieldNames = formatter.Names.Fields;

            if (fieldNames == null)
            {
                return;
            }

            foreach (KeyValuePair <String, TxtEntry[]> pair in fieldNames)
            {
                String fieldPath = Path.Combine(directory, pair.Key + "_Tags.strings");
                TxtWriter.WriteStrings(fieldPath, pair.Value);
            }
        }
Exemplo n.º 4
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.");
            }
        }