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 --- src/map.cpp | 2 ++ src/map.h | 3 +++ src/menu_system.cpp | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') 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