R-Type
R-Type project
MenuManager.hpp
1 #pragma once
2 
3 #include "Menu/Menu.hpp"
4 #include "Dictionary.hpp"
5 
6 namespace RType {
7  class MenuManager {
8  private:
10 
11  public:
12  MenuManager() = default;
13  ~MenuManager() = default;
14 
15  void registerMenu(const std::string &name, const std::shared_ptr<Menu> &menu) {
16  menus[name] = menu;
17  menu->__initCanvas(name);
18  menu->init();
19  }
20 
21  void showMenu(const std::string &name) {
22  std::shared_ptr<Menu> menu;
23  if (menus.tryGetValue(name, menu)) {
24  menu->show();
25  } else {
26  throw KapEngine::Errors::Error("Menu " + name + " not found");
27  }
28  }
29 
30  void hideMenu(const std::string &name) {
31  std::shared_ptr<Menu> menu;
32  if (menus.tryGetValue(name, menu)) {
33  menu->hide();
34  } else {
35  throw KapEngine::Errors::Error("Menu " + name + " not found");
36  }
37  }
38  };
39 } // namespace RType
RType::MenuManager
Definition: MenuManager.hpp:7
KapEngine::Dictionary
Definition: Dictionary.hpp:16
KapEngine::Errors::Error
Definition: Errors.hpp:24