Inheritance: IDisposable
Esempio n. 1
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;
		}
Esempio n. 2
0
		public override void HandleBuddyUpdate(idWindow buddy)
		{
			_top = (int) _scroller.Value;
		}
Esempio n. 3
0
		public override void Init(string name, idWindow win)
		{
			base.Init(name, win);

			if(_guiDict != null)
			{
				_data = _guiDict.GetString(this.Name);
			}
		}
Esempio n. 4
0
		public idSimpleWindow(idWindow win)
		{
			_gui = win.UserInterface;
			_context = win.DeviceContext;

			_drawRect = win.DrawRectangle;
			_clientRect = win.ClientRectangle;
			_textRect = win.TextRectangle;

			_origin = win.Origin;
			_fontFamily = win.FontFamily;
			_name = win.Name;

			_materialScaleX = win.MaterialScaleX;
			_materialScaleY = win.MaterialScaleY;

			_borderSize = win.BorderSize;
			_textAlign = win.TextAlign;
			_textAlignX = win.TextAlignX;
			_textAlignY = win.TextAlignY;
			_background = win.Background;
			_flags = win.Flags;
			_textShadow = win.TextShadow;

			_visible.Set(win.IsVisible);
			_text.Set(win.Text);
			_rect.Set(win.Rectangle);
			_backColor.Set(win.BackColor);
			_materialColor.Set(win.MaterialColor);
			_foreColor.Set(win.ForeColor);
			_borderColor.Set(win.BorderColor);
			_textScale.Set(win.TextScale);
			_rotate.Set(win.Rotate);
			_shear.Set(win.Shear);
			_backgroundName.Set(win.BackgroundName);

			if(_backgroundName != string.Empty)
			{
				_background = idE.DeclManager.FindMaterial(_backgroundName);
				_background.Sort = (float) MaterialSort.Gui; ;
				_background.ImageClassification = 1; // just for resource tracking
			}

			_backgroundName.Material = _background;

			_parent = win.Parent;
			_hideCursor.Set(win.HideCursor);

			if(_parent != null)
			{
				if(_text.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_text);
				}

				if(_visible.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_visible);
				}

				if(_rect.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_rect);
				}

				if(_backColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_backColor);
				}

				if(_materialColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_materialColor);
				}

				if(_foreColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_foreColor);
				}

				if(_borderColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_borderColor);
				}

				if(_textScale.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_textScale);
				}

				if(_rotate.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_rotate);
				}

				if(_shear.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_shear);
				}

				if(_backgroundName.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_backgroundName);
				}
			}
		}
Esempio n. 5
0
		public bool InitFromFile(string path, bool rebuild = true, bool cache = true)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(path == string.Empty)
			{
				return false;
			}

			_loading = true;
			
			if((rebuild == true) || (_desktop == null))
			{
				_desktop = new idWindow(this, idE.UIManager.Context);
			}

			_sourceFile = path;
			_state.Set("text", "Test Text!");

			// load the timestamp so reload guis will work correctly
			byte[] data = idE.FileSystem.ReadFile(path, out _timeStamp);
			string content = UTF8Encoding.UTF8.GetString(data);
			idScriptParser parser = null;

			if(content != null)
			{
				parser = new idScriptParser(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination);
				parser.LoadMemory(content, path);
			}

			if((parser != null) && (parser.IsLoaded == true))
			{
				idToken token;

				while((token = parser.ReadToken()) != null)
				{
					if(token.ToString().Equals("windowDef", StringComparison.OrdinalIgnoreCase) == true)
					{
						if(_desktop.Parse(parser, rebuild) == true)
						{
							_desktop.Flags = WindowFlags.Desktop;
							_desktop.FixupParameters();
						}
					}
				}

				_state.Set("name", path);
			}
			else
			{
				_desktop.Name = "Desktop";
				_desktop.Flags = WindowFlags.Desktop;
				_desktop.Text = string.Format("Invalid GUI: {0}", path);
				_desktop.Rectangle = new idRectangle(0, 0, 640, 480);
				_desktop.DrawRectangle = _desktop.Rectangle;
				_desktop.ForeColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
				_desktop.BackColor = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
				_desktop.SetupFromState();

				idConsole.Warning("Couldn't load gui: '{0}'", path);
			}

			_interactive = _desktop.IsInteractive;

			if(idE.UIManager.FindInternalInterface(this) == null)
			{
				idE.UIManager.AddInternalInterface(this);
			}

			_loading = false;

			return true;
		}
Esempio n. 6
0
		public void Execute(idWindow window)
		{
			foreach(idGuiScript script in _list)
			{
				if(script.ConditionRegister >= 0)
				{
					if(window.HasOperations == true)
					{
						float f = window.EvaluateRegisters(script.ConditionRegister);

						if(f > 0)
						{
							if(script.IfList != null)
							{
								window.RunScriptList(script.IfList);
							}
						}
						else if(script.ElseList != null)
						{
							window.RunScriptList(script.ElseList);
						}
					}
				}

				script.Execute(window);
			}
		}
Esempio n. 7
0
		public void AddRegister(string name, RegisterType type, idScriptParser parser, idWindow window, idWindowVariable var)
		{
			idRegister register = FindRegister(name);

			if(register == null)
			{
				int regCount = idRegister.RegisterTypeCount[(int) type];
				register = new idRegister(name, type, var);
				
				if(type == RegisterType.String)
				{
					idToken token;
					
					if((token = parser.ReadToken()) != null)
					{
						var.Init(idE.Language.Get(token.ToString()), window);
					}
				}
				else
				{
					for(int i = 0; i < regCount; i++)
					{
						register.Indexes[i] = window.ParseExpression(parser, null);

						if(i < (regCount - 1))
						{
							parser.ExpectTokenString(",");
						}
					}
				}

				_registers.Add(register);
				_registerDict.Add(name, register);
			}
			else
			{
				int regCount = idRegister.RegisterTypeCount[(int) type];

				register.Variable = var;

				if(type == RegisterType.String)
				{
					idToken token = parser.ReadToken();

					if(token != null)
					{
						var.Init(token.ToString(), window);
					}
				}
				else
				{
					for(int i = 0; i < regCount; i++)
					{
						register.Indexes[i] = window.ParseExpression(parser, null);

						if(i < (regCount - 1))
						{
							parser.ExpectTokenString(",");
						}
					}
				}
			}
		}
Esempio n. 8
0
		public void Execute(idWindow window)
		{
			if(_handler != null)
			{
				_handler(window, _parameters);
			}
		}
Esempio n. 9
0
		public void FixupParameters(idWindow window)
		{
			if(_handler == Script_Set)
			{
				bool precacheBackground = false;
				bool precacheSounds = false;

				idWinString str = (idWinString) _parameters[0].Variable;
				idWindowVariable dest = window.GetVariableByName(str.ToString(), true);

				if(dest != null)
				{
					_parameters[0].Variable = dest;
					_parameters[0].Owner = false;

					if(dest is idWinBackground)
					{
						precacheBackground = true;
					}
				}
				else if(str.ToString().ToLower() == "cmd")
				{
					precacheSounds = true;
				}

				int parameterCount = _parameters.Count;

				for(int i = 1; i < parameterCount; i++)
				{
					str = (idWinString) _parameters[i].Variable;
					string strValue = str.ToString();

					if(strValue.StartsWith("gui::", StringComparison.InvariantCultureIgnoreCase) == true)
					{
						//  always use a string here, no point using a float if it is one
						//  FIXME: This creates duplicate variables, while not technically a problem since they
						//  are all bound to the same guiDict, it does consume extra memory and is generally a bad thing
						idWinString defVar = new idWinString(null);
						defVar.Init(strValue, window);

						window.AddDefinedVariable(defVar);

						_parameters[i].Variable = defVar;
						_parameters[i].Owner = false;

						//dest = win->GetWinVarByName(*str, true);
						//if (dest) {
						//	delete parms[i].var;
						//	parms[i].var = dest;
						//	parms[i].own = false;
						//}
						// 
					}
					else if(strValue.StartsWith("$") == true)
					{
						// 
						//  dont include the $ when asking for variable
						dest = window.UserInterface.Desktop.GetVariableByName(strValue.Substring(1), true);
						// 					
						if(dest != null)
						{
							_parameters[i].Variable = dest;
							_parameters[i].Owner = false;
						}
					}
					else if(strValue.StartsWith("#str_") == true)
					{
						str.Set(idE.Language.Get(strValue));
					}
					else if(precacheBackground == true)
					{
						idE.DeclManager.FindMaterial(strValue).Sort = (float) MaterialSort.Gui;
					}
					else if(precacheSounds == true)
					{
						idConsole.Warning("TODO: PrecacheSounds");
						// Search for "play <...>"
						/*idToken token;
						idParser parser( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
						parser.LoadMemory(str->c_str(), str->Length(), "command");

						while ( parser.ReadToken(&token) ) {
							if ( token.Icmp("play") == 0 ) {
								if ( parser.ReadToken(&token) && ( token != "" ) ) {
									declManager->FindSound( token.c_str() );
								}
							}
						}*/
					}
				}
			}
			else if(_handler == Script_Transition)
			{
				if(_parameters.Count < 4)
				{
					idConsole.Warning("Window {0} in gui {1} has a bad transition definition", window.Name, window.UserInterface.SourceFile);
				}

				idWinString str = (idWinString) _parameters[0].Variable;

				// 
				DrawWindow destOwner = null;
				idWindowVariable dest = window.GetVariableByName(str.ToString(), true, ref destOwner);
				// 

				if(dest != null)
				{
					_parameters[0].Variable = dest;
					_parameters[0].Owner = false;
				}
				else
				{
					idConsole.Warning("Window {0} in gui {1}: a transition does not have a valid destination var {2}", window.Name, window.UserInterface.SourceFile, str);
				}

				// 
				//  support variables as parameters		
				for(int c = 1; c < 3; c++)
				{
					str = (idWinString) _parameters[c].Variable;
					idWinVector4 v4 = new idWinVector4(null);

					_parameters[c].Variable = v4;
					_parameters[c].Owner = true;

					DrawWindow owner = null;

					if(str.ToString().StartsWith("$") == true)
					{
						dest = window.GetVariableByName(str.ToString().Substring(1), true, ref owner);
					}
					else
					{
						dest = null;
					}

					if(dest != null)
					{
						idWindow ownerParent;
						idWindow destParent;

						if(owner != null)
						{
							ownerParent = (owner.Simple != null) ? owner.Simple.Parent : owner.Window.Parent;
							destParent = (destOwner.Simple != null) ? destOwner.Simple.Parent : destOwner.Window.Parent;

							// if its the rectangle they are referencing then adjust it 
							if((ownerParent != null) && (destParent != null) && (dest == ((owner.Simple != null) ? owner.Simple.GetVariableByName("rect") : owner.Window.GetVariableByName("rect"))))
							{
								idRectangle rect = ((idWinRectangle) dest).Data;
								ownerParent.ClientToScreen(ref rect);
								destParent.ScreenToClient(ref rect);

								v4.Set(dest.ToString());
							}
							else
							{
								v4.Set(dest.ToString());
							}
						}
						else
						{
							v4.Set(dest.ToString());
						}
					}
					else
					{
						v4.Set(str.ToString());
					}
				}
			}
			else
			{
				int c = _parameters.Count;

				for(int i = 0; i < c; i++)
				{
					_parameters[i].Variable.Init(_parameters[i].Variable.ToString(), window);
				}
			}
		}
Esempio n. 10
0
		private void Dispose(bool disposing)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(disposing == true)
			{
				CleanUp();

				_gui = null;
				_context = null;
				_parent = null;
				_background = null;
				_focusedChild = null;
				_captureChild = null;
				_overChild = null;				
				_children = null;
				_drawWindows = null;
				_definedVariables = null;
				_updateVariables = null;
				_scripts = null;
				_timeLineEvents = null;
				_transitions = null;
				_namedEvents = null;
				_expressionRegisters = null;
				_ops = null;
				_regList = null;
				_lastEval = null;
				_builtInVariables = null;
			}

			_disposed = true;
		}
Esempio n. 11
0
		public DrawWindow(idWindow window)
		{
			Window = window;
		}
Esempio n. 12
0
		private void Init()
		{
			_childID = 0;
			_flags = 0;
			_lastTimeRun = 0;

			_origin = Vector2.Zero;
						
			_fontFamily = null;
			_timeLine = -1;
			_offsetX = 0;
			_offsetY = 0;
			
			_cursor = Cursor.Arrow;
			_forceAspectWidth = 640;
			_forceAspectHeight = 480;
			_materialScaleX = 1;
			_materialScaleY = 1;
			_borderSize = 0;

			_textAlign = TextAlign.Left;
			_textAlignX = 0;
			_textAlignY = 0;
			
			_noEvents.Set(false);
			_noTime.Set(false);
			_visible.Set(true);
			_hideCursor.Set(false);

			_shear = Vector2.Zero;
			_rotate.Set(0);
			_textScale.Set(0.35f);

			_backColor.Set(Vector4.Zero);
			_foreColor.Set(new Vector4(1, 1, 1, 1));
			_hoverColor.Set(new Vector4(1, 1, 1, 1));
			_materialColor.Set(new Vector4(1, 1, 1, 1));
			_borderColor.Set(Vector4.Zero);

			_background = null;
			_backgroundName.Set(string.Empty);

			_focusedChild = null;
			_captureChild = null;
			_overChild = null;

			// TODO
			/*
			*/
			_parent = null;
			/*saveOps = NULL;
			saveRegs = NULL;*/
			_timeLine = -1;
			_textShadow = 0;
			_hover = false;

			int count = _scripts.Length;
			
			for(int i = 0; i < count; i++)
			{
				_scripts[i] = null;
			}
		}
Esempio n. 13
0
		protected virtual string RouteMouseCoordinates(float x, float y)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(this.CaptureChild != null)
			{
				//FIXME: unkludge this whole mechanism
				return this.CaptureChild.RouteMouseCoordinates(x, y);
			}

			if((x == -2000) || (y == -2000))
			{
				return string.Empty;
			}
	
			int c = _children.Count;
			string str = string.Empty;

			while(c > 0)
			{
				idWindow child = _children[--c];

				if((child.IsVisible == true)
					&& (child.NoEvents == false)
					&& (child.Contains(child.DrawRectangle, this.UserInterface.CursorX, this.UserInterface.CursorY) == true))
				{
					this.DeviceContext.Cursor = child.Cursor;

					if(_overChild != child)
					{
						if(_overChild != null)
						{
							_overChild.HandleMouseExit();

							str = _overChild.Command;

							if(str != string.Empty)
							{
								this.UserInterface.Desktop.AddCommand(str);
								_overChild.Command = string.Empty;
							}
						}

						_overChild = child;
						_overChild.HandleMouseEnter();

						str = _overChild.Command;

						if(str != string.Empty)
						{
							this.UserInterface.Desktop.AddCommand(str);
							_overChild.Command = string.Empty;
						}
					} 
					else 
					{
						if((child.Flags & WindowFlags.HoldCapture) == 0)
						{
							child.RouteMouseCoordinates(x, y);
						}
					}

					return string.Empty;
				}
			}

			if(_overChild != null)
			{
				_overChild.HandleMouseExit();

				str = _overChild.Command;

				if(str != string.Empty)
				{
					this.UserInterface.Desktop.AddCommand(str);
					_overChild.Command = string.Empty;
				}

				_overChild = null;
			}

			return string.Empty;
		}
Esempio n. 14
0
		public idWindow SetFocus(idWindow window, bool scripts = true)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			// only one child can have the focus
			idWindow lastFocus = null;

			if((window.Flags & WindowFlags.CanFocus) == WindowFlags.CanFocus)
			{
				lastFocus = this.UserInterface.Desktop.FocusedChild;

				if(lastFocus != null)
				{
					lastFocus.HandleFocusLost();
				}

				//  call on lose focus
				if((scripts == true) && (lastFocus != null))
				{
					// calling this broke all sorts of guis
					// lastFocus->RunScript(ON_MOUSEEXIT);
				}


				//  call on gain focus
				if((scripts == true) && (window != null))
				{
					// calling this broke all sorts of guis
					// w->RunScript(ON_MOUSEENTER);
				}

				window.HandleFocusGained();

				this.UserInterface.Desktop.FocusedChild = window;
			}

			return lastFocus;
		}
Esempio n. 15
0
		private static void Script_ShowCursor(idWindow window, List<idWinGuiScript> source)
		{
			idConsole.Warning("TODO: Script_ShowCursor");
		}
Esempio n. 16
0
		private static void Script_EvaluateRegisters(idWindow window, List<idWinGuiScript> source)
		{
			idConsole.Warning("TODO: Script_EvaluateRegisters");
		}
Esempio n. 17
0
		private static void Script_Transition(idWindow window, List<idWinGuiScript> source)
		{
			// transitions always affect rect or vec4 vars
			if(source.Count >= 4)
			{
				idWinRectangle rect = null;
				idWinVector4 vec4 = source[0].Variable as idWinVector4;

				// 
				//  added float variable
				idWinFloat val = null;
				// 
				if(vec4 == null)
				{
					rect = source[0].Variable as idWinRectangle;
					// 
					//  added float variable					
					if(rect == null)
					{
						val = source[0].Variable as idWinFloat;
					}
					// 
				}

				idWinVector4 from = source[1].Variable as idWinVector4;
				idWinVector4 to = source[2].Variable as idWinVector4;
				idWinString timeStr = source[3].Variable as idWinString;
				// 
				//  added float variable			
				if(((vec4 == null) && (rect == null) && (val == null)) && (from != null) && (to != null) && (timeStr != null))
				{
					idConsole.Warning("Bad transition in gui {0} in window {1}", window.UserInterface.SourceFile, window.Name);
				}
				else
				{
					int time;
					int.TryParse(timeStr.ToString(), out time);

					float accel = 0.0f;
					float decel = 0.0f;

					if(source.Count > 4)
					{
						idWinString accelStr = source[4].Variable as idWinString;
						idWinString decelStr = source[5].Variable as idWinString;

						float.TryParse(accelStr.ToString(), out accel);
						float.TryParse(decelStr.ToString(), out decel);
					}

					if(vec4 != null)
					{
						vec4.Evaluate = false;
						window.AddTransition(vec4, from, to, time, accel, decel);
					}
					else if(val != null)
					{
						val.Evaluate = false;
						window.AddTransition(val, from, to, time, accel, decel);
					}
					else
					{
						rect.Evaluate = false;
						window.AddTransition(rect, from, to, time, accel, decel);
					}

					window.StartTransition();
				}
			}
		}
Esempio n. 18
0
		private static void Script_LocalSound(idWindow window, List<idWinGuiScript> source)
		{
			idConsole.Warning("TODO: Script_LocalSound");
		}
Esempio n. 19
0
		public void FixupParameters(idWindow window)
		{
			int c = _list.Count;

			for(int i = 0; i < c; i++)
			{
				idGuiScript script = _list[i];
				script.FixupParameters(window);

				if(script.IfList != null)
				{
					script.IfList.FixupParameters(window);
				}

				if(script.ElseList != null)
				{
					script.ElseList.FixupParameters(window);
				}
			}
		}
Esempio n. 20
0
		private static void Script_ResetCinematics(idWindow window, List<idWinGuiScript> source)
		{
			idConsole.Warning("TODO: Script_ResetCinematics");
		}
Esempio n. 21
0
		private void Init()
		{
			_value.Set(0.0f);
			_low = 0.0f;
			_high = 100.0f;
			_stepSize = 1.0f;
			_thumbMaterial = idE.DeclManager.FindMaterial("_default");
			_buddyWindow = null;

			_cvar = null;
			_cvarInit = false;
			_vertical = false;
			_scrollBar = false;
			_verticalFlip = false;

			_liveUpdate.Set(true);
		}
Esempio n. 22
0
		private static void Script_ResetTime(idWindow window, List<idWinGuiScript> source)
		{
			idWinString parameter = (source.Count > 0) ? source[0].Variable as idWinString : null;
			DrawWindow drawWindow = null;

			if((parameter != null) && (source.Count > 1))
			{
				drawWindow = window.UserInterface.Desktop.FindChildByName(parameter);
				parameter = source[1].Variable as idWinString;
			}

			int tmp;
			int.TryParse(parameter, out tmp);

			if((drawWindow != null) && (drawWindow.Window != null))
			{
				drawWindow.Window.ResetTime(tmp);
				drawWindow.Window.EvaluateRegisters(-1, true);
			}
			else
			{
				window.ResetTime(tmp);
				window.EvaluateRegisters(-1, true);
			}
		}
Esempio n. 23
0
		public string HandleEvent(SystemEvent e, int time, ref bool updateVisuals)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			_time = time;

			if((_bindHandler != null) && (e.Type == SystemEventType.Key) && (e.Value2 == 1))
			{
				string ret = _bindHandler.HandleEvent(e, ref updateVisuals);
				_bindHandler = null;
				
				return ret;
			}

			if(e.Type == SystemEventType.Mouse)
			{
				_cursorX += e.Value;
				_cursorY += e.Value2;

				if(_cursorX < 0)
				{
					_cursorX = 0;
				}

				if(_cursorY < 0)
				{
					_cursorY = 0;
				}
			}

			if(this.Desktop != null)
			{
				this.Desktop.HandleEvent(e, ref updateVisuals);
			}

			return string.Empty;
		}
Esempio n. 24
0
		private static void Script_RunScript(idWindow window, List<idWinGuiScript> source)
		{
			idConsole.Warning("TODO: Script_RunScript");
		}
Esempio n. 25
0
		private void Dispose(bool disposing)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(disposing == true)
			{
				_state = null;
				_desktop = null;
				_bindHandler = null;
			}

			_disposed = true;
		}
Esempio n. 26
0
		private static void Script_Set(idWindow window, List<idWinGuiScript> source)
		{
			string dest = (source.Count > 0) ? source[0].Variable.ToString() : null;

			if(dest != null)
			{
				if(dest.Equals("cmd", StringComparison.OrdinalIgnoreCase) == true)
				{
					dest = (source.Count > 1) ? source[1].Variable as idWinString : null;
					
					int parameterCount = source.Count;

					if(parameterCount > 2)
					{
						StringBuilder value = new StringBuilder(dest);
						int i = 2;

						while(i < parameterCount)
						{
							value.AppendFormat(" \"{0}\"", source[i].Variable);
							i++;
						}

						window.AddCommand(value.ToString());
					}
					else
					{
						window.AddCommand(dest);
					}

					return;
				}
			}

			source[0].Variable.Set(source[1].Variable.ToString());
			source[0].Variable.Evaluate = false;
		}
Esempio n. 27
0
		public virtual void Init(string name, idWindow win)
		{
			string key = name;
			int length = key.Length;
		
			_guiDict = null;

			if((length > Prefix.Length) && (key.StartsWith(Prefix) == true))
			{
				key = key.Substring(length - Prefix.Length - 1);

				SetGuiInfo(win.UserInterface.State, key);
				win.AddUpdateVariable(this);
			}
			else
			{
				Set(name);
			}
		}
Esempio n. 28
0
		private static void Script_SetFocus(idWindow window, List<idWinGuiScript> source)
		{
			idWinString parameter = source[0].Variable as idWinString;

			if(parameter != null)
			{
				DrawWindow drawWindow = window.UserInterface.Desktop.FindChildByName(parameter.ToString());

				if((drawWindow != null) && (drawWindow.Window != null))
				{
					window.SetFocus(drawWindow.Window);
				}
			}
		}
Esempio n. 29
0
		public override void Init(string name, idWindow win)
		{
			base.Init(name, win);

			Update();
		}
Esempio n. 30
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;
		}