Ejemplo n.º 1
0
        private void ReplaceDictionary()
        {
            try
            {
                if (_languageIndex < 0)
                {
                    return;
                }

                if (!Configuration.Import.Enabled || !Configuration.Import.Text)
                {
                    return;
                }

                String importPath = ModTextResources.Import.GetCurrentPath(ModTextResources.SystemPath);
                if (!File.Exists(importPath))
                {
                    Log.Warning($"[LocalizationDictionary] Loading was skipped because a file does not exists: [{importPath}]...");
                }

                Log.Message($"[LocalizationDictionary] Loading from [{importPath}]...");

                TxtEntry[] entries = TxtReader.ReadStrings(importPath);
                Dictionary <string, string> dic = CreateReplaceDictionary(entries);

                Log.Message("[LocalizationDictionary] Loading completed successfully.");
                SetReplacement(dic);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[LocalizationDictionary] Failed to load text.");
            }
        }
Ejemplo n.º 2
0
        protected override Boolean LoadExternal()
        {
            try
            {
                String importDirectory = ImportDirectory;
                if (!Directory.Exists(importDirectory))
                {
                    Log.Warning($"[{TypeName}] Import was skipped bacause a directory does not exist: [{importDirectory}].");
                    return(false);
                }

                Log.Message($"[{TypeName}] Importing from [{importDirectory}]...");

                Dictionary <Int32, String> locationNames = FF9TextToolAccessor.GetLocationName();
                foreach (String filePath in Directory.GetFiles(importDirectory, "Names of *", SearchOption.TopDirectoryOnly))
                {
                    TxtEntry[] entries = TxtReader.ReadStrings(filePath);
                    LocationNameFormatter.Fill(filePath, entries, locationNames);
                }

                Log.Message($"[{TypeName}] Importing completed successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{TypeName}] Failed to import resource from.");
                return(false);
            }
        }
Ejemplo n.º 3
0
        protected override Boolean LoadExternal()
        {
            try
            {
                String importPath = ImportPath;
                if (!File.Exists(importPath))
                {
                    Log.Warning($"[{TypeName}] Import was skipped bacause a file does not exist: [{importPath}].");
                    return(false);
                }

                Log.Message($"[{TypeName}] Importing from [{importPath}]...");

                TxtEntry[] entries = TxtReader.ReadStrings(importPath);

                ProcessEntries(entries);

                Log.Message($"[{TypeName}] Importing completed successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{TypeName}] Failed to import resource from.");
                return(false);
            }
        }
Ejemplo n.º 4
0
        private Boolean ReadExternalText(out TxtEntry[] entries)
        {
            String inputPath = Path.Combine(ModTextResources.Import.FieldsDirectory, _fieldFileName + ".strings");

            if (!File.Exists(inputPath))
            {
                entries = null;
                return(false);
            }

            entries = TxtReader.ReadStrings(inputPath);
            return(!entries.IsNullOrEmpty());
        }
Ejemplo n.º 5
0
        private Boolean TryLoadReplacements(out Dictionary <String, String> dic)
        {
            String importPath = ModTextResources.Import.Battle;

            if (!File.Exists(importPath))
            {
                Log.Warning($"[{TypeName}] Import was skipped bacause a file does not exist: [{importPath}].");
                dic = null;
                return(false);
            }

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

            TxtEntry[] entries = TxtReader.ReadStrings(importPath);

            BattleFormatter.Parse(entries, out dic);

            Log.Message($"[{TypeName}] Loading completed successfully.");
            return(true);
        }
Ejemplo n.º 6
0
        private static IList <KeyValuePair <String, TextReplacement> > ReadTagReplacements(String inputPath)
        {
            if (!File.Exists(inputPath))
            {
                return(new List <KeyValuePair <String, TextReplacement> >());
            }

            TxtEntry[] generalNames = TxtReader.ReadStrings(inputPath);
            if (generalNames.IsNullOrEmpty())
            {
                return(new List <KeyValuePair <String, TextReplacement> >());
            }

            TextReplacements result = new TextReplacements(generalNames.Length);

            foreach (TxtEntry entry in generalNames)
            {
                result.Add(entry.Prefix, entry.Value);
            }

            return(result.Forward);
        }