From a6f025c74f7aac95154d56dc23a7b62eca965dd4 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 20:11:33 +0000 Subject: ZVISION: Basic integration of SideFX into scriptManager. --- engines/zvision/script_manager.cpp | 26 +++++++++++++++++++++++++- engines/zvision/script_manager.h | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 66a54088fd..4b4f1303aa 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -108,6 +108,16 @@ void ScriptManager::createReferenceTable() { } void ScriptManager::updateNodes(uint deltaTimeMillis) { + // If process() returns true, it means the node can be deleted + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { + if ((*iter)->process(deltaTimeMillis)) { + delete (*iter); + // Remove the node + iter = _activeSideFx.erase(iter); + } else { + ++iter; + } + } // If process() returns true, it means the node can be deleted for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { if ((*iter)->process(deltaTimeMillis)) { @@ -262,7 +272,7 @@ void ScriptManager::disableControl(uint32 key) { void ScriptManager::focusControl(uint32 key) { for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { uint32 controlKey = (*iter)->getKey(); - + if (controlKey == key) { (*iter)->focus(); } else if (controlKey == _currentlyFocusedControl) { @@ -273,6 +283,20 @@ void ScriptManager::focusControl(uint32 key) { _currentlyFocusedControl = key; } +void ScriptManager::addSideFX(SideFX *fx) { + _activeSideFx.push_back(fx); +} + +SideFX *ScriptManager::getSideFX(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + return (*iter); + } + } + + return nullptr; +} + void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 388d0805e0..c29bc57d03 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -25,6 +25,7 @@ #include "zvision/puzzle.h" #include "zvision/control.h" +#include "zvision/sidefx.h" #include "common/hashmap.h" #include "common/queue.h" @@ -54,6 +55,7 @@ typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; typedef Common::HashMap StateMap; +typedef Common::List SideFXList; class ScriptManager { public: @@ -78,6 +80,8 @@ private: PuzzleList _globalPuzzles; /** Holds the currently active controls */ ControlList _activeControls; + /** Holds the currently active timers, musics, other */ + SideFXList _activeSideFx; Location _currentLocation; @@ -99,6 +103,9 @@ public: void focusControl(uint32 key); + void addSideFX(SideFX *fx); + SideFX *getSideFX(uint32 key); + /** * Called when LeftMouse is pushed. * @@ -140,7 +147,7 @@ public: void deserializeStateTable(Common::SeekableReadStream *stream); void serializeControls(Common::WriteStream *stream); void deserializeControls(Common::SeekableReadStream *stream); - + Location getCurrentLocation() const; private: -- cgit v1.2.3