Exemplo n.º 1
0
        public void Export()
        {
            try
            {
                String exportPath = ExportPath;
                if (File.Exists(exportPath))
                {
                    Log.Warning($"[{TypeName}] Export was skipped bacause a file already exists: [{exportPath}].");
                    return;
                }

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

                TxtEntry[] abilities = PrepareEntries();

                FileCommander.PrepareFileDirectory(exportPath);
                TxtWriter.WriteStrings(exportPath, abilities);

                Log.Message($"[{TypeName}] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{TypeName}] Failed to export resource.");
            }
        }
Exemplo n.º 2
0
 private static void ExportCustomTags(FieldFormatter formatter)
 {
     TxtEntry[] generalNames = formatter.Names.General;
     if (generalNames != null)
     {
         TxtWriter.WriteStrings(ModTextResources.Export.FieldTags, generalNames);
     }
 }
Exemplo n.º 3
0
        public void Export()
        {
            try
            {
                Log.Message($"[{nameof(LocationNameExporter)}] Exporting...");
                Int32 skipped = 0;

                String text = EmbadedSentenseLoader.LoadText(EmbadedTextResources.LocationNames);

                Dictionary <Int32, String> locationNames = new Dictionary <Int32, String>();
                String[] array = text.Split('\r');
                for (Int32 i = 0; i < array.Length; i++)
                {
                    String str = array[i];
                    str = str.Replace("\n", String.Empty);
                    if (!String.IsNullOrEmpty(str))
                    {
                        String key   = str.Split(':')[0];
                        String value = str.Split(':')[1];
                        locationNames[Int32.Parse(key)] = FF9TextTool.RemoveOpCode(value);
                    }
                }

                Dictionary <String, LinkedList <TxtEntry> > entries = LocationNameFormatter.Build(locationNames);

                String directory = ModTextResources.Export.LocationNamesDirectory;
                Directory.CreateDirectory(directory);

                Char[] invalidChars = Path.GetInvalidFileNameChars();
                foreach (KeyValuePair <String, LinkedList <TxtEntry> > pair in entries)
                {
                    String outputPath = Path.Combine(directory, "Names of " + pair.Key.ReplaceChars("_", invalidChars) + ".strings");
                    if (File.Exists(outputPath))
                    {
                        skipped++;
                        continue;
                    }

                    TxtWriter.WriteStrings(outputPath, pair.Value.ToArray());
                }

                if (skipped > 0)
                {
                    Log.Warning($"[{nameof(LocationNameExporter)}] Exporting completed but [{skipped}/{entries.Count}] files has been skipped because already exists.");
                }
                else
                {
                    Log.Message($"[{nameof(LocationNameExporter)}] Exporting completed successfully.");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{nameof(LocationNameExporter)}] Failed to export resource.");
            }
        }
Exemplo n.º 4
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.º 5
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();

                KeyValuePair <Int32, String> chocoboForest = new KeyValuePair <Int32, String>(945, "MES_CHOCO");
                foreach (KeyValuePair <Int32, String> pair in ExtensionMethodsIEnumerable.Append(FF9DBAll.EventDB, chocoboForest))
                {
                    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 = FF9TextTool.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.");
            }
        }