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

                    //Debug.Assert.If(Engine == ver, "Version mismatch! '{0}' expected '{1}'", Engine.ToString(), ver.ToString());
                    #endregion

                    foreach (XmlNode n in s.Cursor.ChildNodes)
                    {
                        if (n.Name == "types")
                        {
                            s.SaveCursor(n);
                            TypesRead(s);
                            s.RestoreCursor();
                        }
                        else if (n.Name == "definitions")
                        {
                            s.SaveCursor(n);
                            DefinitionsRead(this, s);
                            s.RestoreCursor();
                        }
                    }
                }

                return(true);
            }
コード例 #2
0
 /// <summary>
 /// Process a XML manifest file containing CheApe tag definitions
 /// </summary>
 /// <param name="state"></param>
 /// <param name="path"></param>
 /// <param name="name"></param>
 public void ProcessFile(ProjectState state, string path, string name)
 {
     using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
     {
         ProcessFile(state, s);
     }
 }
コード例 #3
0
 /// <summary>
 /// Process a XML file containing CheApe tag definitions
 /// </summary>
 /// <param name="state"></param>
 /// <param name="file"></param>
 public void ProcessFile(ProjectState state, string file)
 {
     using (IO.XmlStream s = new BlamLib.IO.XmlStream(file, this))
     {
         ProcessFile(state, s);
     }
 }
        /// <summary>
        /// Load the string id data from an xml manifest file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="name"></param>
        public bool Load(string path, string name)
        {
            using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
            {
                StreamFromXml(s);
            }

            return(true);
        }
コード例 #5
0
        public void Read(string path, string name)
        {
            using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
            {
                s.ReadAttribute("game", ref engine);

                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    if (n.Name == "memory")
                    {
                        s.SaveCursor(n);
                        MemoryInfo = new MemoryInformation(s);
                        s.RestoreCursor();
                    }
                    else if (n.Name == "fieldTypes")
                    {
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "type")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            fieldTypes.Add(new FieldType(s));
                            s.RestoreCursor();
                        }
                        s.RestoreCursor();
                    }
                    else if (n.Name == "editorMarkup")
                    {
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "entry")
                            {
                                continue;
                            }

                            //s.SaveCursor(n2);
                            // TODO
                            //s.RestoreCursor();
                        }
                        s.RestoreCursor();
                    }
                }
            }
        }
コード例 #6
0
        private bool LoadInherited(string path, string name)
        {
            using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
            {
                BlamVersion inherited_engine = BlamVersion.Unknown;
                s.ReadAttribute("game", ref inherited_engine);

                Debug.Assert.If(inherited_engine.ToBuild() == engine.ToBuild(), "Inherit failed: expected '{0}', got '{1}' in '{2}{3}'",
                                engine.ToBuild().ToString(), inherited_engine.ToBuild().ToString(), path, name);

                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    LoadProcessNode(s, n);
                }
            }
            return(true);
        }
コード例 #7
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);
        }
コード例 #8
0
			public override bool Load(string path, string name)
			{
				using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
				{
					#region Game
					s.ReadAttribute("game", ref base.engine);

					//Debug.Assert.If(Engine == ver, "Version mismatch! '{0}' expected '{1}'", Engine.ToString(), ver.ToString());
					#endregion

					foreach (XmlNode n in s.Cursor.ChildNodes)
						if (n.Name == "types")
						{
							s.SaveCursor(n);
							TypesRead(s);
							s.RestoreCursor();
						}
						else if (n.Name == "definitions")
						{
							s.SaveCursor(n);
							DefinitionsRead(this, s);
							s.RestoreCursor();
						}						
				}

				return true;
			}
コード例 #9
0
ファイル: Definition.cs プロジェクト: CodeAsm/open-sauce
		public void Read(string path, string name)
		{
			using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
			{
				s.ReadAttribute("game", ref engine);

				foreach (XmlNode n in s.Cursor.ChildNodes)
					if (n.Name == "memory")
					{
						s.SaveCursor(n);
							MemoryInfo = new MemoryInformation(s);
						s.RestoreCursor();
					}
					else if (n.Name == "fieldTypes")
					{
						s.SaveCursor(n);
						foreach (XmlNode n2 in s.Cursor.ChildNodes)
						{
							if (n2.Name != "type") continue;

							s.SaveCursor(n2);
								fieldTypes.Add(new FieldType(s));
							s.RestoreCursor();
						}
						s.RestoreCursor();
					}
					else if(n.Name == "editorMarkup")
					{
						s.SaveCursor(n);
						foreach (XmlNode n2 in s.Cursor.ChildNodes)
						{
							if (n2.Name != "entry") continue;

							//s.SaveCursor(n2);
							// TODO
							//s.RestoreCursor();
						}
						s.RestoreCursor();
					}
			}
		}
コード例 #10
0
        /// <summary>
        /// Process a XML file containing CheApe definitions
        /// </summary>
        /// <param name="state"></param>
        /// <param name="s"></param>
        private void ProcessFile(ProjectState state, BlamLib.IO.XmlStream s)
        {
            int complexity = 1 +
                             PreprocessXmlNodeComplexity();

            BlamVersion def_engine = BlamVersion.Unknown;

            s.ReadAttribute("game", ref def_engine);
            if (def_engine != state.Definition.Engine)
            {
                Debug.Assert.If(false, "CheApe definition '{0}' is for {1}. Expected a {2} definition.", s.FileName, def_engine, state.Definition.Engine);
            }
            else
            {
                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    switch (n.Name)
                    {
                        #region Enums
                    case "enums":
                        s.SaveCursor(n);
                        ProcessEnums(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Flags
                    case "flags":
                        s.SaveCursor(n);
                        ProcessFlags(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Tag References
                    case "references":
                        s.SaveCursor(n);
                        ProcessTagReferences(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Tag Data
                    case "data":
                        s.SaveCursor(n);
                        ProcessTagDatas(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Script Functions
                    case "scriptFunctions":
                        if (state.scriptingInterface == null)
                        {
                            break;
                        }

                        s.SaveCursor(n);
                        ProcessScriptFunctions(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Script Globals
                    case "scriptGlobals":
                        if (state.scriptingInterface == null)
                        {
                            break;
                        }

                        s.SaveCursor(n);
                        ProcessScriptGlobals(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Fix-ups
                    case "fixups":
                        s.SaveCursor(n);
                        ProcessFixups(state, s);
                        s.RestoreCursor();
                        break;
                        #endregion

                    default:
                        ProcessDefinition(n, state, s);
                        break;
                    }
                }
            }
        }
コード例 #11
0
        protected override void ProcessDefinition(XmlNode node, BlamLib.CheApe.ProjectState state, BlamLib.IO.XmlStream s)
        {
            StringIdFieldsInitialize(state);

            string name_str;

            switch (node.Name)
            {
                #region Tag Structs
            case "structs":
                s.SaveCursor(node);
                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    if (n.Name != "Struct")
                    {
                        continue;
                    }

                    s.SaveCursor(n);
                    TagStruct block = new TagStruct(state, s);
                    s.RestoreCursor();
                    name_str = block.ToString();

                    try { Structs.Add(name_str, block); }
                    catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag struct definition", name_str); }
                }
                s.RestoreCursor();
                break;
                #endregion

                #region Tag Blocks
            case "blocks":
                s.SaveCursor(node);
                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    if (n.Name != "TagBlock")
                    {
                        continue;
                    }

                    s.SaveCursor(n);
                    TagBlock block = new TagBlock(state, s);
                    s.RestoreCursor();
                    name_str = block.ToString();

                    try { Blocks.Add(name_str, block); }
                    catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag block definition", name_str); }
                }
                s.RestoreCursor();
                break;
                #endregion

                #region Tag Groups
            case "groups":
                s.SaveCursor(node);
                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    if (n.Name != "TagGroup")
                    {
                        continue;
                    }

                    s.SaveCursor(n);
                    TagGroup group = new TagGroup(state, s);
                    s.RestoreCursor();
                    name_str = group.ToString();

                    try { Groups.Add(name_str, group); }
                    catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag group definition", name_str); }
                }
                s.RestoreCursor();
                break;
                #endregion
            }
        }
コード例 #12
0
        /// <summary>
        /// Process a XML file containing CheApe definitions
        /// </summary>
        /// <param name="state"></param>
        /// <param name="s"></param>
        private void ProcessFile(ProjectState state, BlamLib.IO.XmlStream s)
        {
            int complexity = 1 +
                             PreprocessXmlNodeComplexity();

            BlamVersion def_engine = BlamVersion.Unknown;

            s.ReadAttribute("game", ref def_engine);
            if (def_engine != state.Definition.Engine)
            {
                Debug.Assert.If(false, "CheApe definition '{0}' is for {1}. Expected a {2} definition.", s.FileName, def_engine, state.Definition.Engine);
            }
            else
            {
                string name_str;
                foreach (XmlNode n in s.Cursor.ChildNodes)
                {
                    switch (n.Name)
                    {
                        #region Enums
                    case "enums":
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "Enum")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            StringList list = new StringList(state, s);
                            s.RestoreCursor();
                            name_str = list.ToString();

                            try { Enums.Add(name_str, list); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "enum definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Flags
                    case "flags":
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "Flag")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            StringList list = new StringList(state, s);
                            s.RestoreCursor();
                            name_str = list.ToString();

                            try { Flags.Add(name_str, list); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "flag definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Tag References
                    case "references":
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "Reference")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            TagReference tagref = new TagReference(state, s);
                            s.RestoreCursor();
                            name_str = tagref.ToString();

                            try { References.Add(name_str, tagref); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "tag reference definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Tag Data
                    case "data":
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "TagData")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            TagData tagdata = new TagData(state, s);
                            s.RestoreCursor();
                            name_str = tagdata.ToString();

                            try { Data.Add(name_str, tagdata); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "tag data definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Script Functions
                    case "scriptFunctions":
                        if (state.scriptingInterface == null)
                        {
                            break;
                        }

                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "function")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            ScriptFunction sc = new ScriptFunction(state, s);
                            s.RestoreCursor();
                            name_str = sc.ToString();

                            if (state.scriptingInterface.Functions.Contains(name_str))
                            {
                                Debug.LogFile.WriteLine("Engine already contains a {0} named '{1}', skipping...", "script function", name_str);
                                continue;
                            }

                            try { ScriptFunctions.Add(name_str, sc); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "script function definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Script Globals
                    case "scriptGlobals":
                        if (state.scriptingInterface == null)
                        {
                            break;
                        }

                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "global")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            ScriptGlobal sc = new ScriptGlobal(state, s);
                            s.RestoreCursor();
                            name_str = sc.ToString();

                            if (state.scriptingInterface.Globals.Contains(name_str))
                            {
                                Debug.LogFile.WriteLine("Engine already contains a {0} named '{1}', ignoring...", "script global", name_str);
                                continue;
                            }

                            try { ScriptGlobals.Add(name_str, sc); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "script global definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                        #region Fix-ups
                    case "fixups":
                        s.SaveCursor(n);
                        foreach (XmlNode n2 in s.Cursor.ChildNodes)
                        {
                            if (n2.Name != "fixup")
                            {
                                continue;
                            }

                            s.SaveCursor(n2);
                            Fixup fu = new Fixup(state, s);
                            s.RestoreCursor();
                            name_str = fu.ToString();

                            try { Fixups.Add(name_str, fu); }
                            catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "fix-up definition", name_str); }
                        }
                        s.RestoreCursor();
                        break;
                        #endregion

                    default:
                        ProcessDefinition(n, state, s);
                        break;
                    }
                }
            }
        }
コード例 #13
0
ファイル: Import.cs プロジェクト: guardian2433/open-sauce
		/// <summary>
		/// Process a XML manifest file containing CheApe tag definitions
		/// </summary>
		/// <param name="state"></param>
		/// <param name="path"></param>
		/// <param name="name"></param>
		public void ProcessFile(ProjectState state, string path, string name)
		{
			using (IO.XmlStream s = new BlamLib.IO.XmlStream(path, name, this))
			{
				ProcessFile(state, s);
			}
		}
コード例 #14
0
ファイル: Import.cs プロジェクト: guardian2433/open-sauce
		/// <summary>
		/// Process a XML file containing CheApe tag definitions
		/// </summary>
		/// <param name="state"></param>
		/// <param name="file"></param>
		public void ProcessFile(ProjectState state, string file)
		{
			using (IO.XmlStream s = new BlamLib.IO.XmlStream(file, this))
			{
				ProcessFile(state, s);
			}
		}
コード例 #15
0
        protected override void ProcessDefinition(XmlNode node, BlamLib.CheApe.ProjectState state, BlamLib.IO.XmlStream s)
        {
            StringIdFieldsInitialize(state);

            switch (node.Name)
            {
                #region Tag Structs
            case "structs":
                s.SaveCursor(node);
                ProcessTagStructs(state, s);
                s.RestoreCursor();
                break;
                #endregion

                #region Tag Blocks
            case "blocks":
                s.SaveCursor(node);
                ProcessTagBlocks(state, s);
                s.RestoreCursor();
                break;
                #endregion

                #region Tag Groups
            case "groups":
                s.SaveCursor(node);
                ProcessTagGroups(state, s);
                s.RestoreCursor();
                break;
                #endregion
            }
        }