ContainsPoint() public method

public ContainsPoint ( Vector2 point ) : bool
point Vector2
return bool
コード例 #1
0
ファイル: UIElement.cs プロジェクト: egshels/Sources
        public UIElement GetElementAt(Vector2 point)
        {
            UIElement uIElement = null;

            for (int num = Elements.Count - 1; num >= 0; num--)
            {
                UIElement uIElement2 = Elements[num];
                if (!uIElement2.IgnoresMouseInteraction && uIElement2.ContainsPoint(point))
                {
                    uIElement = uIElement2;
                    break;
                }
            }
            if (uIElement != null)
            {
                return(uIElement.GetElementAt(point));
            }
            if (IgnoresMouseInteraction)
            {
                return(null);
            }
            if (ContainsPoint(point))
            {
                return(this);
            }
            return(null);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: UserInterface.cs プロジェクト: windlex/mylualib
 // 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);
         }
     }
 }
コード例 #4
0
ファイル: UserInterface.cs プロジェクト: egshels/Sources
        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);
            }
        }
コード例 #5
0
        public UIElement GetElementAt(Vector2 point)
        {
            UIElement uiElement = (UIElement)null;

            for (int index = this.Elements.Count - 1; index >= 0; --index)
            {
                UIElement element = this.Elements[index];
                if (!element.IgnoresMouseInteraction && element.ContainsPoint(point))
                {
                    uiElement = element;
                    break;
                }
            }
            if (uiElement != null)
            {
                return(uiElement.GetElementAt(point));
            }
            if (this.IgnoresMouseInteraction)
            {
                return((UIElement)null);
            }
            return(this.ContainsPoint(point) ? this : (UIElement)null);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }