Example #1
0
		public override idWindowVariable GetVariableByName(string name, bool fixup, ref DrawWindow owner)
		{
			if(name.ToLower() == "bind")
			{
				return _bindName;
			}

			return base.GetVariableByName(name, fixup, ref owner);
		}
Example #2
0
		public override idWindowVariable GetVariableByName(string name, bool fixup, ref DrawWindow owner)
		{
			string nameLower = name.ToLower();

			if(nameLower == "cvar")
			{
				return _cvarStr;
			}
			else if(nameLower == "password")
			{
				return _password;
			}
			else if(nameLower == "liveupdate")
			{
				return _liveUpdate;
			}
			else if(nameLower == "cvargroup")
			{
				return _cvarGroup;
			}

			return base.GetVariableByName(name, fixup, ref owner);
		}
Example #3
0
		public override idWindowVariable GetVariableByName(string name, bool fixup, ref DrawWindow owner)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			string nameLower = name.ToLower();

			if(nameLower == "choices")
			{
				return _choicesStr;
			}
			else if(nameLower == "values")
			{
				return _choiceValues;
			}
			else if(nameLower == "cvar")
			{
				return _cvarStr;
			}
			else if(nameLower == "gui")
			{
				return _guiStr;
			}
			else if(nameLower == "liveupdate")
			{
				return _liveUpdate;
			}
			else if(nameLower == "updategroup")
			{
				return _updateGroup;
			}

			return base.GetVariableByName(name, fixup, ref owner);
		}
Example #4
0
		public override idWindowVariable GetVariableByName(string name, bool fixup, ref DrawWindow owner)
		{
			string nameLower = name.ToLower();

			if(nameLower == "model")
			{
				return _modelName;
			}
			else if(nameLower == "anim")
			{
				return _animationName;
			}
			else if(nameLower == "lightorigin")
			{
				return _lightOrigin;
			}
			else if(nameLower == "lightcolor")
			{
				return _lightColor;
			}
			else if(nameLower == "modelorigin")
			{
				return _modelOrigin;
			}
			else if(nameLower == "modelrotate")
			{
				return _modelRotate;
			}
			else if(nameLower == "viewoffset")
			{
				return _viewOffset;
			}
			else if(nameLower == "needsrender")
			{
				return _needsRender;
			}

			return base.GetVariableByName(name, fixup, ref owner);
		}
Example #5
0
		public bool Parse(idScriptParser parser, bool rebuild)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(rebuild == true)
			{
				CleanUp();
			}

			_timeLineEvents.Clear();
			_namedEvents.Clear();
			_transitions.Clear();

			idToken token2;
			idToken token = parser.ExpectTokenType(TokenType.Name, 0);
			DrawWindow drawWindow;

			SetInitialState(token.ToString());

			parser.ExpectTokenString("{");
			token = parser.ExpectAnyToken();

			bool ret = true;

			while(token.ToString() != "}")
			{
				string tokenLower = token.ToString().ToLower();

				// track what was parsed so we can maintain it for the guieditor
				parser.SetMarker();

				if((tokenLower == "windowdef") || (tokenLower == "animationdef"))
				{
					if(tokenLower == "animationdef")
					{
						_visible.Set(false);
						_rect.Set(new idRectangle(0, 0, 0, 0));
					}

					token = parser.ExpectTokenType(TokenType.Name, 0);
					token2 = token;

					parser.UnreadToken(token);

					drawWindow = FindChildByName(token2.ToString());

					if((drawWindow != null) && (drawWindow.Window != null))
					{
						SaveExpressionParseState();
						drawWindow.Window.Parse(parser, rebuild);
						RestoreExpressionParseState();
					}
					else
					{
						idWindow window = new idWindow(_gui, _context);

						SaveExpressionParseState();
						window.Parse(parser, rebuild);
						RestoreExpressionParseState();

						window.Parent = this;

						drawWindow = new DrawWindow();

						if(window.IsSimple == true)
						{
							drawWindow.Simple = new idSimpleWindow(window);
							_drawWindows.Add(drawWindow);
						}
						else
						{
							AddChild(window);
							SetFocus(window, false);

							drawWindow.Window = window;
							_drawWindows.Add(drawWindow);
						}
					}
				}
				else if(tokenLower == "editdef")
				{
					SaveExpressionParseState();

					idEditWindow window = new idEditWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "choicedef")
				{
					SaveExpressionParseState();

					idChoiceWindow window = new idChoiceWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "sliderdef")
				{
					SaveExpressionParseState();

					idSliderWindow window = new idSliderWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "markerdef")
				{
					idConsole.Warning("TODO: markerDef");
					/*idMarkerWindow *win = new idMarkerWindow(dc, gui);
					SaveExpressionParseState();
					win->Parse(src, rebuild);	
					RestoreExpressionParseState();
					AddChild(win);
					win->SetParent(this);
					dwt.simp = NULL;
					dwt.win = win;
					drawWindows.Append(dwt);*/
				}
				else if(tokenLower == "binddef")
				{
					SaveExpressionParseState();

					idBindWindow window = new idBindWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "listdef")
				{
					SaveExpressionParseState();

					idListWindow window = new idListWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "fielddef")
				{
					idConsole.Warning("TODO: fieldDef");
					/*idFieldWindow *win = new idFieldWindow(dc, gui);
					SaveExpressionParseState();
					win->Parse(src, rebuild);	
					RestoreExpressionParseState();
					AddChild(win);
					win->SetParent(this);
					dwt.simp = NULL;
					dwt.win = win;
					drawWindows.Append(dwt);*/
				}
				else if(tokenLower == "renderdef")
				{					
					SaveExpressionParseState();

					idRenderWindow window = new idRenderWindow(_context, _gui);
					window.Parse(parser, rebuild);

					RestoreExpressionParseState();

					AddChild(window);

					window.Parent = this;

					drawWindow = new DrawWindow();
					drawWindow.Simple = null;
					drawWindow.Window = window;

					_drawWindows.Add(drawWindow);
				}
				else if(tokenLower == "gamessddef")
				{
					idConsole.Warning("TODO: gameSSDDef");
					/*idGameSSDWindow *win = new idGameSSDWindow(dc, gui);
					SaveExpressionParseState();
					win->Parse(src, rebuild);	
					RestoreExpressionParseState();
					AddChild(win);
					win->SetParent(this);
					dwt.simp = NULL;
					dwt.win = win;
					drawWindows.Append(dwt);*/
				}
				else if(tokenLower == "gamebearshootdef")
				{
					idConsole.Warning("TODO: gameBearShootDef");
					/*idGameBearShootWindow *win = new idGameBearShootWindow(dc, gui);
					SaveExpressionParseState();
					win->Parse(src, rebuild);	
					RestoreExpressionParseState();
					AddChild(win);
					win->SetParent(this);
					dwt.simp = NULL;
					dwt.win = win;
					drawWindows.Append(dwt);*/
				}
				else if(tokenLower == "gamebustoutdef")
				{
					idConsole.Warning("TODO: gameBustOutDef");
					/*idGameBustOutWindow *win = new idGameBustOutWindow(dc, gui);
					SaveExpressionParseState();
					win->Parse(src, rebuild);	
					RestoreExpressionParseState();
					AddChild(win);
					win->SetParent(this);
					dwt.simp = NULL;
					dwt.win = win;
					drawWindows.Append(dwt);*/
				}
				// 
				//  added new onEvent
				else if(tokenLower == "onnamedevent")
				{
					// read the event name
					if((token = parser.ReadToken()) == null)
					{
						parser.Error("Expected event name");
						return false;
					}

					idNamedEvent ev = new idNamedEvent(token.ToString());
					parser.SetMarker();

					if(ParseScript(parser, ev.Event) == false)
					{
						ret = false;
						break;
					}

					_namedEvents.Add(ev);
				}
				else if(tokenLower == "ontime")
				{
					idTimeLineEvent ev = new idTimeLineEvent();

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

					int tmp;
					int.TryParse(token.ToString(), out tmp);

					ev.Time = tmp;

					// reset the mark since we dont want it to include the time
					parser.SetMarker();

					if(ParseScript(parser, ev.Event) == false)
					{
						ret = false;
						break;
					}

					// this is a timeline event
					ev.Pending = true;
					_timeLineEvents.Add(ev);
				}
				else if(tokenLower == "definefloat")
				{
					token = parser.ReadToken();
					tokenLower = token.ToString().ToLower();

					idWinFloat var = new idWinFloat(tokenLower);

					_definedVariables.Add(var);

					// add the float to the editors wrapper dict
					// Set the marker after the float name
					parser.SetMarker();

					// Read in the float 
					_regList.AddRegister(tokenLower, RegisterType.Float, parser, this, var);
				}
				else if(tokenLower == "definevec4")
				{
					token = parser.ReadToken();
					tokenLower = token.ToString().ToLower();

					idWinVector4 var = new idWinVector4(tokenLower);

					// set the marker so we can determine what was parsed
					// set the marker after the vec4 name
					parser.SetMarker();

					// FIXME: how about we add the var to the desktop instead of this window so it won't get deleted
					//        when this window is destoyed which even happens during parsing with simple windows ?
					//definedVars.Append(var);
					_gui.Desktop._definedVariables.Add(var);
					_gui.Desktop._regList.AddRegister(tokenLower, RegisterType.Vector4, parser, _gui.Desktop, var);
				}
				else if(tokenLower == "float")
				{
					token = parser.ReadToken();
					tokenLower = token.ToString();

					idWinFloat var = new idWinFloat(tokenLower);
					_definedVariables.Add(var);

					// add the float to the editors wrapper dict
					// set the marker to after the float name
					parser.SetMarker();

					// Parse the float
					_regList.AddRegister(tokenLower, RegisterType.Float, parser, this, var);
				}
				else if(ParseScriptEntry(token, parser) == true)
				{

				}
				else if(ParseInternalVariable(token.ToString(), parser) == true)
				{

				}
				else
				{
					ParseRegisterEntry(token.ToString(), parser);
				}

				if((token = parser.ReadToken()) == null)
				{
					parser.Error("Unexpected end of file");
					ret = false;

					break;
				}
			}

			if(ret == true)
			{
				EvaluateRegisters(-1, true);
			}

			SetupFromState();
			PostParse();

			return ret;
		}
Example #6
0
		/// <summary>
		/// Inserts the given window as a child into the given location in the zorder.
		/// </summary>
		/// <param name="window"></param>
		/// <param name="before"></param>
		/// <returns></returns>
		public bool InsertChild(idWindow window, idWindow before)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			AddChild(window);

			window.Parent = this;

			DrawWindow drawWindow = new DrawWindow(window);

			// if not inserting before anything then just add it at the end
			if(before != null)
			{
				int index = GetChildIndex(before);

				if(index != -1)
				{
					_drawWindows.Insert(index, drawWindow);
					return true;
				}
			}

			_drawWindows.Add(drawWindow);

			return true;
		}
Example #7
0
		public virtual idWindowVariable GetVariableByName(string name, bool fixup, ref DrawWindow owner)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idWindowVariable ret = null;

			if(owner != null)
			{
				owner = null;
			}

			string nameLower = name.ToLower();

			if(nameLower == "notime")
			{
				ret = _noTime;
			}
			else if(nameLower == "background")
			{
				ret = _backgroundName;
			}
			else if(nameLower == "visible")
			{
				ret = _visible;
			}
			else if(nameLower == "rect")
			{
				ret = _rect;
			}
			else if(nameLower == "backcolor")
			{
				ret = _backColor;
			}
			else if(nameLower == "matcolor")
			{
				ret = _materialColor;
			}
			else if(nameLower == "forecolor")
			{
				ret = _foreColor;
			}
			else if(nameLower == "hovercolor")
			{
				ret = _hoverColor;
			}
			else if(nameLower == "bordercolor")
			{
				ret = _borderColor;
			}
			else if(nameLower == "textscale")
			{
				ret = _textScale;
			}
			else if(nameLower == "rotate")
			{
				ret = _rotate;
			}
			else if(nameLower == "noevents")
			{
				ret = _noEvents;
			}
			else if(nameLower == "text")
			{
				ret = _text;
			}
			else if(nameLower == "backgroundname")
			{
				ret = _backgroundName;
			}
			else if(nameLower == "hidecursor")
			{
				ret = _hideCursor;
			}

			string key = name;
			bool guiVar = key.StartsWith(idWindowVariable.Prefix);

			foreach(idWindowVariable var in _definedVariables)
			{
				if(nameLower.Equals(var.Name, StringComparison.OrdinalIgnoreCase) == true)
				{
					ret = var;
					break;
				}
			}

			if(ret != null)
			{
				if((fixup == true) && (name.StartsWith("$") == false))
				{
					DisableRegister(name);
				}

				if(_parent != null)
				{
					owner = _parent.FindChildByName(_name);
				}

				return ret;
			}

			int keyLength = key.Length;

			if((keyLength > 5) && (guiVar == true))
			{
				idWindowVariable var = new idWinString(name);
				var.Init(name, this);

				_definedVariables.Add(var);

				return var;
			}
			else if(fixup == true)
			{
				int n = key.IndexOf("::");

				if(n > 0)
				{
					string winName = key.Substring(0, n);
					string var = key.Substring(n + 2);

					DrawWindow win = this.UserInterface.Desktop.FindChildByName(winName);

					if(win != null)
					{
						if(win.Window != null)
						{
							return win.Window.GetVariableByName(var, false, ref owner);
						}
						else
						{
							owner = win;
						}

						return win.Simple.GetVariableByName(var);
					}
				}
			}

			return null;
		}
Example #8
0
		public idWindowVariable GetVariableByName(string name, bool fixup)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			DrawWindow owner = new DrawWindow();
			return GetVariableByName(name, fixup, ref owner);
		}