blob: 71e2b3959be44e3384aceb5272c969c6ca151d7f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#ifndef MENU_SYSTEM_H_205861EC
#define MENU_SYSTEM_H_205861EC
#include <deque>
#include <vector>
#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<Menu> menus_;
int cursorBob_ = 0;
bool cursorBobDown_ = true;
Timer cursorBobTimer_ { 125 };
Interpolation menuChangeAnimation_;
bool isMenuChanging_ = false;
};
#endif /* end of include guard: MENU_SYSTEM_H_205861EC */
|