#ifndef MENU_SYSTEM_H_205861EC #define MENU_SYSTEM_H_205861EC #include #include #include "interpolation.h" #include "menu.h" #include "system.h" #include "timer.h" class Game; class MenuSystem : public System { public: static constexpr SystemKey Key = SystemKey::Menu; explicit MenuSystem(Game& game) : game_(game) {} void tick(double dt) override; // Commands void openPauseMenu(); void closePauseMenu(bool playSfx = true); void pressedUp(); void pressedDown(); void pressedLeft(); void pressedRight(); void activateOption(); // Info double getPauseAnimationProgress() const { return pauseAnimation_.getProgress(); } bool isMenuOpen() const { return openState_ == OpenState::Open && !isMenuChanging_; } // Only call this if a menu is open. Menu& getMenu() { return menus_.back(); } // Only call this if a submenu is open. Menu& getParentMenu() { return menus_[menus_.size()-2]; } int getCursorBob() const { return cursorBob_; } double getMenuChangeAnimationProgress() const { return menuChangeAnimation_.getProgress(); } bool isMenuChanging() const { return isMenuChanging_; } private: void openSubmenu(Menu submenu); enum class OpenState { Closed, Animating, Open }; Game& game_; Interpolation pauseAnimation_; OpenState openState_ = OpenState::Closed; std::deque menus_; int cursorBob_ = 0; bool cursorBobDown_ = true; Timer cursorBobTimer_ { 125 }; Interpolation menuChangeAnimation_; bool isMenuChanging_ = false; }; #endif /* end of include guard: MENU_SYSTEM_H_205861EC */