//The game states have to feed the UI Input!!! This is to allow more flexibility. //Maybe this should be handled in the main methods for input. But then the state wouldnt have power over //this and things like the chat might get difficult. //Other Notes: When a component returns true to an input event the loop stops and so only that control recieves the input. // That way we don't have all components reacting to one event. /// <summary> /// Handles MouseDown event. Returns true if a component accepted and handled the event. /// </summary> public virtual bool MouseDown(MouseButtonEventArgs e) { if (_console.IsVisible()) { if (_console.MouseDown(e)) { return(true); } } if (moveMode) { foreach (IGuiComponent comp in _components) { if (comp.ClientArea.Contains(e.X, e.Y)) { movingComp = comp; dragOffset = (new Vector2i(e.X, e.Y)) - new Vector2i(comp.ClientArea.Left, comp.ClientArea.Top); break; } } return(true); } else { IOrderedEnumerable <IGuiComponent> inputList = from IGuiComponent comp in _components where comp.RecieveInput orderby comp.ZDepth ascending orderby comp.IsVisible() descending //Invisible controls still recieve input but after everyone else. This is mostly for the inventory and other toggleable components. orderby comp.Focus descending select comp; foreach (IGuiComponent current in inputList) { if (current.MouseDown(e)) { SetFocus(current); return(true); } } return(false); } }