public void Draw(SpriteBatch spriteBatch, GameTime time) { Use(); if (_currentState == null) { return; } MouseState state = Mouse.GetState(); MousePosition = new Vector2(state.X, state.Y); bool flag = state.LeftButton == ButtonState.Pressed && Main.hasFocus; UIElement uIElement = Main.hasFocus ? _currentState.GetElementAt(MousePosition) : null; _clickDisabledTimeRemaining = Math.Max(0.0, _clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds); bool flag2 = _clickDisabledTimeRemaining > 0.0; if (uIElement != _lastElementHover) { if (_lastElementHover != null) { _lastElementHover.MouseOut(new UIMouseEvent(_lastElementHover, MousePosition)); } uIElement?.MouseOver(new UIMouseEvent(uIElement, MousePosition)); _lastElementHover = uIElement; } if (flag && !_wasMouseDown && uIElement != null && !flag2) { _lastElementDown = uIElement; uIElement.MouseDown(new UIMouseEvent(uIElement, MousePosition)); if (_lastElementClicked == uIElement && time.TotalGameTime.TotalMilliseconds - _lastMouseDownTime < 500.0) { uIElement.DoubleClick(new UIMouseEvent(uIElement, MousePosition)); _lastElementClicked = null; } _lastMouseDownTime = time.TotalGameTime.TotalMilliseconds; } else if (!flag && _wasMouseDown && _lastElementDown != null && !flag2) { UIElement lastElementDown = _lastElementDown; if (lastElementDown.ContainsPoint(MousePosition)) { lastElementDown.Click(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementClicked = _lastElementDown; } lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementDown = null; } if (state.ScrollWheelValue != _scrollWheelState) { uIElement?.ScrollWheel(new UIScrollWheelEvent(uIElement, MousePosition, state.ScrollWheelValue - _scrollWheelState)); _scrollWheelState = state.ScrollWheelValue; } _wasMouseDown = flag; if (_currentState != null) { _currentState.Draw(spriteBatch); } }
// Token: 0x06000C47 RID: 3143 RVA: 0x003D8BF8 File Offset: 0x003D6DF8 public void Update(GameTime time) { if (this._currentState != null) { this.MousePosition = new Vector2((float)Main.mouseX, (float)Main.mouseY); bool flag = Main.mouseLeft && Main.hasFocus; UIElement uIElement = Main.hasFocus ? this._currentState.GetElementAt(this.MousePosition) : null; this._clickDisabledTimeRemaining = Math.Max(0.0, this._clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds); bool flag2 = this._clickDisabledTimeRemaining > 0.0; if (uIElement != this._lastElementHover) { if (this._lastElementHover != null) { this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition)); } if (uIElement != null) { uIElement.MouseOver(new UIMouseEvent(uIElement, this.MousePosition)); } this._lastElementHover = uIElement; } if (flag && !this._wasMouseDown && uIElement != null && !flag2) { this._lastElementDown = uIElement; uIElement.MouseDown(new UIMouseEvent(uIElement, this.MousePosition)); if (this._lastElementClicked == uIElement && time.TotalGameTime.TotalMilliseconds - this._lastMouseDownTime < 500.0) { uIElement.DoubleClick(new UIMouseEvent(uIElement, this.MousePosition)); this._lastElementClicked = null; } this._lastMouseDownTime = time.TotalGameTime.TotalMilliseconds; } else if (!flag && this._wasMouseDown && this._lastElementDown != null && !flag2) { UIElement lastElementDown = this._lastElementDown; if (lastElementDown.ContainsPoint(this.MousePosition)) { lastElementDown.Click(new UIMouseEvent(lastElementDown, this.MousePosition)); this._lastElementClicked = this._lastElementDown; } lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, this.MousePosition)); this._lastElementDown = null; } if (PlayerInput.ScrollWheelDeltaForUI != 0) { if (uIElement != null) { uIElement.ScrollWheel(new UIScrollWheelEvent(uIElement, this.MousePosition, PlayerInput.ScrollWheelDeltaForUI)); } PlayerInput.ScrollWheelDeltaForUI = 0; } this._wasMouseDown = flag; if (this._currentState != null) { this._currentState.Update(time); } } }
public void Update(GameTime time) { if (_currentState == null) { return; } GetMousePosition(); bool flag = Main.mouseLeft && Main.hasFocus; UIElement uIElement = Main.hasFocus ? _currentState.GetElementAt(MousePosition) : null; _clickDisabledTimeRemaining = Math.Max(0.0, _clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds); bool flag2 = _clickDisabledTimeRemaining > 0.0; if (uIElement != _lastElementHover) { if (_lastElementHover != null) { _lastElementHover.MouseOut(new UIMouseEvent(_lastElementHover, MousePosition)); } uIElement?.MouseOver(new UIMouseEvent(uIElement, MousePosition)); _lastElementHover = uIElement; } if (flag && !_wasMouseDown && uIElement != null && !flag2) { _lastElementDown = uIElement; uIElement.MouseDown(new UIMouseEvent(uIElement, MousePosition)); if (_lastElementClicked == uIElement && time.TotalGameTime.TotalMilliseconds - _lastMouseDownTime < 500.0) { uIElement.DoubleClick(new UIMouseEvent(uIElement, MousePosition)); _lastElementClicked = null; } _lastMouseDownTime = time.TotalGameTime.TotalMilliseconds; } else if (!flag && _wasMouseDown && _lastElementDown != null && !flag2) { UIElement lastElementDown = _lastElementDown; if (lastElementDown.ContainsPoint(MousePosition)) { lastElementDown.Click(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementClicked = _lastElementDown; } lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementDown = null; } if (PlayerInput.ScrollWheelDeltaForUI != 0) { uIElement?.ScrollWheel(new UIScrollWheelEvent(uIElement, MousePosition, PlayerInput.ScrollWheelDeltaForUI)); PlayerInput.ScrollWheelDeltaForUI = 0; } _wasMouseDown = flag; if (_currentState != null) { _currentState.Update(time); } }
public virtual void DoubleClick(UIMouseEvent evt) { if (this.OnDoubleClick != null) { this.OnDoubleClick(evt, this); } if (Parent != null) { Parent.DoubleClick(evt); } }
public void Update(GameTime time) { if (this._currentState == null) { return; } this.GetMousePosition(); bool flag1 = Main.mouseLeft && Main.hasFocus; UIElement target = Main.hasFocus ? this._currentState.GetElementAt(this.MousePosition) : (UIElement)null; double disabledTimeRemaining = this._clickDisabledTimeRemaining; TimeSpan timeSpan = time.ElapsedGameTime; double totalMilliseconds = timeSpan.TotalMilliseconds; this._clickDisabledTimeRemaining = Math.Max(0.0, disabledTimeRemaining - totalMilliseconds); bool flag2 = this._clickDisabledTimeRemaining > 0.0; if (target != this._lastElementHover) { if (this._lastElementHover != null) { this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition)); } target?.MouseOver(new UIMouseEvent(target, this.MousePosition)); this._lastElementHover = target; } if (flag1 && !this._wasMouseDown && (target != null && !flag2)) { this._lastElementDown = target; target.MouseDown(new UIMouseEvent(target, this.MousePosition)); if (this._lastElementClicked == target) { timeSpan = time.TotalGameTime; if (timeSpan.TotalMilliseconds - this._lastMouseDownTime < 500.0) { target.DoubleClick(new UIMouseEvent(target, this.MousePosition)); this._lastElementClicked = (UIElement)null; } } timeSpan = time.TotalGameTime; this._lastMouseDownTime = timeSpan.TotalMilliseconds; } else if (!flag1 && this._wasMouseDown && (this._lastElementDown != null && !flag2)) { UIElement lastElementDown = this._lastElementDown; if (lastElementDown.ContainsPoint(this.MousePosition)) { lastElementDown.Click(new UIMouseEvent(lastElementDown, this.MousePosition)); this._lastElementClicked = this._lastElementDown; } lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, this.MousePosition)); this._lastElementDown = (UIElement)null; } if (PlayerInput.ScrollWheelDeltaForUI != 0) { target?.ScrollWheel(new UIScrollWheelEvent(target, this.MousePosition, PlayerInput.ScrollWheelDeltaForUI)); PlayerInput.ScrollWheelDeltaForUI = 0; } this._wasMouseDown = flag1; if (this._currentState == null) { return; } this._currentState.Update(time); }
public void Draw(SpriteBatch spriteBatch, GameTime time) { this.Use(); if (this._currentState == null) { return; } MouseState state = Mouse.GetState(); this.MousePosition = new Vector2((float)state.X, (float)state.Y); bool flag1 = state.LeftButton == ButtonState.Pressed && Main.hasFocus; UIElement target1 = Main.hasFocus ? this._currentState.GetElementAt(this.MousePosition) : (UIElement)null; this._clickDisabledTimeRemaining = Math.Max(0.0, this._clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds); bool flag2 = this._clickDisabledTimeRemaining > 0.0; if (target1 != this._lastElementHover) { if (this._lastElementHover != null) { this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition)); } if (target1 != null) { target1.MouseOver(new UIMouseEvent(target1, this.MousePosition)); } this._lastElementHover = target1; } if (flag1 && !this._wasMouseDown && (target1 != null && !flag2)) { this._lastElementDown = target1; target1.MouseDown(new UIMouseEvent(target1, this.MousePosition)); if (this._lastElementClicked == target1 && time.TotalGameTime.TotalMilliseconds - this._lastMouseDownTime < 500.0) { target1.DoubleClick(new UIMouseEvent(target1, this.MousePosition)); this._lastElementClicked = (UIElement)null; } this._lastMouseDownTime = time.TotalGameTime.TotalMilliseconds; } else if (!flag1 && this._wasMouseDown && (this._lastElementDown != null && !flag2)) { UIElement target2 = this._lastElementDown; if (target2.ContainsPoint(this.MousePosition)) { target2.Click(new UIMouseEvent(target2, this.MousePosition)); this._lastElementClicked = this._lastElementDown; } target2.MouseUp(new UIMouseEvent(target2, this.MousePosition)); this._lastElementDown = (UIElement)null; } if (state.ScrollWheelValue != this._scrollWheelState) { if (target1 != null) { target1.ScrollWheel(new UIScrollWheelEvent(target1, this.MousePosition, state.ScrollWheelValue - this._scrollWheelState)); } this._scrollWheelState = state.ScrollWheelValue; } this._wasMouseDown = flag1; if (this._currentState == null) { return; } this._currentState.Draw(spriteBatch); }