示例#1
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);
            }
        }
示例#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 = FF9TextTool.LocationNames;
                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);
            }
        }
示例#3
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}]...");
                    return;
                }

                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.");
            }
        }
示例#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());
        }
示例#5
0
        private void LoadExternalText()
        {
            if (!Configuration.Import.Text)
            {
                return;
            }

            foreach (SortedList <String, String> languageDic in _languages.Values)
            {
                if (!languageDic.TryGetValue(SymbolKey, out String symbol))
                {
                    continue;
                }

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

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

                TxtEntry[] entries = TxtReader.ReadStrings(importPath);
                foreach (TxtEntry entry in entries)
                {
                    if (entry == null)
                    {
                        continue;
                    }

                    switch (entry.Prefix)
                    {
                    case "KEY":
                    case "Symbol":
                    case "Name":
                    case "":
                        continue;
                    }

                    languageDic[entry.Prefix] = entry.Value;
                }
            }
            Log.Message("[LocalizationDictionary] Loading completed successfully.");
        }
示例#6
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);
        }
示例#7
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);
        }