Beispiel #1
0
        private static void AddFromNode_Translation(TyMod tymod, XmlNode node)
        {
            string         name;
            TyModTranslate modTranslate;

            try { name = node.Attributes.GetNamedItem("name").Value; } catch (Exception e) { Program.Log(tymod.ToString(), "Invalid or missing name attribute for translation \"" + node.OuterXml + "\"", e); return; }

            modTranslate = new TyModTranslate(name);

            foreach (XmlNode child in node.ChildNodes)
            {
                name = child.Name.ToLower();
                if (child.HasTextChild())
                {
                    if (modTranslate.Translations.ContainsKey(name))
                    {
                        modTranslate.Translations[name] = child.GetFirstTextChild();
                    }
                    else
                    {
                        modTranslate.Translations.Add(name, child.GetFirstTextChild());
                    }
                }
            }

            tymod.Translations.Add(modTranslate);
        }
Beispiel #2
0
        public static void ApplyTranslate(Dictionary <string, TyTranslation> translations, TyModTranslate edit)
        {
            foreach (string key in edit.Translations.Keys)
            {
                if (!translations.ContainsKey(key))
                {
                    continue;
                }

                string        value = edit.Translations[key];
                TyTranslation trans = translations[key];

                if (trans.Translations.ContainsKey(edit.Name))
                {
                    trans.Translations[edit.Name] = value;
                }

                // No longer can support adding new translations
                // They could interfere with custom maps

                //else
                //    trans.Translations.Add(edit.Name, value);
            }
        }