Example #1
0
        /*//  Doesn't work - this is a bug within the game, not my code. Pressing the 'B' button on my Xbox One controller is sending Keys.E to receiveKeyPress.
         * public override void receiveKeyPress(Keys key)
         * {
         *  if (Game1.options.gamepadControls || (key.ToSButton().TryGetController(out Buttons b) && GamepadControls.IsMatch(b, GamepadControls.CloseBag)))
         *      return; // Let this button press be handled by our custom OnGamepadButtonsPressed logic
         *  else
         *      base.receiveKeyPress(key);
         * }*/

        #region Input Handling

        #region Mouse Handling
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            if (IsShowingModalMenu && CustomizeIconMenu != null)
            {
                CustomizeIconMenu.OnMouseMoved(e);
            }
            else
            {
                if (InventoryMenu.Bounds.Contains(e.OldPosition.LegacyScreenPixels().AsPoint()) || InventoryMenu.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
                {
                    InventoryMenu.OnMouseMoved(e);
                }

                if (Content.Bounds.Contains(e.OldPosition.LegacyScreenPixels().AsPoint()) || Content.Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
                {
                    Content.OnMouseMoved(e);
                }

                if (IsLeftSidebarVisible || IsRightSidebarVisible)
                {
                    Point OldPos = e.OldPosition.LegacyScreenPixels().AsPoint();
                    Point NewPos = e.NewPosition.LegacyScreenPixels().AsPoint();

                    if (LeftSidebarButtonBounds.Any(x => x.Contains(OldPos) || x.Contains(NewPos)) ||
                        RightSidebarButtonBounds.Any(x => x.Contains(OldPos) || x.Contains(NewPos)))
                    {
                        if (IsLeftSidebarVisible && DepositAllBounds.Contains(NewPos))
                        {
                            this.HoveredButton = SidebarButton.DepositAll;
                        }
                        else if (IsLeftSidebarVisible && WithdrawAllBounds.Contains(NewPos))
                        {
                            this.HoveredButton = SidebarButton.WithdrawAll;
                        }
                        else if (IsLeftSidebarVisible && AutolootBounds.Contains(NewPos))
                        {
                            this.HoveredButton = SidebarButton.Autoloot;
                        }
                        else if (IsRightSidebarVisible && HelpInfoBounds.Contains(NewPos))
                        {
                            this.HoveredButton = SidebarButton.HelpInfo;
                        }
                        else if (IsRightSidebarVisible && !(Bag is BundleBag) && CustomizeIconBounds.Contains(NewPos))
                        {
                            this.HoveredButton = SidebarButton.CustomizeIcon;
                        }
                        else
                        {
                            this.HoveredButton = null;
                        }

                        if (HoveredButton != null)
                        {
                            this.IsNavigatingWithGamepad = false;
                        }
                    }
                }
            }

            UpdateHoveredItem(e);
        }