From fa74bcc4d50c746c3f06b156200a064a11369baa Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 07:51:05 +0000 Subject: ZVISION: Add to sidefx and scriptManager classes stop and kill methods --- engines/zvision/script_manager.cpp | 46 ++++++++++++++++++++++++++++++++++++++ engines/zvision/script_manager.h | 4 ++++ engines/zvision/sidefx.h | 5 +++++ 3 files changed, 55 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 3054466cd0..111865302a 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -336,6 +336,52 @@ SideFX *ScriptManager::getSideFX(uint32 key) { return nullptr; } +void ScriptManager::deleteSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + delete(*iter); + _activeSideFx.erase(iter); + break; + } + } +} + +void ScriptManager::stopSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + bool ret = (*iter)->stop(); + if (ret) { + delete(*iter); + _activeSideFx.erase(iter); + } + break; + } + } +} + +void ScriptManager::killSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + (*iter)->kill(); + delete(*iter); + _activeSideFx.erase(iter); + break; + } + } +} + +void ScriptManager::killSideFxType(SideFX::SideFXType type) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { + if ((*iter)->getType() & type) { + (*iter)->kill(); + delete(*iter); + _activeSideFx.erase(iter); + } else { + ++iter; + } + } +} + void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 90df2ccee5..3399484970 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -187,6 +187,10 @@ public: void addSideFX(SideFX *fx); SideFX *getSideFX(uint32 key); + void deleteSideFx(uint32 key); + void stopSideFx(uint32 key); + void killSideFx(uint32 key); + void killSideFxType(SideFX::SideFXType type); /** * Called when LeftMouse is pushed. diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 6f75ad6649..9c18371ef4 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -88,6 +88,11 @@ public: return false; } + virtual bool stop() { + return true; + } + virtual void kill() {} + protected: ZVision *_engine; uint32 _key; -- cgit v1.2.3