aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorBastien Bouclet2017-02-19 09:36:38 +0100
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit1aa42338025543814ac0dbf41ed62c03ccf01ba8 (patch)
tree1f03b0d35055024bd169992915e7a38852301396 /engines/mohawk
parentad7f94f10f5893ed2ee14f9fc7b48d8ebbce49de (diff)
downloadscummvm-rg350-1aa42338025543814ac0dbf41ed62c03ccf01ba8.tar.gz
scummvm-rg350-1aa42338025543814ac0dbf41ed62c03ccf01ba8.tar.bz2
scummvm-rg350-1aa42338025543814ac0dbf41ed62c03ccf01ba8.zip
MOHAWK: Rework stack frame updates to work like the original
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/riven.cpp7
-rw-r--r--engines/mohawk/riven_card.cpp26
-rw-r--r--engines/mohawk/riven_card.h7
-rw-r--r--engines/mohawk/riven_graphics.cpp14
-rw-r--r--engines/mohawk/riven_graphics.h7
-rw-r--r--engines/mohawk/riven_scripts.cpp8
-rw-r--r--engines/mohawk/riven_scripts.h1
-rw-r--r--engines/mohawk/riven_stack.cpp18
-rw-r--r--engines/mohawk/riven_stack.h3
9 files changed, 65 insertions, 26 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index fcc0f0b752..2a651cf0de 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -194,8 +194,6 @@ void MohawkEngine_Riven::doFrame() {
// Update background running things
checkTimer();
_sound->updateSLST();
- _gfx->runFliesEffect();
- _gfx->runScheduledWaterEffects();
_video->updateMovies();
Common::Event event;
@@ -270,7 +268,7 @@ void MohawkEngine_Riven::doFrame() {
}
}
- _card->onMouseUpdate();
+ _stack->onFrame();
if (!_scriptMan->runningQueuedScripts()) {
// Don't run queued scripts if we are calling from a queued script
@@ -436,8 +434,7 @@ void MohawkEngine_Riven::delayAndUpdate(uint32 ms) {
while (_system->getMillis() < startTime + ms && !shouldQuit()) {
_sound->updateSLST();
- _gfx->runFliesEffect();
- _gfx->runScheduledWaterEffects();
+ _stack->onFrame();
_video->updateMovies();
Common::Event event;
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index cc816a81c9..99ee902799 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -107,7 +107,7 @@ RivenScriptPtr RivenCard::getScript(uint16 scriptType) const {
return _scripts[i].script;
}
- return RivenScriptPtr(new RivenScript());
+ return RivenScriptPtr();
}
void RivenCard::runScript(uint16 scriptType) {
@@ -393,24 +393,30 @@ RivenScriptPtr RivenCard::onMouseMove(const Common::Point &mouse) {
return script;
}
-void RivenCard::onMouseDragUpdate() {
+RivenScriptPtr RivenCard::onMouseDragUpdate() {
+ RivenScriptPtr script;
if (_pressedHotspot) {
- RivenScriptPtr script = _pressedHotspot->getScript(kMouseDragScript);
- _vm->_scriptMan->runScript(script, true);
+ script = _pressedHotspot->getScript(kMouseDragScript);
}
+
+ return script;
}
-void RivenCard::onMouseUpdate() {
- RivenScriptPtr script(new RivenScript());
+RivenScriptPtr RivenCard::onFrame() {
+ return getScript(kCardFrameScript);
+}
+
+RivenScriptPtr RivenCard::onMouseUpdate() {
+ RivenScriptPtr script;
if (_hoveredHotspot) {
script = _hoveredHotspot->getScript(kMouseInsideScript);
}
- if (!script->empty()) {
- _vm->_scriptMan->runScript(script, true);
- } else {
+ if (!script || script->empty()) {
updateMouseCursor();
}
+
+ return script;
}
void RivenCard::updateMouseCursor() {
@@ -608,7 +614,7 @@ RivenScriptPtr RivenHotspot::getScript(uint16 scriptType) const {
return _scripts[i].script;
}
- return RivenScriptPtr(new RivenScript());
+ return RivenScriptPtr();
}
bool RivenHotspot::isEnabled() const {
diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h
index 73c47b66aa..27e6ec2ca8 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -118,11 +118,14 @@ public:
/** Handle a mouse move event */
RivenScriptPtr onMouseMove(const Common::Point &mouse);
+ /** General frame update handler */
+ RivenScriptPtr onFrame();
+
/** Frame update handler for the mouse cursor */
- void onMouseUpdate();
+ RivenScriptPtr onMouseUpdate();
/** Frame update handler for mouse dragging */
- void onMouseDragUpdate();
+ RivenScriptPtr onMouseDragUpdate();
/** Write all of the card's data to standard output */
void dump() const;
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index a07cb79fa8..04562f82ba 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -670,12 +670,6 @@ void RivenGraphics::clearFliesEffect() {
_fliesEffect = nullptr;
}
-void RivenGraphics::runFliesEffect() {
- if (_fliesEffect) {
- _fliesEffect->update();
- }
-}
-
Graphics::Surface *RivenGraphics::getBackScreen() {
return _mainScreen;
}
@@ -684,6 +678,14 @@ Graphics::Surface *RivenGraphics::getEffectScreen() {
return _effectScreen;
}
+void RivenGraphics::updateEffects() {
+ runScheduledWaterEffects();
+
+ if (_fliesEffect) {
+ _fliesEffect->update();
+ }
+}
+
const FliesEffect::FliesEffectData FliesEffect::_firefliesParameters = {
true,
true,
diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h
index 36225dab28..b09eefbded 100644
--- a/engines/mohawk/riven_graphics.h
+++ b/engines/mohawk/riven_graphics.h
@@ -73,12 +73,13 @@ public:
// Water Effect
void scheduleWaterEffect(uint16);
void clearWaterEffects();
- void runScheduledWaterEffects();
// Flies Effect
void setFliesEffect(uint16 count, bool fireflies);
void clearFliesEffect();
- void runFliesEffect();
+
+ /** Update the screen with the water and fly effects */
+ void updateEffects();
// Transitions
void scheduleTransition(RivenTransition id, const Common::Rect &rect = Common::Rect(0, 0, 608, 392));
@@ -115,6 +116,8 @@ private:
};
Common::Array<SFXERecord> _waterEffects;
+ void runScheduledWaterEffects();
+
// Flies Effect
FliesEffect *_fliesEffect;
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 99f1eecf6e..8c6c9745a1 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -120,6 +120,10 @@ void RivenScriptManager::clearStoredMovieOpcode() {
}
void RivenScriptManager::runScript(const RivenScriptPtr &script, bool queue) {
+ if (!script || script->empty()) {
+ return;
+ }
+
if (!queue) {
script->run();
} else {
@@ -239,7 +243,9 @@ const char *RivenScript::getTypeName(uint16 type) {
}
RivenScriptPtr &operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs) {
- *lhs += *rhs;
+ if (rhs) {
+ *lhs += *rhs;
+ }
return lhs;
}
diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h
index b47724d544..d052a02787 100644
--- a/engines/mohawk/riven_scripts.h
+++ b/engines/mohawk/riven_scripts.h
@@ -46,6 +46,7 @@ enum {
kCardLoadScript = 6,
kCardLeaveScript = 7,
+ kCardFrameScript = 8,
kCardEnterScript = 9,
kCardUpdateScript = 10
};
diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp
index f8dd6a30f1..490e4b538b 100644
--- a/engines/mohawk/riven_stack.cpp
+++ b/engines/mohawk/riven_stack.cpp
@@ -272,6 +272,24 @@ void RivenStack::mouseForceUp() {
_mouseIsDown = false;
}
+void RivenStack::onFrame() {
+ if (!_vm->getCard() || _vm->_scriptMan->hasQueuedScripts()) {
+ return;
+ }
+
+ _vm->_gfx->updateEffects();
+
+ RivenScriptPtr script(new RivenScript());
+ if (_mouseIsDown) {
+ script += _vm->getCard()->onMouseDragUpdate();
+ } else {
+ script += _vm->getCard()->onFrame();
+ script += _vm->getCard()->onMouseUpdate();
+ }
+
+ _vm->_scriptMan->runScript(script, true);
+}
+
RivenNameList::RivenNameList() {
}
diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h
index 2365859dad..0ef267e421 100644
--- a/engines/mohawk/riven_stack.h
+++ b/engines/mohawk/riven_stack.h
@@ -120,6 +120,9 @@ public:
/** Handle a mouse move event */
void onMouseMove(const Common::Point &mouse);
+ /** Frame update handler */
+ void onFrame();
+
/** Is the left mouse button currently pressed? */
bool mouseIsDown() const;