コード例 #1
0
        public bool Load(string path, string name)
        {
            using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
            {
                s.ReadAttribute("game", ref engine);

                bool inherited;
                if (inherited = s.ReadAttributeOpt("inheritFrom", ref inheritFrom))
                {
                    path = System.IO.Path.GetDirectoryName(inheritFrom);
                    name = System.IO.Path.GetFileName(inheritFrom);

                    if (!LoadInherited(path, name))
                    {
                        return(false);
                    }
                }

                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    if (!inherited && LoadProcessNode(s, n))
                    {
                        continue;
                    }
                    else if (n.Name == "functions")
                    {
                        s.SaveCursor(n);
                        ReadFunctions(s);                         // Load the definition's functions
                        s.RestoreCursor();
                    }
                    else if (n.Name == "globals")
                    {
                        s.SaveCursor(n);
                        ReadGlobals(s);                         // Load the definition's globals
                        s.RestoreCursor();
                    }
                }
            }

            return(true);
        }