Example #1
0
        // '' <summary>
        // '' Handles input for the specified menu.
        // '' </summary>
        // '' <param name="menu">the identifier of the menu being processed</param>
        // '' <param name="level">the vertical level of the menu</param>
        // '' <param name="xOffset">the xoffset of the menu</param>
        // '' <returns>false if a clicked missed the buttons. This can be used to check prior menus.</returns>
        private static bool HandleMenuInput(int menu, int level, int xOffset)
        {
            if (SwinGame.KeyTyped(KeyCode.EscapeKey))
            {
                EndCurrentState();
                return(true);
            }

            if (SwinGame.MouseClicked(MouseButton.LeftButton))
            {
                int i;
                for (i = 0; i <= _menuStructure(menu).Length - 1; i++)
                {
                    // IsMouseOver the i'th button of the menu
                    if (MenuController.IsMouseOverMenu(i, level, xOffset))
                    {
                        MenuController.PerformMenuAction(menu, i);
                        return(true);
                    }
                }

                if ((level > 0))
                {
                    // none clicked - so end this sub menu
                    EndCurrentState();
                }
            }

            return(false);
        }