From 37bbad70090071a473a04583e373491557906699 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 13 Mar 2021 10:01:39 -0500 Subject: Added option to exit area from pause menu on supported maps #7 --- res/maps/time_passage.tmx | 1 + res/maps/time_passage_antechamber.tmx | 1 + res/maps/underwater_start.tmx | 1 + src/map.cpp | 2 ++ src/map.h | 3 +++ 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 @@ + 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 @@ + 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 @@ + 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) { music_ = property.getStringValue(); } else if (property.getName() == "maskZone") { maskZone_ = property.getStringValue(); + } else if (property.getName() == "exitArea") { + hasExitArea_ = property.getBoolValue(); } } } 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: const std::string& getMaskZone() const { return maskZone_; } + bool hasExitArea() const { return hasExitArea_; } + private: std::string name_; @@ -104,6 +106,7 @@ private: std::map zones_; std::string music_; std::string maskZone_; + bool hasExitArea_ = false; }; #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 @@ #include "menu_system.h" #include "game.h" +#include "script_system.h" void MenuSystem::tick(double dt) { pauseAnimation_.tick(dt); @@ -38,7 +39,7 @@ void MenuSystem::openPauseMenu() { game_.pauseGameplay(); - menu_ = CreateMenu({ + std::vector builders = { MenuBuilder().Command("Settings"), MenuBuilder().Command("Resume Game") .ActivationFunction([] (Game& game) { @@ -48,7 +49,17 @@ void MenuSystem::openPauseMenu() { .ActivationFunction([] (Game& game) { game.quit(); }) - }); + }; + + if (game_.getMap().hasExitArea()) { + builders.push_back(MenuBuilder().Command("Exit Area") + .ActivationFunction([] (Game& game) { + game.getSystem().closePauseMenu(); + game.getSystem().runScript(game.getMap().getName(), "exit_area"); + })); + } + + menu_ = CreateMenu(builders); cursor_ = 0; } -- cgit 1.4.1