Esempio n. 1
0
		public idNamedEvent(string name)
		{
			_name = name;
			_scriptList = new idGuiScriptList();
		}
Esempio n. 2
0
		private bool ParseScript(idScriptParser parser, idGuiScriptList list, bool elseBlock = false)
		{
			bool ifElseBlock = false;

			idToken token;

			// scripts start with { ( unless parm is true ) and have ; separated command lists.. commands are command,
			// arg.. basically we want everything between the { } as it will be interpreted at
			// run time
			if(elseBlock == true)
			{
				token = parser.ReadToken();

				if(token.ToString().ToLower() == "if")
				{
					ifElseBlock = true;
				}

				parser.UnreadToken(token);

				if((ifElseBlock == false) && (parser.ExpectTokenString("{") == false))
				{
					return false;
				}
			}
			else if(parser.ExpectTokenString("{") == false)
			{
				return false;
			}

			int nest = 0;
			string tokenLower;

			while(true)
			{
				if((token = parser.ReadToken()) == null)
				{
					parser.Error("Unexpected end of file");
					return false;
				}

				tokenLower = token.ToString().ToLower();

				if(tokenLower == "{")
				{
					nest++;
				}
				else if(tokenLower == "}")
				{
					if(nest-- <= 0)
					{
						return true;
					}
				}

				idGuiScript script = new idGuiScript();

				if(tokenLower == "if")
				{
					script.ConditionRegister = ParseExpression(parser);

					ParseScript(parser, script.IfList);

					if((token = parser.ReadToken()) != null)
					{
						if(token.ToString() == "else")
						{
							// pass true to indicate we are parsing an else condition
							ParseScript(parser, script.ElseList, true);
						}
						else
						{
							parser.UnreadToken(token);
						}
					}

					list.Append(script);

					// if we are parsing an else if then return out so 
					// the initial "if" parser can handle the rest of the tokens
					if(ifElseBlock == true)
					{
						return true;
					}

					continue;
				}
				else
				{
					parser.UnreadToken(token);
				}

				// empty { } is not allowed
				if(token.ToString() == "{")
				{
					parser.Error("Unexpected {");
					return false;
				}

				script.Parse(parser);
				list.Append(script);
			}
		}
Esempio n. 3
0
		private bool ParseScriptEntry(idToken token, idScriptParser parser)
		{
			int count = (int) ScriptName.Count;
			string tokenLower = token.ToString().ToLower();

			for(int i = 0; i < count; i++)
			{
				if(tokenLower == ScriptNames[i].ToLower())
				{
					_scripts[i] = new idGuiScriptList();

					return ParseScript(parser, _scripts[i]);
				}
			}

			return false;
		}
Esempio n. 4
0
		public bool RunScriptList(idGuiScriptList list)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(list == null)
			{
				return false;
			}

			list.Execute(this);

			return true;
		}