Skip to content

Commit

Permalink
ZVISION: Add to sidefx and scriptManager classes stop and kill methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Oct 30, 2013
1 parent 41088f5 commit fa74bcc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
46 changes: 46 additions & 0 deletions engines/zvision/script_manager.cpp
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions engines/zvision/script_manager.h
Expand Up @@ -187,6 +187,10 @@ class ScriptManager {

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.
Expand Down
5 changes: 5 additions & 0 deletions engines/zvision/sidefx.h
Expand Up @@ -88,6 +88,11 @@ class SideFX {
return false;
}

virtual bool stop() {
return true;
}
virtual void kill() {}

protected:
ZVision *_engine;
uint32 _key;
Expand Down

0 comments on commit fa74bcc

Please sign in to comment.