diff options
author | Matthew Hoops | 2015-07-17 00:35:30 -0400 |
---|---|---|
committer | Matthew Hoops | 2015-07-17 20:05:04 -0400 |
commit | 9665efa39a4df000eb695329a9b81c1657f4dc10 (patch) | |
tree | 23d4e17554fa05372b07b5a4715d00dc3f779754 /engines/mohawk | |
parent | 7e6c8be7db2449c1f793b6fb01af5613282e7f27 (diff) | |
download | scummvm-rg350-9665efa39a4df000eb695329a9b81c1657f4dc10.tar.gz scummvm-rg350-9665efa39a4df000eb695329a9b81c1657f4dc10.tar.bz2 scummvm-rg350-9665efa39a4df000eb695329a9b81c1657f4dc10.zip |
MOHAWK: Move further VideoManager functionality to VideoEntry
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/console.cpp | 31 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 5 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/channelwood.cpp | 26 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/dni.cpp | 38 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/intro.cpp | 23 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.cpp | 18 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 146 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.cpp | 42 | ||||
-rw-r--r-- | engines/mohawk/video.cpp | 116 | ||||
-rw-r--r-- | engines/mohawk/video.h | 47 |
11 files changed, 366 insertions, 134 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index d49f3e8637..9b5bae78be 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -248,9 +248,9 @@ bool MystConsole::Cmd_PlayMovie(int argc, const char **argv) { return true; } - int8 stackNum = 0; - + Common::String fileName; if (argc == 3 || argc > 4) { + int8 stackNum = 0; for (byte i = 1; i <= ARRAYSIZE(mystStackNames); i++) if (!scumm_stricmp(argv[2], mystStackNames[i - 1])) { stackNum = i; @@ -261,16 +261,27 @@ bool MystConsole::Cmd_PlayMovie(int argc, const char **argv) { debugPrintf("\'%s\' is not a stack name!\n", argv[2]); return true; } + + fileName = _vm->wrapMovieFilename(argv[1], stackNum - 1); + } else { + fileName = argv[1]; } - if (argc == 2) - _vm->_video->playMovie(argv[1], 0, 0); - else if (argc == 3) - _vm->_video->playMovie(_vm->wrapMovieFilename(argv[1], stackNum - 1), 0, 0); - else if (argc == 4) - _vm->_video->playMovie(argv[1], atoi(argv[2]), atoi(argv[3])); - else - _vm->_video->playMovie(_vm->wrapMovieFilename(argv[1], stackNum - 1), atoi(argv[3]), atoi(argv[4])); + VideoHandle handle = _vm->_video->playMovie(fileName); + if (!handle) { + debugPrintf("Failed to open movie '%s'\n", fileName.c_str()); + return true; + } + + if (argc == 4) { + handle->setX(atoi(argv[2])); + handle->setY(atoi(argv[3])); + } else if (argc > 4) { + handle->setX(atoi(argv[3])); + handle->setY(atoi(argv[4])); + } else { + handle->center(); + } return false; } diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 6874f2420e..30b9d7c0e5 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -3802,8 +3802,11 @@ bool LBMovieItem::togglePlaying(bool playing, bool restart) { if (playing) { if ((_loaded && _enabled && _globalEnabled) || _phase == kLBPhaseNone) { debug("toggled video for phase %d", _phase); - _vm->_video->playMovie(_resourceId, _rect.left, _rect.top); + VideoHandle handle = _vm->_video->playMovie(_resourceId); + if (!handle) + error("Failed to open tMOV %d", _resourceId); + handle->moveTo(_rect.left, _rect.top); return true; } } diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index fcfb55e3b3..7a9596d8e0 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -224,7 +224,13 @@ VideoHandle MystResourceType6::playMovie() { // If the video is not running, play it if (!handle || handle->endOfVideo()) { - handle = _vm->_video->playMovie(_videoFile, _left, _top, _loop); + handle = _vm->_video->playMovie(_videoFile); + if (!handle) + error("Failed to open '%s'", _videoFile.c_str()); + + handle->moveTo(_left, _top); + handle->setLooping(_loop != 0); + if (_direction == -1) { handle->seek(handle->getDuration()); handle->setRate(-1); diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp index 0bd8100c84..dfa15a9b6c 100644 --- a/engines/mohawk/myst_stacks/channelwood.cpp +++ b/engines/mohawk/myst_stacks/channelwood.cpp @@ -299,7 +299,11 @@ bool Channelwood::pipeChangeValve(bool open, uint16 mask) { void Channelwood::o_bridgeToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Bridge rise / skink video", op); - VideoHandle bridge = _vm->_video->playMovie(_vm->wrapMovieFilename("bridge", kChannelwoodStack), 292, 203); + VideoHandle bridge = _vm->_video->playMovie(_vm->wrapMovieFilename("bridge", kChannelwoodStack)); + if (!bridge) + error("Failed to open 'bridge' movie"); + + bridge->moveTo(292, 203); // Toggle bridge state if (_state.waterPumpBridgeState) @@ -317,7 +321,11 @@ void Channelwood::o_pipeExtend(uint16 op, uint16 var, uint16 argc, uint16 *argv) debugC(kDebugScript, "\tsoundId: %d", soundId); _vm->_sound->replaceSoundMyst(soundId); - VideoHandle pipe = _vm->_video->playMovie(_vm->wrapMovieFilename("pipebrid", kChannelwoodStack), 267, 170); + VideoHandle pipe = _vm->_video->playMovie(_vm->wrapMovieFilename("pipebrid", kChannelwoodStack)); + if (!pipe) + error("Failed to open 'pipebrid' movie"); + + pipe->moveTo(267, 170); // Toggle pipe state if (_state.pipeState) @@ -605,23 +613,29 @@ void Channelwood::o_hologramMonitor(uint16 op, uint16 var, uint16 argc, uint16 * _vm->_video->stopVideos(); + VideoHandle handle; + switch (button) { case 0: - _vm->_video->playMovie(_vm->wrapMovieFilename("monalgh", kChannelwoodStack), 227, 70); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monalgh", kChannelwoodStack)); break; case 1: - _vm->_video->playMovie(_vm->wrapMovieFilename("monamth", kChannelwoodStack), 227, 70); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monamth", kChannelwoodStack)); break; case 2: - _vm->_video->playMovie(_vm->wrapMovieFilename("monasirs", kChannelwoodStack), 227, 70); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monasirs", kChannelwoodStack)); break; case 3: - _vm->_video->playMovie(_vm->wrapMovieFilename("monsmsg", kChannelwoodStack), 227, 70); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monsmsg", kChannelwoodStack)); break; default: warning("Opcode %d Control Variable Out of Range", op); break; } + + // Move the video to the right location + if (handle) + handle->moveTo(227, 70); } } diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp index 44d5ecef96..6ba0b63423 100644 --- a/engines/mohawk/myst_stacks/dni.cpp +++ b/engines/mohawk/myst_stacks/dni.cpp @@ -121,7 +121,11 @@ void Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Dni::atrusLeft_run() { if (_vm->_system->getMillis() > _atrusLeftTime + 63333) { _video = _vm->wrapMovieFilename("atrus2", kDniStack); - VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); + VideoHandle atrus = _vm->_video->playMovie(_video); + if (!atrus) + error("Failed to open '%s'", _video.c_str()); + + atrus->moveTo(215, 77); atrus->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 98000, 600)); _waitForLoop = true; @@ -139,7 +143,11 @@ void Dni::atrusLeft_run() { void Dni::loopVideo_run() { if (!_vm->_video->isVideoPlaying()) { - VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); + VideoHandle atrus = _vm->_video->playMovie(_video); + if (!atrus) + error("Failed to open '%s'", _video.c_str()); + + atrus->moveTo(215, 77); atrus->setBounds(Audio::Timestamp(0, _loopStart, 600), Audio::Timestamp(0, _loopEnd, 600)); atrus->setLooping(true); @@ -155,13 +163,22 @@ void Dni::atrus_run() { // Atrus asking for page if (!_vm->_video->isVideoPlaying()) { _video = _vm->wrapMovieFilename("atr1page", kDniStack); - VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77, true); + VideoHandle atrus = _vm->_video->playMovie(_video); + if (!atrus) + error("Failed to open '%s'", _video.c_str()); + + atrus->moveTo(215, 77); + atrus->setLooping(true); atrus->setBounds(Audio::Timestamp(0, 7388, 600), Audio::Timestamp(0, 14700, 600)); } } else if (_globals.ending != 3 && _globals.ending != 4) { if (_globals.heldPage == 13) { _video = _vm->wrapMovieFilename("atr1page", kDniStack); - VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); + VideoHandle atrus = _vm->_video->playMovie(_video); + if (!atrus) + error("Failed to open '%s'", _video.c_str()); + + atrus->moveTo(215, 77); atrus->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 14700, 600)); _waitForLoop = true; @@ -173,7 +190,11 @@ void Dni::atrus_run() { } else { _video = _vm->wrapMovieFilename("atr1nopg", kDniStack); - VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); + VideoHandle atrus = _vm->_video->playMovie(_video); + if (!atrus) + error("Failed to open '%s'", _video.c_str()); + + atrus->moveTo(215, 77); atrus->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 46175, 600)); _waitForLoop = true; @@ -184,7 +205,12 @@ void Dni::atrus_run() { _globals.ending = 3; } } else if (!_vm->_video->isVideoPlaying()) { - _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true); + VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack)); + if (!handle) + error("Failed to open atrwrite movie"); + + handle->moveTo(215, 77); + handle->setLooping(true); } } diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp index 2a33379198..dc66984398 100644 --- a/engines/mohawk/myst_stacks/intro.cpp +++ b/engines/mohawk/myst_stacks/intro.cpp @@ -98,10 +98,16 @@ void Intro::introMovies_run() { // Play Intro Movies // This is all quite messy... + VideoHandle handle; + switch (_introStep) { case 0: _introStep = 1; - _vm->_video->playMovie(_vm->wrapMovieFilename("broder", kIntroStack)); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("broder", kIntroStack)); + if (!handle) + error("Failed to open broder movie"); + + handle->center(); break; case 1: if (!_vm->_video->isVideoPlaying()) @@ -109,7 +115,11 @@ void Intro::introMovies_run() { break; case 2: _introStep = 3; - _vm->_video->playMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack)); + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack)); + if (!handle) + error("Failed to open cyanlogo movie"); + + handle->center(); break; case 3: if (!_vm->_video->isVideoPlaying()) @@ -118,8 +128,13 @@ void Intro::introMovies_run() { case 4: _introStep = 5; - if (!(_vm->getFeatures() & GF_DEMO)) // The demo doesn't have the intro video - _vm->_video->playMovie(_vm->wrapMovieFilename("intro", kIntroStack)); + if (!(_vm->getFeatures() & GF_DEMO)) { // The demo doesn't have the intro video + handle = _vm->_video->playMovie(_vm->wrapMovieFilename("intro", kIntroStack)); + if (!handle) + error("Failed to open intro movie"); + + handle->center(); + } break; case 5: if (!_vm->_video->isVideoPlaying()) diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index 5a180bd5b0..ffcaa226c6 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -316,7 +316,11 @@ void Mechanical::o_snakeBoxTrigger(uint16 op, uint16 var, uint16 argc, uint16 *a void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Play Stairs Movement Movie", op); - VideoHandle staircase = _vm->_video->playMovie(_vm->wrapMovieFilename("hhstairs", kMechanicalStack), 174, 222); + VideoHandle staircase = _vm->_video->playMovie(_vm->wrapMovieFilename("hhstairs", kMechanicalStack)); + if (!staircase) + error("Failed to open hhstairs movie"); + + staircase->moveTo(174, 222); if (_state.staircaseState) { staircase->setBounds(Audio::Timestamp(0, 840, 600), Audio::Timestamp(0, 1680, 600)); @@ -571,7 +575,11 @@ void Mechanical::o_elevatorWindowMovie(uint16 op, uint16 var, uint16 argc, uint1 debugC(kDebugScript, "Opcode %d Movie Time Index %d to %d", op, startTime, endTime); - VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("ewindow", kMechanicalStack), 253, 0); + VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("ewindow", kMechanicalStack)); + if (!window) + error("Failed to open ewindow movie"); + + window->moveTo(253, 0); window->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, endTime, 600)); _vm->_video->waitUntilMovieEnds(window); } @@ -644,7 +652,11 @@ void Mechanical::o_elevatorTopMovie(uint16 op, uint16 var, uint16 argc, uint16 * debugC(kDebugScript, "Opcode %d Movie Time Index %d to %d", op, startTime, endTime); - VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("hcelev", kMechanicalStack), 206, 38); + VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("hcelev", kMechanicalStack)); + if (!window) + error("Failed to open hcelev movie"); + + window->moveTo(206, 38); window->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, endTime, 600)); _vm->_video->waitUntilMovieEnds(window); } diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index d674f37703..98f0aa5349 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -1133,11 +1133,14 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv _vm->_system->delayMillis(500); // Gears rise up - VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33); + VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack)); + if (!gears) + error("Failed to open gears movie"); + + gears->moveTo(305, 33); gears->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 650, 600)); _vm->_video->waitUntilMovieEnds(gears); - _state.clockTowerBridgeOpen = 1; _vm->redrawArea(12); } else if (_state.clockTowerBridgeOpen && !correctTime) { @@ -1145,7 +1148,11 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv _vm->_system->delayMillis(500); // Gears sink down - VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33); + VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack)); + if (!gears) + error("Failed to open gears movie"); + + gears->moveTo(305, 33); gears->setBounds(Audio::Timestamp(0, 700, 600), Audio::Timestamp(0, 1300, 600)); _vm->_video->waitUntilMovieEnds(gears); @@ -1189,14 +1196,22 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) if (_state.imagerActive) { // Mountains disappearing Common::String file = _vm->wrapMovieFilename("vltmntn", kMystStack); - VideoHandle mountain = _vm->_video->playMovie(file, 159, 96, false); + VideoHandle mountain = _vm->_video->playMovie(file); + if (!mountain) + error("Failed to open '%s'", file.c_str()); + + mountain->moveTo(159, 96); mountain->setBounds(Audio::Timestamp(0, 11180, 600), Audio::Timestamp(0, 16800, 600)); _state.imagerActive = 0; } else { // Mountains appearing Common::String file = _vm->wrapMovieFilename("vltmntn", kMystStack); - VideoHandle mountain = _vm->_video->playMovie(file, 159, 96, false); + VideoHandle mountain = _vm->_video->playMovie(file); + if (!mountain) + error("Failed to open '%s'", file.c_str()); + + mountain->moveTo(159, 96); mountain->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 11180, 600)); _state.imagerActive = 1; @@ -1902,9 +1917,17 @@ Common::Rational Myst::boilerComputeGaugeRate(uint16 pressure, uint32 delay) { void Myst::boilerResetGauge(const Common::Rational &rate) { if (!_cabinGaugeMovie || _cabinGaugeMovie->endOfVideo()) { if (_vm->getCurCard() == 4098) { - _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabingau", kMystStack), 243, 96); + _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabingau", kMystStack)); + if (!_cabinGaugeMovie) + error("Failed to open cabingau movie"); + + _cabinGaugeMovie->moveTo(243, 96); } else { - _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabcgfar", kMystStack), 254, 136); + _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabcgfar", kMystStack)); + if (!_cabinGaugeMovie) + error("Failed to open cabingau movie"); + + _cabinGaugeMovie->moveTo(254, 136); } } @@ -2244,12 +2267,21 @@ void Myst::rocketCheckSolution() { // Book appearing Common::String movieFile = _vm->wrapMovieFilename("selenbok", kMystStack); - _rocketLinkBook = _vm->_video->playMovie(movieFile, 224, 41); + _rocketLinkBook = _vm->_video->playMovie(movieFile); + if (!_rocketLinkBook) + error("Failed to open '%s'", movieFile.c_str()); + + _rocketLinkBook->moveTo(224, 41); _rocketLinkBook->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 660, 600)); _vm->_video->waitUntilMovieEnds(_rocketLinkBook); // Book looping closed - _rocketLinkBook = _vm->_video->playMovie(movieFile, 224, 41, true); + _rocketLinkBook = _vm->_video->playMovie(movieFile); + if (!_rocketLinkBook) + error("Failed to open '%s'", movieFile.c_str()); + + _rocketLinkBook->moveTo(224, 41); + _rocketLinkBook->setLooping(true); _rocketLinkBook->setBounds(Audio::Timestamp(0, 660, 600), Audio::Timestamp(0, 3500, 600)); _tempVar = 1; @@ -2887,7 +2919,11 @@ void Myst::clockGearForwardOneStep(uint16 gear) { // Set video bounds uint16 gearPosition = _clockGearsPositions[gear] - 1; - _clockGearsVideos[gear] = _vm->_video->playMovie(_vm->wrapMovieFilename(videos[gear], kMystStack), x[gear], y[gear]); + _clockGearsVideos[gear] = _vm->_video->playMovie(_vm->wrapMovieFilename(videos[gear], kMystStack)); + if (!_clockGearsVideos[gear]) + error("Failed to open %s movie", videos[gear]); + + _clockGearsVideos[gear]->moveTo(x[gear], y[gear]); _clockGearsVideos[gear]->setBounds( Audio::Timestamp(0, startTime[gearPosition], 600), Audio::Timestamp(0, endTime[gearPosition], 600)); @@ -2900,7 +2936,11 @@ void Myst::clockWeightDownOneStep() { // Set video bounds if (updateVideo) { - _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack) , 124, 0); + _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack)); + if (!_clockWeightVideo) + error("Failed to open cl1wlfch movie"); + + _clockWeightVideo->moveTo(124, 0); _clockWeightVideo->setBounds( Audio::Timestamp(0, _clockWeightPosition, 600), Audio::Timestamp(0, _clockWeightPosition + 246, 600)); @@ -2954,7 +2994,11 @@ void Myst::clockGearsCheckSolution() { // Make weight go down _vm->_sound->replaceSoundMyst(9113); - _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack) , 124, 0); + _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack)); + if (!_clockWeightVideo) + error("Failed to open cl1wlfch movie"); + + _clockWeightVideo->moveTo(124, 0); _clockWeightVideo->setBounds( Audio::Timestamp(0, _clockWeightPosition, 600), Audio::Timestamp(0, 2214, 600)); @@ -2966,7 +3010,7 @@ void Myst::clockGearsCheckSolution() { _vm->_sound->replaceSoundMyst(7113); // Gear opening video - _vm->_video->playMovieBlocking(_vm->wrapMovieFilename("cl1wggat", kMystStack) , 195, 225); + _vm->_video->playMovieBlocking(_vm->wrapMovieFilename("cl1wggat", kMystStack), 195, 225); _state.gearsOpen = 1; _vm->redrawArea(40); @@ -3022,7 +3066,11 @@ void Myst::clockReset() { _vm->_sound->replaceSoundMyst(7113); // Gear closing movie - VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wggat", kMystStack) , 195, 225); + VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wggat", kMystStack)); + if (!handle) + error("Failed to open cl1wggat movie"); + + handle->moveTo(195, 225); handle->seek(handle->getDuration()); handle->setRate(-1); _vm->_video->waitUntilMovieEnds(handle); @@ -3036,7 +3084,11 @@ void Myst::clockReset() { } void Myst::clockResetWeight() { - _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack) , 124, 0); + _clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack)); + if (!_clockWeightVideo) + error("Failed to open cl1wlfch movie"); + + _clockWeightVideo->moveTo(124, 0); // Play the movie backwards, weight going up _clockWeightVideo->seek(Audio::Timestamp(0, _clockWeightPosition, 600)); @@ -3055,7 +3107,11 @@ void Myst::clockResetGear(uint16 gear) { // Set video bounds, gears going to 3 uint16 gearPosition = _clockGearsPositions[gear] - 1; if (gearPosition != 2) { - _clockGearsVideos[gear] = _vm->_video->playMovie(_vm->wrapMovieFilename(videos[gear], kMystStack), x[gear], y[gear]); + _clockGearsVideos[gear] = _vm->_video->playMovie(_vm->wrapMovieFilename(videos[gear], kMystStack)); + if (!_clockGearsVideos[gear]) + error("Failed to open gears movie"); + + _clockGearsVideos[gear]->moveTo(x[gear], y[gear]); _clockGearsVideos[gear]->setBounds( Audio::Timestamp(0, time[gearPosition], 600), Audio::Timestamp(0, time[2], 600)); @@ -3400,8 +3456,11 @@ void Myst::gullsFly1_run() { else x = _vm->_rnd->getRandomNumber(160) + 260; - _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack), x, 0); + VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack)); + if (!handle) + error("Failed to open gulls movie"); + handle->moveTo(x, 0); _gullsNextTime = time + _vm->_rnd->getRandomNumber(16667) + 13334; } } @@ -3546,8 +3605,11 @@ void Myst::gullsFly2_run() { if (time > _gullsNextTime) { uint16 video = _vm->_rnd->getRandomNumber(3); if (video != 3) { - _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack), 424, 0); - + VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack)); + if (!handle) + error("Failed to open gulls movie"); + + handle->moveTo(424, 0); _gullsNextTime = time + _vm->_rnd->getRandomNumber(16667) + 13334; } } @@ -3578,14 +3640,24 @@ void Myst::o_boilerMovies_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) void Myst::boilerFireInit() { if (_vm->getCurCard() == 4098) { - _cabinFireMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabfire", kMystStack), 240, 279, true); + _cabinFireMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabfire", kMystStack)); + if (!_cabinFireMovie) + error("Failed to open cabfire movie"); + + _cabinFireMovie->moveTo(240, 279); + _cabinFireMovie->setLooping(true); _cabinFireMovie->pause(true); _vm->redrawArea(305); boilerFireUpdate(true); } else { if (_state.cabinPilotLightLit == 1 && _state.cabinValvePosition >= 1) { - _cabinFireMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabfirfr", kMystStack), 254, 244, true); + _cabinFireMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabfirfr", kMystStack)); + if (!_cabinFireMovie) + error("Failed to open cabfirfr movie"); + + _cabinFireMovie->moveTo(254, 244); + _cabinFireMovie->setLooping(true); } } } @@ -3610,9 +3682,17 @@ void Myst::boilerFireUpdate(bool init) { void Myst::boilerGaugeInit() { if (_vm->getCurCard() == 4098) { - _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabingau", kMystStack), 243, 96); + _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabingau", kMystStack)); + if (!_cabinFireMovie) + error("Failed to open cabingau movie"); + + _cabinFireMovie->moveTo(243, 96); } else { - _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabcgfar", kMystStack), 254, 136); + _cabinGaugeMovie = _vm->_video->playMovie(_vm->wrapMovieFilename("cabcgfar", kMystStack)); + if (!_cabinFireMovie) + error("Failed to open cabcgfar movie"); + + _cabinFireMovie->moveTo(254, 136); } Audio::Timestamp frame; @@ -3678,16 +3758,25 @@ void Myst::greenBook_run() { _vm->_sound->stopSound(); _vm->_sound->pauseBackgroundMyst(); + VideoHandle book = _vm->_video->playMovie(file); + if (!book) + error("Failed to open '%s'", file.c_str()); + + book->moveTo(314, 76); + if (_globals.ending != 4) { _tempVar = 2; - _vm->_video->playMovie(file, 314, 76); } else { - VideoHandle book = _vm->_video->playMovie(file, 314, 76, true); book->setBounds(Audio::Timestamp(0, loopStart, 600), Audio::Timestamp(0, loopEnd, 600)); + book->setLooping(true); _tempVar = 0; } } else if (_tempVar == 2 && !_vm->_video->isVideoPlaying()) { - VideoHandle book = _vm->_video->playMovie(file, 314, 76); + VideoHandle book = _vm->_video->playMovie(file); + if (!book) + error("Failed to open '%s'", file.c_str()); + + book->moveTo(314, 76); book->setBounds(Audio::Timestamp(0, loopStart, 600), Audio::Timestamp(0, loopEnd, 600)); book->setLooping(true); _tempVar = 0; @@ -3712,8 +3801,11 @@ void Myst::gullsFly3_run() { if (video != 3) { uint16 x = _vm->_rnd->getRandomNumber(280) + 135; - _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack), x, 0); + VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack)); + if (!handle) + error("Failed to open gulls movie"); + handle->moveTo(x, 0); _gullsNextTime = time + _vm->_rnd->getRandomNumber(16667) + 13334; } } diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index fe9fdbab42..1113ceeac9 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -425,7 +425,11 @@ void Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16 argc, uint16 *arg uint16 startTime = argv[0]; uint16 endTime = argv[1]; - VideoHandle book = _vm->_video->playMovie(_vm->wrapMovieFilename("bkroom", kStoneshipStack), 159, 99); + VideoHandle book = _vm->_video->playMovie(_vm->wrapMovieFilename("bkroom", kStoneshipStack)); + if (!book) + error("Failed to open bkroom movie"); + + book->moveTo(159, 99); book->setBounds(Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, endTime, 600)); _vm->_video->waitUntilMovieEnds(book); } @@ -673,19 +677,31 @@ void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *a if (_state.chestValveState) { // Valve closing - VideoHandle valve = _vm->_video->playMovie(movie, 97, 267); + VideoHandle valve = _vm->_video->playMovie(movie); + if (!valve) + error("Failed to open '%s'", movie.c_str()); + + valve->moveTo(97, 267); valve->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 350, 600)); _vm->_video->waitUntilMovieEnds(valve); } else if (_state.chestWaterState) { // Valve opening, spilling water - VideoHandle valve = _vm->_video->playMovie(movie, 97, 267); + VideoHandle valve = _vm->_video->playMovie(movie); + if (!valve) + error("Failed to open '%s'", movie.c_str()); + + valve->moveTo(97, 267); valve->setBounds(Audio::Timestamp(0, 350, 600), Audio::Timestamp(0, 650, 600)); _vm->_video->waitUntilMovieEnds(valve); _vm->_sound->playSound(3132); for (uint i = 0; i < 25; i++) { - valve = _vm->_video->playMovie(movie, 97, 267); + valve = _vm->_video->playMovie(movie); + if (!valve) + error("Failed to open '%s'", movie.c_str()); + + valve->moveTo(97, 267); valve->setBounds(Audio::Timestamp(0, 650, 600), Audio::Timestamp(0, 750, 600)); _vm->_video->waitUntilMovieEnds(valve); } @@ -693,7 +709,11 @@ void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *a _vm->_sound->resumeBackgroundMyst(); } else { // Valve opening - VideoHandle valve = _vm->_video->playMovie(movie, 97, 267); + VideoHandle valve = _vm->_video->playMovie(movie); + if (!valve) + error("Failed to open '%s'", movie.c_str()); + + valve->moveTo(97, 267); valve->seek(Audio::Timestamp(0, 350, 600)); valve->setRate(-1); _vm->_video->waitUntilMovieEnds(valve); @@ -716,13 +736,21 @@ void Stoneship::o_trapLockOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) Common::String movie = _vm->wrapMovieFilename("openloc", kStoneshipStack); - VideoHandle lock = _vm->_video->playMovie(movie, 187, 71); + VideoHandle lock = _vm->_video->playMovie(movie); + if (!lock) + error("Failed to open '%s'", movie.c_str()); + + lock->moveTo(187, 71); lock->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 750, 600)); _vm->_video->waitUntilMovieEnds(lock); _vm->_sound->playSound(2143); - lock = _vm->_video->playMovie(movie, 187, 71); + lock = _vm->_video->playMovie(movie); + if (!lock) + error("Failed to open '%s'", movie.c_str()); + + lock->moveTo(187, 71); lock->setBounds(Audio::Timestamp(0, 750, 600), Audio::Timestamp(0, 10000, 600)); _vm->_video->waitUntilMovieEnds(lock); diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index 577f8a1a27..ff4a69cd28 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -85,11 +85,17 @@ Common::Rational VideoEntry::getRate() const { return _video->getRate(); } -void VideoEntry::setBounds(const Audio::Timestamp &start, const Audio::Timestamp &end) { +void VideoEntry::center() { assert(_video); - _start = start; - _video->setEndTime(end); - _video->seek(start); + _x = (g_system->getWidth() - _video->getWidth()) / 2; + _y = (g_system->getHeight() - _video->getHeight()) / 2; +} + +void VideoEntry::setBounds(const Audio::Timestamp &startTime, const Audio::Timestamp &endTime) { + assert(_video); + _start = startTime; + _video->setEndTime(endTime); + _video->seek(startTime); } void VideoEntry::seek(const Audio::Timestamp &time) { @@ -107,6 +113,31 @@ void VideoEntry::pause(bool isPaused) { _video->pauseVideo(isPaused); } +void VideoEntry::start() { + assert(_video); + _video->start(); +} + +void VideoEntry::stop() { + assert(_video); + _video->stop(); +} + +bool VideoEntry::isPlaying() const { + assert(_video); + return _video->isPlaying(); +} + +int VideoEntry::getVolume() const { + assert(_video); + return _video->getVolume(); +} + +void VideoEntry::setVolume(int volume) { + assert(_video); + _video->setVolume(CLIP(volume, 0, 255)); +} + VideoHandle::VideoHandle(VideoEntryPtr ptr) : _ptr(ptr) { } @@ -144,8 +175,7 @@ void VideoManager::playMovieBlocking(const Common::String &fileName, uint16 x, u if (!ptr) return; - ptr->setX(x); - ptr->setY(y); + ptr->moveTo(x, y); // Clear screen if requested if (clearScreen) { @@ -153,6 +183,7 @@ void VideoManager::playMovieBlocking(const Common::String &fileName, uint16 x, u _vm->_system->updateScreen(); } + ptr->start(); waitUntilMovieEnds(ptr); } @@ -167,9 +198,8 @@ void VideoManager::playMovieBlockingCentered(const Common::String &fileName, boo _vm->_system->updateScreen(); } - ptr->setX((_vm->_system->getWidth() - ptr->_video->getWidth()) / 2); - ptr->setY((_vm->_system->getHeight() - ptr->_video->getHeight()) / 2); - + ptr->center(); + ptr->start(); waitUntilMovieEnds(ptr); } @@ -242,51 +272,21 @@ void VideoManager::delayUntilMovieEnds(VideoHandle videoHandle) { removeEntry(videoHandle._ptr); } -VideoHandle VideoManager::playMovie(const Common::String &fileName, int16 x, int16 y, bool loop) { +VideoHandle VideoManager::playMovie(const Common::String &fileName) { VideoEntryPtr ptr = open(fileName); if (!ptr) return VideoHandle(); - ptr->setLooping(loop); - - // Center x if requested - // FIXME: Move to a playMovieCentered() - if (x < 0) - ptr->setX((_vm->_system->getWidth() - ptr->_video->getWidth()) / 2); - else - ptr->setX(x); - - // Center y if requested - // FIXME: Move to a playMovieCentered() - if (y < 0) - ptr->setY((_vm->_system->getHeight() - ptr->_video->getHeight()) / 2); - else - ptr->setY(y); - + ptr->start(); return ptr; } -VideoHandle VideoManager::playMovie(uint16 id, int16 x, int16 y, bool loop) { +VideoHandle VideoManager::playMovie(uint16 id) { VideoEntryPtr ptr = open(id); if (!ptr) return VideoHandle(); - ptr->setLooping(loop); - - // Center x if requested - // FIXME: Move to a playMovieCentered() - if (x < 0) - ptr->setX((_vm->_system->getWidth() - ptr->_video->getWidth()) / 2); - else - ptr->setX(x); - - // Center y if requested - // FIXME: Move to a playMovieCentered() - if (y < 0) - ptr->setY((_vm->_system->getHeight() - ptr->_video->getHeight()) / 2); - else - ptr->setY(y); - + ptr->start(); return ptr; } @@ -422,11 +422,12 @@ VideoHandle VideoManager::playMovieRiven(uint16 id) { if (_mlstRecords[i].code == id) { debug(1, "Play tMOV %d (non-blocking) at (%d, %d) %s, Volume = %d", _mlstRecords[i].movieID, _mlstRecords[i].left, _mlstRecords[i].top, _mlstRecords[i].loop != 0 ? "looping" : "non-looping", _mlstRecords[i].volume); - VideoEntryPtr ptr = open(_mlstRecords[i].movieID, _mlstRecords[i].volume); + VideoEntryPtr ptr = open(_mlstRecords[i].movieID); if (ptr) { - ptr->setX(_mlstRecords[i].left); - ptr->setY(_mlstRecords[i].top); + ptr->moveTo(_mlstRecords[i].left, _mlstRecords[i].top); ptr->setLooping(_mlstRecords[i].loop != 0); + ptr->setVolume(_mlstRecords[i].volume); + ptr->start(); } return ptr; @@ -440,9 +441,10 @@ void VideoManager::playMovieBlockingRiven(uint16 id) { for (uint16 i = 0; i < _mlstRecords.size(); i++) { if (_mlstRecords[i].code == id) { debug(1, "Play tMOV %d (blocking) at (%d, %d), Volume = %d", _mlstRecords[i].movieID, _mlstRecords[i].left, _mlstRecords[i].top, _mlstRecords[i].volume); - VideoEntryPtr ptr = open(_mlstRecords[i].movieID, _mlstRecords[i].volume); - ptr->setX(_mlstRecords[i].left); - ptr->setY(_mlstRecords[i].top); + VideoEntryPtr ptr = open(_mlstRecords[i].movieID); + ptr->moveTo(_mlstRecords[i].left, _mlstRecords[i].top); + ptr->setVolume(_mlstRecords[i].volume); + ptr->start(); waitUntilMovieEnds(ptr); return; } @@ -462,7 +464,7 @@ void VideoManager::disableAllMovies() { (*it)->setEnabled(false); } -VideoEntryPtr VideoManager::open(uint16 id, int volume) { +VideoEntryPtr VideoManager::open(uint16 id) { // If this video is already playing, return that handle VideoHandle oldHandle = findVideoHandle(id); if (oldHandle._ptr) @@ -473,9 +475,6 @@ VideoEntryPtr VideoManager::open(uint16 id, int volume) { video->setChunkBeginOffset(_vm->getResourceOffset(ID_TMOV, id)); video->loadStream(_vm->getResource(ID_TMOV, id)); - // Set the volume - video->setVolume(CLIP(volume, 0, 255)); - // Create the entry VideoEntryPtr entry(new VideoEntry(video, id)); @@ -485,13 +484,10 @@ VideoEntryPtr VideoManager::open(uint16 id, int volume) { // Add it to the video list _videos.push_back(entry); - // Start the video - entry->_video->start(); - return entry; } -VideoEntryPtr VideoManager::open(const Common::String &fileName, int volume) { +VideoEntryPtr VideoManager::open(const Common::String &fileName) { // If this video is already playing, return that entry VideoHandle oldHandle = findVideoHandle(fileName); if (oldHandle._ptr) @@ -509,9 +505,6 @@ VideoEntryPtr VideoManager::open(const Common::String &fileName, int volume) { return VideoEntryPtr(); } - // Set the volume - video->setVolume(CLIP(volume, 0, 255)); - // Create the entry VideoEntryPtr entry(new VideoEntry(video, fileName)); @@ -521,9 +514,6 @@ VideoEntryPtr VideoManager::open(const Common::String &fileName, int volume) { // Add it to the video list _videos.push_back(entry); - // Start the video - entry->_video->start(); - return entry; } diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h index 70eecb8175..106a32f8e2 100644 --- a/engines/mohawk/video.h +++ b/engines/mohawk/video.h @@ -159,9 +159,19 @@ public: void setY(uint16 y) { _y = y; } /** + * Move the video to the specified coordinates + */ + void moveTo(uint16 x, uint16 y) { setX(x); setY(y); } + + /** + * Center the video on the screen + */ + void center(); + + /** * Set the start time when using video bounds */ - void setStart(const Audio::Timestamp &start) { _start = start; } + void setStart(const Audio::Timestamp &time) { _start = time; } /** * Set the video to loop (true) or not (false) @@ -178,7 +188,7 @@ public: * * This automatically seeks to the start time */ - void setBounds(const Audio::Timestamp &start, const Audio::Timestamp &end); + void setBounds(const Audio::Timestamp &startTime, const Audio::Timestamp &endTime); /** * Seek to the given time @@ -195,6 +205,31 @@ public: */ void pause(bool isPaused); + /** + * Start playing the video + */ + void start(); + + /** + * Stop playing the video + */ + void stop(); + + /** + * Is the video playing? + */ + bool isPlaying() const; + + /** + * Get the volume of the video + */ + int getVolume() const; + + /** + * Set the volume of the video + */ + void setVolume(int volume); + private: // Non-changing variables Video::VideoDecoder *_video; @@ -274,8 +309,8 @@ public: // Generic movie functions void playMovieBlocking(const Common::String &filename, uint16 x = 0, uint16 y = 0, bool clearScreen = false); void playMovieBlockingCentered(const Common::String &filename, bool clearScreen = true); - VideoHandle playMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false); - VideoHandle playMovie(uint16 id, int16 x = -1, int16 y = -1, bool loop = false); + VideoHandle playMovie(const Common::String &filename); + VideoHandle playMovie(uint16 id); bool updateMovies(); void pauseVideos(); void resumeVideos(); @@ -309,8 +344,8 @@ private: VideoList _videos; // Utility functions for managing entries - VideoEntryPtr open(uint16 id, int volume = 0xFF); - VideoEntryPtr open(const Common::String &fileName, int volume = 0xFF); + VideoEntryPtr open(uint16 id); + VideoEntryPtr open(const Common::String &fileName); VideoList::iterator findEntry(VideoEntryPtr ptr); void removeEntry(VideoEntryPtr ptr); |