diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 13:10:47 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
| commit | 8a7d87a312b3dc42877577e99533c96d48714368 (patch) | |
| tree | d68d614ba817237e347e0982afdae17b7b54e197 /src/menu.h | |
| parent | fce37403bbc29521b2b5bd983291b3730f8ad7b4 (diff) | |
| download | tanetane-8a7d87a312b3dc42877577e99533c96d48714368.tar.gz tanetane-8a7d87a312b3dc42877577e99533c96d48714368.tar.bz2 tanetane-8a7d87a312b3dc42877577e99533c96d48714368.zip | |
Added sliders to the settings menu
#7
Diffstat (limited to 'src/menu.h')
| -rw-r--r-- | src/menu.h | 26 |
1 files changed, 23 insertions, 3 deletions
| diff --git a/src/menu.h b/src/menu.h index 67c75c0..9ef94be 100644 --- a/src/menu.h +++ b/src/menu.h | |||
| @@ -9,14 +9,17 @@ | |||
| 9 | class Game; | 9 | class Game; |
| 10 | 10 | ||
| 11 | enum class MenuType { | 11 | enum class MenuType { |
| 12 | Command | 12 | Command, |
| 13 | Slider | ||
| 13 | }; | 14 | }; |
| 14 | 15 | ||
| 15 | struct MenuItem { | 16 | struct MenuItem { |
| 16 | MenuType type = MenuType::Command; | 17 | MenuType type = MenuType::Command; |
| 17 | std::string text; | 18 | std::string text; |
| 18 | std::function<void(Game&)> activationFunction; | 19 | std::function<void(Game&)> activationFunction; |
| 19 | bool playSfx = false; | 20 | bool playSfx = true; |
| 21 | int value = 0; | ||
| 22 | int maxValue = 0; | ||
| 20 | }; | 23 | }; |
| 21 | 24 | ||
| 22 | class MenuBuilder { | 25 | class MenuBuilder { |
| @@ -25,7 +28,6 @@ public: | |||
| 25 | MenuBuilder& Command(std::string text) { | 28 | MenuBuilder& Command(std::string text) { |
| 26 | result_.type = MenuType::Command; | 29 | result_.type = MenuType::Command; |
| 27 | result_.text = std::move(text); | 30 | result_.text = std::move(text); |
| 28 | result_.playSfx = true; | ||
| 29 | return *this; | 31 | return *this; |
| 30 | } | 32 | } |
| 31 | 33 | ||
| @@ -39,6 +41,22 @@ public: | |||
| 39 | return *this; | 41 | return *this; |
| 40 | } | 42 | } |
| 41 | 43 | ||
| 44 | MenuBuilder& Slider(std::string text) { | ||
| 45 | result_.type = MenuType::Slider; | ||
| 46 | result_.text = std::move(text); | ||
| 47 | return *this; | ||
| 48 | } | ||
| 49 | |||
| 50 | MenuBuilder& InitialValue(int value) { | ||
| 51 | result_.value = value; | ||
| 52 | return *this; | ||
| 53 | } | ||
| 54 | |||
| 55 | MenuBuilder& MaxValue(int mv) { | ||
| 56 | result_.maxValue = mv; | ||
| 57 | return *this; | ||
| 58 | } | ||
| 59 | |||
| 42 | MenuItem Build() const { | 60 | MenuItem Build() const { |
| 43 | return result_; | 61 | return result_; |
| 44 | } | 62 | } |
| @@ -55,6 +73,8 @@ public: | |||
| 55 | 73 | ||
| 56 | const std::vector<MenuItem>& getItems() const { return items_; } | 74 | const std::vector<MenuItem>& getItems() const { return items_; } |
| 57 | 75 | ||
| 76 | std::vector<MenuItem>& getItems() { return items_; } | ||
| 77 | |||
| 58 | int getCursorPosition() const { return cursor_; } | 78 | int getCursorPosition() const { return cursor_; } |
| 59 | 79 | ||
| 60 | void moveCursorUp(); | 80 | void moveCursorUp(); |
