Example #1
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);
        }
Example #2
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;
        }
Example #3
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());
        }
Example #4
0
        private static String ReplaceComplexTag(String str, StringBuilder word, ref Int32 index, ref Int32 length)
        {
            Int32  offset = length;
            String incompleteTag;

            if (BattleFormatter.IsIncompleteTag(str, '}', word, ref index, ref length, out incompleteTag))
            {
                return(incompleteTag);
            }

            String result;

            switch (word.ToString(0, offset))
            {
            case "{W":
                result = "[STRT=" + String.Join(",", (word.ToString(offset, length - offset - 1) + ']').Split('H'));
                return(result);

            case "{Variable ":
                result = "[NUMB=";
                break;

            case "{Icon ":
                result = "[ICON=";
                break;

            case "{Icon+ ":
                result = "[PNEW=";
                break;

            case "{Speed ":
                result = "[SPED=";
                break;

            case "{Text ":
                result = "[TEXT=";
                break;

            case "{Widths ":
                result = "[WDTH=";
                break;

            case "{Time ":
                result = "[TIME=";
                break;

            case "{Wait ":
                result = "[WAIT=";
                break;

            case "{Center ":
                result = "[CENT=";
                break;

            case "{Item ":
                result = "[ITEM=";
                break;

            case "{PreChoose ":
                result = "[PCHC=";
                break;

            case "{PreChooseMask ":
                result = "[PCHM=";
                break;

            case "{Position ":
                result = "[MPOS=";
                break;

            case "{Offset ":
                result = "[OFFT=";
                break;

            case "{Mobile ":
                result = "[MOBI=";
                break;

            case "{y":
                result = "[YADD=";
                break;

            case "{y-":
                result = "[YSUB=";
                break;

            case "{f":
                result = "[FEED=";
                break;

            case "{x":
                result = "[XTAB=";
                break;

            case "{Table ":
                result = "[TBLE=";
                break;

            default:
                return(word.ToString());
            }

            result += word.ToString(offset, length - offset - 1) + ']';
            return(result);
        }