mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-13 07:14:59 +00:00
MOHAWK: Move running the card leave script to the RivenCard destructor
This commit is contained in:
parent
9b2c90c0b3
commit
aa0c89da03
@ -387,9 +387,6 @@ void MohawkEngine_Riven::changeToCard(uint16 dest) {
|
||||
}
|
||||
}
|
||||
|
||||
if (_card)
|
||||
_card->runScript(kCardLeaveScript);
|
||||
|
||||
delete _card;
|
||||
_card = new RivenCard(this, dest);
|
||||
|
||||
@ -400,9 +397,6 @@ void MohawkEngine_Riven::refreshCard() {
|
||||
// Clear any timer still floating around
|
||||
removeTimer();
|
||||
|
||||
_gfx->clearWaterEffects();
|
||||
_video->stopVideos();
|
||||
|
||||
_card->open();
|
||||
|
||||
if (_showHotspots)
|
||||
@ -838,7 +832,7 @@ void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
|
||||
ZipMode zip;
|
||||
zip.name = cardName;
|
||||
zip.id = cardId;
|
||||
if (!(Common::find(_zipModeData.begin(), _zipModeData.end(), zip) != _zipModeData.end()))
|
||||
if (Common::find(_zipModeData.begin(), _zipModeData.end(), zip) == _zipModeData.end())
|
||||
_zipModeData.push_back(zip);
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,14 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) :
|
||||
}
|
||||
|
||||
RivenCard::~RivenCard() {
|
||||
runLeaveScripts();
|
||||
|
||||
for (uint i = 0; i < _hotspots.size(); i++) {
|
||||
delete _hotspots[i];
|
||||
}
|
||||
|
||||
_vm->_gfx->clearWaterEffects();
|
||||
_vm->_video->stopVideos();
|
||||
}
|
||||
|
||||
void RivenCard::loadCardResource(uint16 id) {
|
||||
@ -93,13 +98,18 @@ void RivenCard::initializeZipMode() {
|
||||
}
|
||||
}
|
||||
|
||||
void RivenCard::runScript(uint16 scriptType) {
|
||||
RivenScriptPtr RivenCard::getScript(uint16 scriptType) const {
|
||||
for (uint16 i = 0; i < _scripts.size(); i++)
|
||||
if (_scripts[i].type == scriptType) {
|
||||
RivenScriptPtr script = _scripts[i].script;
|
||||
_vm->_scriptMan->runScript(script, false);
|
||||
break;
|
||||
return _scripts[i].script;
|
||||
}
|
||||
|
||||
return RivenScriptPtr(new RivenScript());
|
||||
}
|
||||
|
||||
void RivenCard::runScript(uint16 scriptType) {
|
||||
RivenScriptPtr script = getScript(scriptType);
|
||||
_vm->_scriptMan->runScript(script, false);
|
||||
}
|
||||
|
||||
uint16 RivenCard::getId() const {
|
||||
@ -381,12 +391,12 @@ void RivenCard::onMouseDragUpdate() {
|
||||
}
|
||||
|
||||
void RivenCard::onMouseUpdate() {
|
||||
RivenScriptPtr script;
|
||||
RivenScriptPtr script(new RivenScript());
|
||||
if (_hoveredHotspot) {
|
||||
script = _hoveredHotspot->getScript(kMouseInsideScript);
|
||||
}
|
||||
|
||||
if (script && !script->empty()) {
|
||||
if (!script->empty()) {
|
||||
_vm->_scriptMan->runScript(script, false);
|
||||
} else {
|
||||
updateMouseCursor();
|
||||
@ -405,6 +415,22 @@ void RivenCard::updateMouseCursor() {
|
||||
_vm->_system->updateScreen();
|
||||
}
|
||||
|
||||
void RivenCard::runLeaveScripts() {
|
||||
RivenScriptPtr script(new RivenScript());
|
||||
|
||||
if (_pressedHotspot) {
|
||||
script += _pressedHotspot->getScript(kMouseUpScript);
|
||||
}
|
||||
|
||||
if (_hoveredHotspot) {
|
||||
script += _hoveredHotspot->getScript(kMouseLeaveScript);
|
||||
}
|
||||
|
||||
script += getScript(kCardLeaveScript);
|
||||
|
||||
_vm->_scriptMan->runScript(script, false);
|
||||
}
|
||||
|
||||
RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) :
|
||||
_vm(vm) {
|
||||
loadFromStream(stream);
|
||||
@ -448,7 +474,7 @@ RivenScriptPtr RivenHotspot::getScript(uint16 scriptType) const {
|
||||
return _scripts[i].script;
|
||||
}
|
||||
|
||||
return RivenScriptPtr();
|
||||
return RivenScriptPtr(new RivenScript());
|
||||
}
|
||||
|
||||
bool RivenHotspot::isEnabled() const {
|
||||
|
@ -125,7 +125,11 @@ private:
|
||||
void loadCardHotspotEnableList(uint16 id);
|
||||
void loadCardWaterEffectList(uint16 id);
|
||||
|
||||
RivenScriptPtr getScript(uint16 scriptType) const;
|
||||
void defaultLoadScript();
|
||||
void runLeaveScripts();
|
||||
|
||||
void updateMouseCursor();
|
||||
|
||||
struct HotspotEnableRecord {
|
||||
uint16 index;
|
||||
@ -156,8 +160,6 @@ private:
|
||||
Common::Array<SLSTRecord> _soundList;
|
||||
Common::Array<HotspotEnableRecord> _hotspotEnableList;
|
||||
Common::Array<WaterEffectRecord> _waterEffectList;
|
||||
|
||||
void updateMouseCursor();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -114,10 +114,6 @@ void RivenScriptManager::clearStoredMovieOpcode() {
|
||||
}
|
||||
|
||||
void RivenScriptManager::runScript(const RivenScriptPtr &script, bool queue) {
|
||||
if (!script || script->empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
script->run();
|
||||
} else {
|
||||
@ -187,6 +183,16 @@ bool RivenScript::empty() const {
|
||||
return _commands.empty();
|
||||
}
|
||||
|
||||
RivenScript &RivenScript::operator+=(const RivenScript &other) {
|
||||
_commands.push_back(other._commands);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RivenScriptPtr &operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs) {
|
||||
*lhs += *rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
RivenCommand::RivenCommand(MohawkEngine_Riven *vm) :
|
||||
_vm(vm) {
|
||||
|
||||
|
@ -87,11 +87,17 @@ public:
|
||||
/** Stop the script after the current command */
|
||||
void stopRunning() { _continueRunning = false; }
|
||||
|
||||
/** Append the commands of the other script to this script */
|
||||
RivenScript &operator+=(const RivenScript &other);
|
||||
|
||||
private:
|
||||
Common::Array<RivenCommand *> _commands;
|
||||
bool _continueRunning;
|
||||
};
|
||||
|
||||
/** Append the commands of the rhs Script to those of the lhs Script */
|
||||
RivenScriptPtr &operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs);
|
||||
|
||||
/**
|
||||
* A script and its type
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user