Ejemplo n.º 1
0
        public static void Repack(string sourceFile)
        {
            LUAINFO     info = new LUAINFO();
            XmlDocument xml  = new XmlDocument();

            xml.Load(sourceFile);
            info.BigEndian  = bool.Parse(xml.SelectSingleNode("luainfo/bigendian").InnerText);
            info.LongFormat = bool.Parse(xml.SelectSingleNode("luainfo/longformat").InnerText);

            foreach (XmlNode node in xml.SelectNodes("luainfo/goals/goal"))
            {
                int    id                 = int.Parse(node.Attributes["id"].InnerText);
                string name               = node.SelectSingleNode("name").InnerText;
                bool   battleInterrupt    = bool.Parse(node.SelectSingleNode("battleinterrupt").InnerText);
                bool   logicInterrupt     = bool.Parse(node.SelectSingleNode("logicinterrupt").InnerText);
                string logicInterruptName = node.SelectSingleNode("logicinterruptname")?.InnerText;
                info.Goals.Add(new LUAINFO.Goal(id, name, battleInterrupt, logicInterrupt, logicInterruptName));
            }

            string outPath = sourceFile.Replace(".luainfo.xml", ".luainfo");

            if (File.Exists(outPath) && !File.Exists(outPath + ".bak"))
            {
                File.Copy(outPath, outPath + ".bak");
            }
            info.Write(outPath);
        }