> For the complete documentation index, see [llms.txt](https://redboard.gitbook.io/r-type-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://redboard.gitbook.io/r-type-1/client/menumanager.md).

# MenuManager

Manager used for the menus in the game

```cpp
class MenuManager {
    public:
        MenuManager(ECS::Registry &ecs);
        ~MenuManager();

        enum BUTTON_TYPE {
            NO_BUTTON = -1,
            CREATE_GAME,
            JOIN_GAME,
            EXIT_SYSTEM,
            LEAVE_GAME,
            ROOM_LIST_0,
            ROOM_LIST_1,
            ROOM_LIST_2,
            ROOM_LIST_3,
            ROOM_LIST_4,
            ROOM_LIST_5,
        };

        enum MENU_TYPE {
            MAIN_MENU,
            LOOSER_MENU,
            COUNT
        };


        void setSelectedButton(BUTTON_TYPE type);
        void createMenu(MENU_TYPE type, entity_t entity, bool isDisplay, std::vector<BUTTON_TYPE> buttons);
        void removeMenu(MENU_TYPE type);

        void createButton(BUTTON_TYPE type, entity_t entity);

        entity_t getMenuEntity(MENU_TYPE type);
        void changeMenuEntity(MENU_TYPE type, entity_t entity);
        bool menuState(MENU_TYPE type);
        void enableMenu(MENU_TYPE type);
        void disableMenu(MENU_TYPE type);
        void disableAllmenu();

        void nextButtonInMenu(MENU_TYPE type);
        void previousButtonInMenu(MENU_TYPE type);
        void executeButtonInMenu(ECS::Registry &ecs);


    private:
        std::unordered_map<BUTTON_TYPE, entity_t> _buttons;
        std::unordered_map<MENU_TYPE, std::pair<std::pair<entity_t, bool>, std::vector<BUTTON_TYPE>>> _menu; // MENU_TYPE, menu entity, isDisplayed, buttons
        BUTTON_TYPE _selectedButton;
        ECS::Registry &_ecs;
        bool checkLastButtonInput();
        long _lastButtonInput;

};
```

In this class, you will find each methods and variables that we use to handle each menu present in the game. <br>

As you may see, there is some variables to store buttons, which button is currently selected and others.

You will also find some ENUM, for example BUTTON\_TYPE enum is an enum that we use for our buttons (create game, join game, etc...).

Methods present in this class are used to handle the user's actions on a menu. For example if he changed the selected button, if he click on a button or even if he's done an action that display a menu.
