diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 10:01:39 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
commit | 37bbad70090071a473a04583e373491557906699 (patch) | |
tree | a7bffa340c8222d7447a1fb3bfb1d8dd2921918d /src | |
parent | f9dd0fbabe5348fcd9841978cdd9d3a5824a5dec (diff) | |
download | tanetane-37bbad70090071a473a04583e373491557906699.tar.gz tanetane-37bbad70090071a473a04583e373491557906699.tar.bz2 tanetane-37bbad70090071a473a04583e373491557906699.zip |
Added option to exit area from pause menu on supported maps
#7
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 2 | ||||
-rw-r--r-- | src/map.h | 3 | ||||
-rw-r--r-- | src/menu_system.cpp | 15 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/map.cpp b/src/map.cpp index a170288..c8bf18f 100644 --- a/src/map.cpp +++ b/src/map.cpp | |||
@@ -179,6 +179,8 @@ Map::Map(std::string_view name) : name_(name) { | |||
179 | music_ = property.getStringValue(); | 179 | music_ = property.getStringValue(); |
180 | } else if (property.getName() == "maskZone") { | 180 | } else if (property.getName() == "maskZone") { |
181 | maskZone_ = property.getStringValue(); | 181 | maskZone_ = property.getStringValue(); |
182 | } else if (property.getName() == "exitArea") { | ||
183 | hasExitArea_ = property.getBoolValue(); | ||
182 | } | 184 | } |
183 | } | 185 | } |
184 | } | 186 | } |
diff --git a/src/map.h b/src/map.h index 7398d66..7300e76 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -89,6 +89,8 @@ public: | |||
89 | 89 | ||
90 | const std::string& getMaskZone() const { return maskZone_; } | 90 | const std::string& getMaskZone() const { return maskZone_; } |
91 | 91 | ||
92 | bool hasExitArea() const { return hasExitArea_; } | ||
93 | |||
92 | private: | 94 | private: |
93 | 95 | ||
94 | std::string name_; | 96 | std::string name_; |
@@ -104,6 +106,7 @@ private: | |||
104 | std::map<std::string, Zone> zones_; | 106 | std::map<std::string, Zone> zones_; |
105 | std::string music_; | 107 | std::string music_; |
106 | std::string maskZone_; | 108 | std::string maskZone_; |
109 | bool hasExitArea_ = false; | ||
107 | }; | 110 | }; |
108 | 111 | ||
109 | #endif /* end of include guard: MAP_H_D95D6D47 */ | 112 | #endif /* end of include guard: MAP_H_D95D6D47 */ |
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index 34616a6..468fa6e 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "menu_system.h" | 1 | #include "menu_system.h" |
2 | #include "game.h" | 2 | #include "game.h" |
3 | #include "script_system.h" | ||
3 | 4 | ||
4 | void MenuSystem::tick(double dt) { | 5 | void MenuSystem::tick(double dt) { |
5 | pauseAnimation_.tick(dt); | 6 | pauseAnimation_.tick(dt); |
@@ -38,7 +39,7 @@ void MenuSystem::openPauseMenu() { | |||
38 | 39 | ||
39 | game_.pauseGameplay(); | 40 | game_.pauseGameplay(); |
40 | 41 | ||
41 | menu_ = CreateMenu({ | 42 | std::vector<MenuBuilder> builders = { |
42 | MenuBuilder().Command("Settings"), | 43 | MenuBuilder().Command("Settings"), |
43 | MenuBuilder().Command("Resume Game") | 44 | MenuBuilder().Command("Resume Game") |
44 | .ActivationFunction([] (Game& game) { | 45 | .ActivationFunction([] (Game& game) { |
@@ -48,7 +49,17 @@ void MenuSystem::openPauseMenu() { | |||
48 | .ActivationFunction([] (Game& game) { | 49 | .ActivationFunction([] (Game& game) { |
49 | game.quit(); | 50 | game.quit(); |
50 | }) | 51 | }) |
51 | }); | 52 | }; |
53 | |||
54 | if (game_.getMap().hasExitArea()) { | ||
55 | builders.push_back(MenuBuilder().Command("Exit Area") | ||
56 | .ActivationFunction([] (Game& game) { | ||
57 | game.getSystem<MenuSystem>().closePauseMenu(); | ||
58 | game.getSystem<ScriptSystem>().runScript(game.getMap().getName(), "exit_area"); | ||
59 | })); | ||
60 | } | ||
61 | |||
62 | menu_ = CreateMenu(builders); | ||
52 | 63 | ||
53 | cursor_ = 0; | 64 | cursor_ = 0; |
54 | } | 65 | } |