public virtual bool MouseIsCurrentlyOverButtonArea(ButtonArea buttonArea, Vector2 offset, IResolution resolution)
        {
            Point   mouseScreenPosition = _currentMousePosition;
            Vector2 mousePosition       = resolution.ScreenToGameCoord(new Vector2(mouseScreenPosition.X, mouseScreenPosition.Y));
            Vector2 buttonAreaSize      = buttonArea.GetSize();

            return(mousePosition.X >= buttonArea.Position.X + offset.X && mousePosition.X <= buttonArea.Position.X + offset.X + buttonAreaSize.X && mousePosition.Y >= buttonArea.Position.Y + offset.Y && mousePosition.Y <= buttonArea.Position.Y + offset.Y + buttonAreaSize.Y);
        }
Esempio n. 2
0
        protected virtual void CheckIfScrollUpOrDown(int focusedIndex)
        {
            if (focusedIndex >= 0)
            {
                ButtonArea focusedButton = _buttonAreaList[focusedIndex];
                if (focusedButton != null)
                {
                    if (focusedButton.Position.Y + focusedButton.GetSize().Y + ScrollCurrentOffset.Y >= _scrollDownButtonArea.Position.Y)
                    {
                        ButtonArea aboveFocusedButton = _buttonAreaList[focusedIndex - 1];
                        //Scroll down
                        ScrollCurrentOffset.Y -= focusedButton.Position.Y + focusedButton.GetSize().Y - (aboveFocusedButton.Position.Y + aboveFocusedButton.GetSize().Y);
                    }
                    else if (focusedButton.Position.Y + ScrollCurrentOffset.Y < _scrollUpButtonArea.Position.Y + _scrollUpButtonArea.GetSize().Y)
                    {
                        ButtonArea belowFocusedButton = _buttonAreaList[focusedIndex + 1];
                        //Scroll up
                        ScrollCurrentOffset.Y += belowFocusedButton.Position.Y + belowFocusedButton.GetSize().Y - (focusedButton.Position.Y + focusedButton.GetSize().Y);
                    }
                }
            }
            if (_buttonAreaList[_buttonAreaList.Count - 1].Position.Y + _buttonAreaList[_buttonAreaList.Count - 1].GetSize().Y + ScrollCurrentOffset.Y >= _scrollDownButtonArea.Position.Y)
            {
                _scrollDownButtonArea.Visible = true;
            }
            else
            {
                _scrollDownButtonArea.Visible = false;
            }

            if (_buttonAreaList[0].Position.Y + ScrollCurrentOffset.Y <= _scrollUpButtonArea.Position.Y + _scrollUpButtonArea.GetSize().Y)
            {
                _scrollUpButtonArea.Visible = true;
            }
            else
            {
                _scrollUpButtonArea.Visible = false;
            }
        }
Esempio n. 3
0
 public virtual ButtonArea GetMouseOverButtonArea(GameTime gameTime, GameSettings gameSettings, IResolution resolution)
 {
     foreach (ButtonArea button in _buttonAreaList)
     {
         if (button.Visible && !button.Disabled)
         {
             if (!Scrollable || button.Position.Y + button.GetSize().Y + ScrollCurrentOffset.Y < _scrollDownButtonArea.Position.Y && button.Position.Y + ScrollCurrentOffset.Y > _scrollUpButtonArea.Position.Y + _scrollUpButtonArea.GetSize().Y)
             {
                 if (_inputChecker.MouseIsCurrentlyOverButtonArea(button, ScrollCurrentOffset, resolution))
                 {
                     return(button);
                 }
             }
         }
     }
     if (Scrollable)
     {
         if (_scrollUpButtonArea.Visible && !_scrollUpButtonArea.Disabled)
         {
             if (_inputChecker.MouseIsCurrentlyOverButtonArea(_scrollUpButtonArea, new Vector2(0, 0), resolution))
             {
                 return(_scrollUpButtonArea);
             }
         }
         if (_scrollDownButtonArea.Visible && !_scrollDownButtonArea.Disabled)
         {
             if (_inputChecker.MouseIsCurrentlyOverButtonArea(_scrollDownButtonArea, new Vector2(0, 0), resolution))
             {
                 return(_scrollDownButtonArea);
             }
         }
     }
     return(null);
 }