public void Clear() { Gumps.ForEach(s => { s.Dispose(); }); }
public UIManager() { AnchorManager = new AnchorManager(); Engine.Input.MouseDragging += (sender, e) => { HandleMouseInput(); //if (_mouseDownControls[0] == MouseOverControl) // AttemptDragControl(MouseOverControl, Mouse.Position); if (_isDraggingControl) { DoDragControl(Mouse.Position); } }; Engine.Input.LeftMouseButtonDown += (sender, e) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // return; if (MouseOverControl != null) { MakeTopMostGump(MouseOverControl); MouseOverControl.InvokeMouseDown(Mouse.Position, MouseButton.Left); if (MouseOverControl.AcceptKeyboardInput) { _keyboardFocusControl = MouseOverControl; } _mouseDownControls[(int)MouseButton.Left] = MouseOverControl; } else { if (IsModalControlOpen) { Gumps.ForEach(s => { if (s.ControlInfo.IsModal && s.ControlInfo.ModalClickOutsideAreaClosesThisControl) { s.Dispose(); } }); } } }; Control lastLeftUp = null, lastRightUp = null; Engine.Input.LeftMouseButtonUp += (sender, e) => { //if (!IsModalControlOpen && ObjectsBlockingInputExists) // return; //if (MouseOverControl == null) // return; const int btn = (int)MouseButton.Left; EndDragControl(Mouse.Position); if (MouseOverControl != null) { if (_mouseDownControls[btn] != null && MouseOverControl == _mouseDownControls[btn]) { MouseOverControl.InvokeMouseClick(Mouse.Position, MouseButton.Left); } MouseOverControl.InvokeMouseUp(Mouse.Position, MouseButton.Left); if (_mouseDownControls[btn] != null && MouseOverControl != _mouseDownControls[btn]) { _mouseDownControls[btn].InvokeMouseUp(Mouse.Position, MouseButton.Left); } lastLeftUp = MouseOverControl; } else { _mouseDownControls[btn]?.InvokeMouseUp(Mouse.Position, MouseButton.Left); } CloseIfClickOutGumps(); _mouseDownControls[btn] = null; }; Engine.Input.LeftMouseDoubleClick += (sender, e) => { if (MouseOverControl != null && IsMouseOverAControl && MouseOverControl == lastLeftUp) { e.Result = MouseOverControl.InvokeMouseDoubleClick(Mouse.Position, MouseButton.Left); } }; Engine.Input.RightMouseButtonDown += (sender, e) => { //if (!IsModalControlOpen && ObjectsBlockingInputExists) // return; if (MouseOverControl != null) { MakeTopMostGump(MouseOverControl); MouseOverControl.InvokeMouseDown(Mouse.Position, MouseButton.Right); if (MouseOverControl.AcceptKeyboardInput) { _keyboardFocusControl = MouseOverControl; } _mouseDownControls[(int)MouseButton.Right] = MouseOverControl; } else { if (IsModalControlOpen) { Gumps.ForEach(s => { if (s.ControlInfo.IsModal && s.ControlInfo.ModalClickOutsideAreaClosesThisControl) { s.Dispose(); } }); } } CloseIfClickOutGumps(); }; Engine.Input.RightMouseButtonUp += (sender, e) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // return; //if (MouseOverControl == null) // return; const int btn = (int)MouseButton.Right; EndDragControl(Mouse.Position); if (MouseOverControl != null) { if (_mouseDownControls[btn] != null && MouseOverControl == _mouseDownControls[btn]) { MouseOverControl.InvokeMouseClick(Mouse.Position, MouseButton.Right); MouseOverControl.InvokeMouseCloseGumpWithRClick(); } MouseOverControl.InvokeMouseUp(Mouse.Position, MouseButton.Right); if (_mouseDownControls[btn] != null && MouseOverControl != _mouseDownControls[btn]) { _mouseDownControls[btn].InvokeMouseUp(Mouse.Position, MouseButton.Right); _mouseDownControls[btn].InvokeMouseCloseGumpWithRClick(); } lastRightUp = MouseOverControl; } else if (_mouseDownControls[btn] != null) { _mouseDownControls[btn].InvokeMouseUp(Mouse.Position, MouseButton.Right); _mouseDownControls[btn].InvokeMouseCloseGumpWithRClick(); } CloseIfClickOutGumps(); _mouseDownControls[btn] = null; }; Engine.Input.RightMouseDoubleClick += (sender, e) => { if (MouseOverControl != null && IsMouseOverAControl && MouseOverControl == lastRightUp) { e.Result = MouseOverControl.InvokeMouseDoubleClick(Mouse.Position, MouseButton.Right); } }; Engine.Input.MouseWheel += (sender, isup) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // return; if (MouseOverControl != null && MouseOverControl.AcceptMouseInput) { MouseOverControl.InvokeMouseWheel(isup ? MouseEvent.WheelScrollUp : MouseEvent.WheelScrollDown); } }; Engine.Input.KeyDown += (sender, e) => { _keyboardFocusControl?.InvokeKeyDown(e.keysym.sym, e.keysym.mod); }; Engine.Input.KeyUp += (sender, e) => { _keyboardFocusControl?.InvokeKeyUp(e.keysym.sym, e.keysym.mod); }; Engine.Input.TextInput += (sender, e) => { _keyboardFocusControl?.InvokeTextInput(e); }; }