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 | |
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
-rw-r--r-- | res/maps/time_passage.tmx | 1 | ||||
-rw-r--r-- | res/maps/time_passage_antechamber.tmx | 1 | ||||
-rw-r--r-- | res/maps/underwater_start.tmx | 1 | ||||
-rw-r--r-- | src/map.cpp | 2 | ||||
-rw-r--r-- | src/map.h | 3 | ||||
-rw-r--r-- | src/menu_system.cpp | 15 |
6 files changed, 21 insertions, 2 deletions
diff --git a/res/maps/time_passage.tmx b/res/maps/time_passage.tmx index c5c6b71..64815a9 100644 --- a/res/maps/time_passage.tmx +++ b/res/maps/time_passage.tmx | |||
@@ -1,6 +1,7 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="32" height="128" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="4"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="32" height="128" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="4"> |
3 | <properties> | 3 | <properties> |
4 | <property name="exitArea" type="bool" value="true"/> | ||
4 | <property name="music" value="time_passage"/> | 5 | <property name="music" value="time_passage"/> |
5 | </properties> | 6 | </properties> |
6 | <tileset firstgid="1" source="time_passage.tsx"/> | 7 | <tileset firstgid="1" source="time_passage.tsx"/> |
diff --git a/res/maps/time_passage_antechamber.tmx b/res/maps/time_passage_antechamber.tmx index f705305..da7c421 100644 --- a/res/maps/time_passage_antechamber.tmx +++ b/res/maps/time_passage_antechamber.tmx | |||
@@ -1,6 +1,7 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="5"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="5"> |
3 | <properties> | 3 | <properties> |
4 | <property name="exitArea" type="bool" value="true"/> | ||
4 | <property name="music" value="time_passage"/> | 5 | <property name="music" value="time_passage"/> |
5 | </properties> | 6 | </properties> |
6 | <tileset firstgid="1" source="time_passage.tsx"/> | 7 | <tileset firstgid="1" source="time_passage.tsx"/> |
diff --git a/res/maps/underwater_start.tmx b/res/maps/underwater_start.tmx index d616c27..191fb1c 100644 --- a/res/maps/underwater_start.tmx +++ b/res/maps/underwater_start.tmx | |||
@@ -1,6 +1,7 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="32" height="32" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="5"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="32" height="32" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="5"> |
3 | <properties> | 3 | <properties> |
4 | <property name="exitArea" type="bool" value="true"/> | ||
4 | <property name="music" value="barren_factory"/> | 5 | <property name="music" value="barren_factory"/> |
5 | </properties> | 6 | </properties> |
6 | <tileset firstgid="1" source="underwater.tsx"/> | 7 | <tileset firstgid="1" source="underwater.tsx"/> |
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 | } |