From f3f4c562ff0625df99782af09725391d0f1c0a8a Mon Sep 17 00:00:00 2001 From: zuu Date: Fri, 21 Sep 2012 19:58:18 +0000 Subject: (svn r24537) -Feature: Scripts can be suspended even if the game is still progressing, thus break-on-log now works also for Game Scripts. --- src/game/game.hpp | 20 ++++++++++++++++++++ src/game/game_core.cpp | 15 +++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'src/game') diff --git a/src/game/game.hpp b/src/game/game.hpp index 0347758e4..66a155bd5 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -46,6 +46,26 @@ public: */ static void Uninitialize(bool keepConfig); + /** + * Suspends the Game Script and then pause the execution of the script. The + * script will not be resumed from its suspended state until the script + * has been unpaused. + */ + static void Pause(); + + /** + * Resume execution of the Game Script. This function will not actually execute + * the script, but set a flag so that the script is executed my the usual + * mechanism that executes the script. + */ + static void Unpause(); + + /** + * Checks if the Game Script is paused. + * @return true if the Game Script is paused, otherwise false. + */ + static bool IsPaused(); + /** * Queue a new event for a Game Script. */ diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index f56dddf83..f32a99b27 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -117,6 +117,21 @@ } } +/* static */ void Game::Pause() +{ + if (Game::instance != NULL) Game::instance->Pause(); +} + +/* static */ void Game::Unpause() +{ + if (Game::instance != NULL) Game::instance->Unpause(); +} + +/* static */ bool Game::IsPaused() +{ + return Game::instance != NULL? Game::instance->IsPaused() : false; +} + /* static */ void Game::NewEvent(ScriptEvent *event) { /* AddRef() and Release() need to be called at least once, so do it here */ -- cgit v1.2.3-54-g00ecf