diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 12:24:05 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
| commit | fce37403bbc29521b2b5bd983291b3730f8ad7b4 (patch) | |
| tree | c7bdf0fa62f6d67f85b97a7cda746da31470def2 /src/menu_system.h | |
| parent | c6b5e936ff9869d8a3de9ea41db784a4cb46a818 (diff) | |
| download | tanetane-fce37403bbc29521b2b5bd983291b3730f8ad7b4.tar.gz tanetane-fce37403bbc29521b2b5bd983291b3730f8ad7b4.tar.bz2 tanetane-fce37403bbc29521b2b5bd983291b3730f8ad7b4.zip | |
Added submenus
#7
Diffstat (limited to 'src/menu_system.h')
| -rw-r--r-- | src/menu_system.h | 24 |
1 files changed, 19 insertions, 5 deletions
| diff --git a/src/menu_system.h b/src/menu_system.h index 736d555..c921d0b 100644 --- a/src/menu_system.h +++ b/src/menu_system.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #ifndef MENU_SYSTEM_H_205861EC | 1 | #ifndef MENU_SYSTEM_H_205861EC |
| 2 | #define MENU_SYSTEM_H_205861EC | 2 | #define MENU_SYSTEM_H_205861EC |
| 3 | 3 | ||
| 4 | #include <deque> | ||
| 4 | #include <vector> | 5 | #include <vector> |
| 5 | #include "interpolation.h" | 6 | #include "interpolation.h" |
| 6 | #include "menu.h" | 7 | #include "menu.h" |
| @@ -34,16 +35,24 @@ public: | |||
| 34 | 35 | ||
| 35 | double getPauseAnimationProgress() const { return pauseAnimation_.getProgress(); } | 36 | double getPauseAnimationProgress() const { return pauseAnimation_.getProgress(); } |
| 36 | 37 | ||
| 37 | bool isMenuOpen() const { return openState_ == OpenState::Open; } | 38 | bool isMenuOpen() const { return openState_ == OpenState::Open && !isMenuChanging_; } |
| 38 | 39 | ||
| 39 | const std::vector<MenuItem>& getMenu() const { return menu_; } | 40 | // Only call this if a menu is open. |
| 41 | Menu& getMenu() { return menus_.back(); } | ||
| 40 | 42 | ||
| 41 | int getCursorPosition() const { return cursor_; } | 43 | // Only call this if a submenu is open. |
| 44 | Menu& getParentMenu() { return menus_[menus_.size()-2]; } | ||
| 42 | 45 | ||
| 43 | int getCursorBob() const { return cursorBob_; } | 46 | int getCursorBob() const { return cursorBob_; } |
| 44 | 47 | ||
| 48 | double getMenuChangeAnimationProgress() const { return menuChangeAnimation_.getProgress(); } | ||
| 49 | |||
| 50 | bool isMenuChanging() const { return isMenuChanging_; } | ||
| 51 | |||
| 45 | private: | 52 | private: |
| 46 | 53 | ||
| 54 | void openSubmenu(Menu submenu); | ||
| 55 | |||
| 47 | enum class OpenState { | 56 | enum class OpenState { |
| 48 | Closed, | 57 | Closed, |
| 49 | Animating, | 58 | Animating, |
| @@ -51,13 +60,18 @@ private: | |||
| 51 | }; | 60 | }; |
| 52 | 61 | ||
| 53 | Game& game_; | 62 | Game& game_; |
| 63 | |||
| 54 | Interpolation pauseAnimation_; | 64 | Interpolation pauseAnimation_; |
| 55 | OpenState openState_ = OpenState::Closed; | 65 | OpenState openState_ = OpenState::Closed; |
| 56 | std::vector<MenuItem> menu_; | 66 | |
| 57 | int cursor_ = 0; | 67 | std::deque<Menu> menus_; |
| 68 | |||
| 58 | int cursorBob_ = 0; | 69 | int cursorBob_ = 0; |
| 59 | bool cursorBobDown_ = true; | 70 | bool cursorBobDown_ = true; |
| 60 | Timer cursorBobTimer_ { 125 }; | 71 | Timer cursorBobTimer_ { 125 }; |
| 72 | |||
| 73 | Interpolation menuChangeAnimation_; | ||
| 74 | bool isMenuChanging_ = false; | ||
| 61 | }; | 75 | }; |
| 62 | 76 | ||
| 63 | #endif /* end of include guard: MENU_SYSTEM_H_205861EC */ | 77 | #endif /* end of include guard: MENU_SYSTEM_H_205861EC */ |
