示例#1
0
        void ProcessTagReferences(ProjectState state, IO.XmlStream s)
        {
            foreach (XmlNode n in s.Cursor.ChildNodes)
            {
                if (n.Name != "Reference")
                {
                    continue;
                }

                s.SaveCursor(n);
                var tagref = new TagReference(state, s);
                s.RestoreCursor();
                string name_str = tagref.ToString();

                try { References.Add(name_str, tagref); }
                catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "tag reference definition", name_str); }
            }
        }
示例#2
0
		void ProcessTagReferences(ProjectState state, IO.XmlStream s)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != "Reference") continue;

				s.SaveCursor(n);
				var tagref = new TagReference(state, s);
				s.RestoreCursor();
				string name_str = tagref.ToString();

				try { References.Add(name_str, tagref); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "tag reference definition", name_str); }
			}
		}
示例#3
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;
                    }
                }
            }
        }
示例#4
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;
					}
				}
			}
		}