From 9b14f5faedef513be2f17da57b7fb9182a751150 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 6 Jun 2007 19:46:10 +0000 Subject: [PATCH] Implemented the sfGetMouseClicks and sfResetMouseClicks opcodes and created the skeleton for sfScriptStartVideo, sfScriptReturnFromVideo and sfScriptEndVideo opcodes svn-id: r27145 --- engines/saga/animation.cpp | 42 +++++++++++++++++++++++++++++++++++--- engines/saga/animation.h | 9 ++++++++ engines/saga/saga.cpp | 1 + engines/saga/saga.h | 13 ++++++++++++ engines/saga/scene.cpp | 5 +++++ engines/saga/scene.h | 1 + engines/saga/script.cpp | 1 + engines/saga/sfuncs.cpp | 20 +++++++++++++----- 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index f9bfe897651..e038213d5cf 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -183,11 +183,16 @@ void Anim::returnFromCutaway(void) { // Note that clearCutaway() sets _cutawayActive to false. clearCutaway(); - // TODO: Handle fade up, if we previously faded down + warning("TODO: Implement the rest of returnFromCutaway()"); - // TODO: Restore the scene + // Handle fade up, if we previously faded down + // TODO - // TODO: Restore the animations + // Restore the scene + _vm->_scene->restoreScene(); + + // Restore the animations + // TODO for (int i = 0; i < MAX_ANIMATIONS; i++) { if (_animations[i] && _animations[i]->state == ANIM_PLAYING) { @@ -213,6 +218,37 @@ void Anim::clearCutaway(void) { } } +void Anim::startVideo(int vid, bool fade) { + debug(0, "startVideo(%d, %d)", vid, fade); + + // TODO + warning(0, "TODO: Anim::startVideo(%d, %d)", vid, fade); + + _videoActive = true; +} + +void Anim::endVideo(void) { + debug(0, "endVideo()"); + + // TODO + warning("TODO: Anim::endVideo()"); + + _videoActive = false; +} + +void Anim::returnFromVideo(void) { + debug(0, "returnFromVideo()"); + + // TODO + warning("TODO: Anim::returnFromVideo"); + + _videoActive = false; +} + +void Anim::nextVideoFrame(void) { + // TODO +} + void Anim::load(uint16 animId, const byte *animResourceData, size_t animResourceLength) { AnimationData *anim; uint16 temp; diff --git a/engines/saga/animation.h b/engines/saga/animation.h index c850fdec833..4aa813c7656 100644 --- a/engines/saga/animation.h +++ b/engines/saga/animation.h @@ -120,6 +120,11 @@ public: void returnFromCutaway(void); void clearCutaway(void); + void startVideo(int vid, bool fade); + void endVideo(void); + void returnFromVideo(void); + void nextVideoFrame(void); + void load(uint16 animId, const byte *animResourceData, size_t animResourceLength); void freeId(uint16 animId); void play(uint16 animId, int vectorTime, bool playing = true); @@ -137,6 +142,9 @@ public: bool hasCutaway(void) { return _cutawayActive; } + bool hasVideo(void) { + return _videoActive; + } bool hasAnimation(uint16 animId) { if (animId >= MAX_ANIMATIONS) { if (animId < MAX_ANIMATIONS + ARRAYSIZE(_cutawayAnimations)) @@ -192,6 +200,7 @@ private: Cutaway *_cutawayList; int _cutawayListLength; bool _cutawayActive; + bool _videoActive; }; } // End of namespace Saga diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 7573988a8d1..23f5b51de7d 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -87,6 +87,7 @@ SagaEngine::SagaEngine(OSystem *syst) _frameCount = 0; _globalFlags = 0; + _mouseClickCount = 0; memset(_ethicsPoints, 0, sizeof(_ethicsPoints)); // The Linux version of Inherit the Earth puts all data files in an diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 1a8da5533a1..b596d2c2a10 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -559,6 +559,18 @@ public: int processInput(void); Point mousePos() const; + int getMouseClickCount() { + return _mouseClickCount; + } + + void incrementMouseClickCount() { + _mouseClickCount++; + } + + void resetMouseClickCount() { + _mouseClickCount = 0; + } + const bool leftMouseButtonPressed() const { return _leftMouseButtonPressed; } @@ -580,6 +592,7 @@ public: bool _leftMouseButtonPressed; bool _rightMouseButtonPressed; + int _mouseClickCount; bool _quit; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 9b7e7fb331d..d59c0bb987e 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1209,6 +1209,11 @@ void Scene::endScene() { } +void Scene::restoreScene() { + // TODO + warning("TODO: restoreScene()"); +} + void Scene::cmdSceneChange(int argc, const char **argv) { int scene_num = 0; diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 2410f672e52..9f2305cfc50 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -224,6 +224,7 @@ class Scene { void nextScene(); void skipScene(); void endScene(); + void restoreScene(); void queueScene(LoadSceneParams *sceneQueue) { _sceneQueue.push_back(*sceneQueue); } diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 578a42c5c87..b62e9aacf5d 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -592,6 +592,7 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) { const HitZone *hitZone; Point specialPoint; + _vm->incrementMouseClickCount(); _vm->_actor->abortSpeech(); if ((_vm->_actor->_protagonist->_currentAction != kActionWait) && diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 560bf10b5a8..1dddba5fcce 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1887,11 +1887,11 @@ void Script::sfEndCutAway(SCRIPTFUNC_PARAMS) { } void Script::sfGetMouseClicks(SCRIPTFUNC_PARAMS) { - SF_stub("sfGetMouseClicks", thread, nArgs); + thread->_returnValue = _vm->getMouseClickCount(); } void Script::sfResetMouseClicks(SCRIPTFUNC_PARAMS) { - SF_stub("sfResetMouseClicks", thread, nArgs); + _vm->resetMouseClickCount(); } // Used in IHNM only @@ -1927,15 +1927,25 @@ void Script::sfScriptFade(SCRIPTFUNC_PARAMS) { } void Script::sfScriptStartVideo(SCRIPTFUNC_PARAMS) { - SF_stub("sfScriptStartVideo", thread, nArgs); + int16 vid; + int16 fade; + vid = thread->pop(); + fade = thread->pop(); + + _vm->_interface->setStatusText(""); + _vm->_anim->startVideo(vid, fade != 0); + _vm->_interface->rememberMode(); + _vm->_interface->setMode(kPanelVideo); } void Script::sfScriptReturnFromVideo(SCRIPTFUNC_PARAMS) { - SF_stub("sfScriptReturnFromVideo", thread, nArgs); + _vm->_anim->returnFromVideo(); + _vm->_interface->restoreMode(); } void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) { - SF_stub("sfScriptEndVideo", thread, nArgs); + _vm->_anim->endVideo(); + _vm->_interface->restoreMode(); } void Script::sf87(SCRIPTFUNC_PARAMS) {