aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/console.cpp14
-rw-r--r--engines/mohawk/livingbooks.cpp10
-rw-r--r--engines/mohawk/myst_areas.cpp14
-rw-r--r--engines/mohawk/myst_areas.h4
-rw-r--r--engines/mohawk/myst_stacks/channelwood.cpp30
-rw-r--r--engines/mohawk/myst_stacks/dni.cpp20
-rw-r--r--engines/mohawk/myst_stacks/intro.cpp20
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp18
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp34
-rw-r--r--engines/mohawk/myst_stacks/myst.h10
-rw-r--r--engines/mohawk/myst_stacks/stoneship.cpp16
-rw-r--r--engines/mohawk/video.cpp74
-rw-r--r--engines/mohawk/video.h71
13 files changed, 138 insertions, 197 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 91be370672..cfabbd304d 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -272,20 +272,20 @@ bool MystConsole::Cmd_PlayMovie(int argc, const char **argv) {
fileName = argv[1];
}
- VideoHandle handle = _vm->_video->playMovie(fileName);
- if (!handle) {
+ VideoEntryPtr video = _vm->_video->playMovie(fileName);
+ if (!video) {
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]));
+ video->setX(atoi(argv[2]));
+ video->setY(atoi(argv[3]));
} else if (argc > 4) {
- handle->setX(atoi(argv[3]));
- handle->setY(atoi(argv[4]));
+ video->setX(atoi(argv[3]));
+ video->setY(atoi(argv[4]));
} else {
- handle->center();
+ video->center();
}
return false;
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 340dfd16f7..95b4722d81 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -3828,8 +3828,8 @@ LBMovieItem::~LBMovieItem() {
void LBMovieItem::update() {
if (_playing) {
- VideoHandle videoHandle = _vm->_video->findVideoHandle(_resourceId);
- if (!videoHandle || videoHandle->endOfVideo())
+ VideoEntryPtr video = _vm->_video->findVideo(_resourceId);
+ if (!video || video->endOfVideo())
done(true);
}
@@ -3840,11 +3840,11 @@ bool LBMovieItem::togglePlaying(bool playing, bool restart) {
if (playing) {
if ((_loaded && _enabled && _globalEnabled) || _phase == kLBPhaseNone) {
debug("toggled video for phase %d", _phase);
- VideoHandle handle = _vm->_video->playMovie(_resourceId);
- if (!handle)
+ VideoEntryPtr video = _vm->_video->playMovie(_resourceId);
+ if (!video)
error("Failed to open tMOV %d", _resourceId);
- handle->moveTo(_rect.left, _rect.top);
+ video->moveTo(_rect.left, _rect.top);
return true;
}
}
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 8514cd5406..5bad3e5a04 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -211,9 +211,9 @@ MystAreaVideo::MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *
debugC(kDebugResource, "\tplayRate: %d", _playRate);
}
-VideoHandle MystAreaVideo::playMovie() {
+VideoEntryPtr MystAreaVideo::playMovie() {
// Check if the video is already running
- VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+ VideoEntryPtr handle = _vm->_video->findVideo(_videoFile);
// If the video is not running, play it
if (!handle) {
@@ -245,15 +245,15 @@ VideoHandle MystAreaVideo::playMovie() {
if (_playBlocking) {
_vm->_video->waitUntilMovieEnds(handle);
- return VideoHandle();
+ return VideoEntryPtr();
}
return handle;
}
-VideoHandle MystAreaVideo::getMovieHandle() {
+VideoEntryPtr MystAreaVideo::getVideo() {
// If the video is already in the manager, just return the handle
- VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+ VideoEntryPtr handle = _vm->_video->findVideo(_videoFile);
if (!handle) {
// If the video has not been loaded yet, do it but don't start playing it
handle = _vm->_video->playMovie(_videoFile);
@@ -271,12 +271,12 @@ void MystAreaVideo::handleCardChange() {
}
bool MystAreaVideo::isPlaying() {
- VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+ VideoEntryPtr handle = _vm->_video->findVideo(_videoFile);
return handle && !handle->endOfVideo();
}
void MystAreaVideo::pauseMovie(bool pause) {
- VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+ VideoEntryPtr handle = _vm->_video->findVideo(_videoFile);
if (handle && !handle->endOfVideo())
handle->pause(pause);
}
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index b19a2df9e2..3108a197fb 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -107,8 +107,8 @@ class MystAreaVideo : public MystAreaAction {
public:
MystAreaVideo(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystArea *parent);
- VideoHandle playMovie();
- VideoHandle getMovieHandle();
+ VideoEntryPtr playMovie();
+ VideoEntryPtr getVideo();
void handleCardChange() override;
bool isPlaying();
diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp
index f006a8e3ea..aee3036327 100644
--- a/engines/mohawk/myst_stacks/channelwood.cpp
+++ b/engines/mohawk/myst_stacks/channelwood.cpp
@@ -302,7 +302,7 @@ 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));
+ VideoEntryPtr bridge = _vm->_video->playMovie(_vm->wrapMovieFilename("bridge", kChannelwoodStack));
if (!bridge)
error("Failed to open 'bridge' movie");
@@ -324,7 +324,7 @@ 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));
+ VideoEntryPtr pipe = _vm->_video->playMovie(_vm->wrapMovieFilename("pipebrid", kChannelwoodStack));
if (!pipe)
error("Failed to open 'pipebrid' movie");
@@ -617,32 +617,32 @@ void Channelwood::o_hologramMonitor(uint16 op, uint16 var, uint16 argc, uint16 *
_vm->_video->stopVideos();
- VideoHandle handle;
+ VideoEntryPtr video;
switch (button) {
case 0:
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monalgh", kChannelwoodStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("monalgh", kChannelwoodStack));
+ if (!video)
error("Failed to open monalgh movie");
- handle->moveTo(227, 70);
+ video->moveTo(227, 70);
break;
case 1:
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monamth", kChannelwoodStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("monamth", kChannelwoodStack));
+ if (!video)
error("Failed to open monamth movie");
- handle->moveTo(227, 70);
+ video->moveTo(227, 70);
break;
case 2:
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monasirs", kChannelwoodStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("monasirs", kChannelwoodStack));
+ if (!video)
error("Failed to open monasirs movie");
- handle->moveTo(227, 70);
+ video->moveTo(227, 70);
break;
case 3:
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("monsmsg", kChannelwoodStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("monsmsg", kChannelwoodStack));
+ if (!video)
error("Failed to open monsmsg movie");
- handle->moveTo(226, 68);
+ video->moveTo(226, 68);
break;
default:
warning("Opcode %d Control Variable Out of Range", op);
diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp
index 6ba0b63423..8611662b69 100644
--- a/engines/mohawk/myst_stacks/dni.cpp
+++ b/engines/mohawk/myst_stacks/dni.cpp
@@ -100,7 +100,7 @@ void Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used in Card 5014 (Atrus)
// Find Atrus movie
- VideoHandle atrus = _vm->_video->findVideoHandle(_video);
+ VideoEntryPtr atrus = _vm->_video->findVideo(_video);
// Good ending and Atrus asked to give page
if (_globals.ending == 1 && atrus && atrus->getTime() > (uint)Audio::Timestamp(0, 6801, 600).msecs()) {
@@ -121,7 +121,7 @@ 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);
+ VideoEntryPtr atrus = _vm->_video->playMovie(_video);
if (!atrus)
error("Failed to open '%s'", _video.c_str());
@@ -143,7 +143,7 @@ void Dni::atrusLeft_run() {
void Dni::loopVideo_run() {
if (!_vm->_video->isVideoPlaying()) {
- VideoHandle atrus = _vm->_video->playMovie(_video);
+ VideoEntryPtr atrus = _vm->_video->playMovie(_video);
if (!atrus)
error("Failed to open '%s'", _video.c_str());
@@ -163,7 +163,7 @@ void Dni::atrus_run() {
// Atrus asking for page
if (!_vm->_video->isVideoPlaying()) {
_video = _vm->wrapMovieFilename("atr1page", kDniStack);
- VideoHandle atrus = _vm->_video->playMovie(_video);
+ VideoEntryPtr atrus = _vm->_video->playMovie(_video);
if (!atrus)
error("Failed to open '%s'", _video.c_str());
@@ -174,7 +174,7 @@ void Dni::atrus_run() {
} else if (_globals.ending != 3 && _globals.ending != 4) {
if (_globals.heldPage == 13) {
_video = _vm->wrapMovieFilename("atr1page", kDniStack);
- VideoHandle atrus = _vm->_video->playMovie(_video);
+ VideoEntryPtr atrus = _vm->_video->playMovie(_video);
if (!atrus)
error("Failed to open '%s'", _video.c_str());
@@ -190,7 +190,7 @@ void Dni::atrus_run() {
} else {
_video = _vm->wrapMovieFilename("atr1nopg", kDniStack);
- VideoHandle atrus = _vm->_video->playMovie(_video);
+ VideoEntryPtr atrus = _vm->_video->playMovie(_video);
if (!atrus)
error("Failed to open '%s'", _video.c_str());
@@ -205,12 +205,12 @@ void Dni::atrus_run() {
_globals.ending = 3;
}
} else if (!_vm->_video->isVideoPlaying()) {
- VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack));
- if (!handle)
+ VideoEntryPtr atrus = _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack));
+ if (!atrus)
error("Failed to open atrwrite movie");
- handle->moveTo(215, 77);
- handle->setLooping(true);
+ atrus->moveTo(215, 77);
+ atrus->setLooping(true);
}
}
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index e465180f16..2797ba3ef5 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -96,16 +96,16 @@ void Intro::introMovies_run() {
// Play Intro Movies
// This is all quite messy...
- VideoHandle handle;
+ VideoEntryPtr video;
switch (_introStep) {
case 0:
_introStep = 1;
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("broder", kIntroStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("broder", kIntroStack));
+ if (!video)
error("Failed to open broder movie");
- handle->center();
+ video->center();
break;
case 1:
if (!_vm->_video->isVideoPlaying())
@@ -113,11 +113,11 @@ void Intro::introMovies_run() {
break;
case 2:
_introStep = 3;
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack));
+ if (!video)
error("Failed to open cyanlogo movie");
- handle->center();
+ video->center();
break;
case 3:
if (!_vm->_video->isVideoPlaying())
@@ -127,11 +127,11 @@ void Intro::introMovies_run() {
_introStep = 5;
if (!(_vm->getFeatures() & GF_DEMO)) { // The demo doesn't have the intro video
- handle = _vm->_video->playMovie(_vm->wrapMovieFilename("intro", kIntroStack));
- if (!handle)
+ video = _vm->_video->playMovie(_vm->wrapMovieFilename("intro", kIntroStack));
+ if (!video)
error("Failed to open intro movie");
- handle->center();
+ video->center();
}
break;
case 5:
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 6daa5bd220..7c5989f6f2 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -319,7 +319,7 @@ 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));
+ VideoEntryPtr staircase = _vm->_video->playMovie(_vm->wrapMovieFilename("hhstairs", kMechanicalStack));
if (!staircase)
error("Failed to open hhstairs movie");
@@ -578,7 +578,7 @@ 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));
+ VideoEntryPtr window = _vm->_video->playMovie(_vm->wrapMovieFilename("ewindow", kMechanicalStack));
if (!window)
error("Failed to open ewindow movie");
@@ -655,7 +655,7 @@ 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));
+ VideoEntryPtr window = _vm->_video->playMovie(_vm->wrapMovieFilename("hcelev", kMechanicalStack));
if (!window)
error("Failed to open hcelev movie");
@@ -667,7 +667,7 @@ void Mechanical::o_elevatorTopMovie(uint16 op, uint16 var, uint16 argc, uint16 *
void Mechanical::o_fortressRotationSetPosition(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Set fortress position", op);
- VideoHandle gears = _fortressRotationGears->getMovieHandle();
+ VideoEntryPtr gears = _fortressRotationGears->getVideo();
uint32 moviePosition = Audio::Timestamp(gears->getTime(), 600).totalNumberOfFrames();
// Myst ME short movie workaround, explained in o_fortressRotation_init
@@ -801,7 +801,7 @@ void Mechanical::o_elevatorRotation_init(uint16 op, uint16 var, uint16 argc, uin
}
void Mechanical::fortressRotation_run() {
- VideoHandle gears = _fortressRotationGears->getMovieHandle();
+ VideoEntryPtr gears = _fortressRotationGears->getVideo();
double oldRate = gears->getRate().toDouble();
uint32 moviePosition = Audio::Timestamp(gears->getTime(), 600).totalNumberOfFrames();
@@ -877,7 +877,7 @@ void Mechanical::o_fortressRotation_init(uint16 op, uint16 var, uint16 argc, uin
_fortressRotationGears = getInvokingResource<MystAreaVideo>();
- VideoHandle gears = _fortressRotationGears->playMovie();
+ VideoEntryPtr gears = _fortressRotationGears->playMovie();
gears->setLooping(true);
gears->seek(Audio::Timestamp(0, 1800 * _fortressPosition, 600));
gears->setRate(0);
@@ -917,7 +917,7 @@ void Mechanical::fortressSimulation_run() {
_vm->_sound->replaceSoundMyst(_fortressSimulationStartSound2);
// Update movie while the sound is playing
- VideoHandle startup = _fortressSimulationStartup->playMovie();
+ VideoEntryPtr startup = _fortressSimulationStartup->playMovie();
while (_vm->_sound->isPlaying(_fortressSimulationStartSound2)) {
if (_vm->_video->updateMovies())
_vm->_system->updateScreen();
@@ -937,7 +937,7 @@ void Mechanical::fortressSimulation_run() {
_vm->_system->updateScreen();
_fortressSimulationStartup->pauseMovie(true);
- VideoHandle holo = _fortressSimulationHolo->playMovie();
+ VideoEntryPtr holo = _fortressSimulationHolo->playMovie();
holo->setLooping(true);
holo->setRate(0);
@@ -949,7 +949,7 @@ void Mechanical::fortressSimulation_run() {
_fortressSimulationInit = false;
} else {
- VideoHandle holo = _fortressSimulationHolo->getMovieHandle();
+ VideoEntryPtr holo = _fortressSimulationHolo->getVideo();
double oldRate = holo->getRate().toDouble();
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index edd4eccd6c..2840b7c797 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -1139,7 +1139,7 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv
_vm->wait(500);
// Gears rise up
- VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
+ VideoEntryPtr gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
if (!gears)
error("Failed to open gears movie");
@@ -1154,7 +1154,7 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv
_vm->wait(500);
// Gears sink down
- VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
+ VideoEntryPtr gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
if (!gears)
error("Failed to open gears movie");
@@ -1202,7 +1202,7 @@ 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);
+ VideoEntryPtr mountain = _vm->_video->playMovie(file);
if (!mountain)
error("Failed to open '%s'", file.c_str());
@@ -1213,7 +1213,7 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv)
} else {
// Mountains appearing
Common::String file = _vm->wrapMovieFilename("vltmntn", kMystStack);
- VideoHandle mountain = _vm->_video->playMovie(file);
+ VideoEntryPtr mountain = _vm->_video->playMovie(file);
if (!mountain)
error("Failed to open '%s'", file.c_str());
@@ -1230,14 +1230,14 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv)
_vm->_sound->replaceSoundMyst(argv[1]);
// Water disappearing
- VideoHandle water = _imagerMovie->playMovie();
+ VideoEntryPtr water = _imagerMovie->playMovie();
water->setBounds(Audio::Timestamp(0, 4204, 600), Audio::Timestamp(0, 6040, 600));
water->setLooping(false);
_state.imagerActive = 0;
} else {
// Water appearing
- VideoHandle water = _imagerMovie->playMovie();
+ VideoEntryPtr water = _imagerMovie->playMovie();
water->setBounds(Audio::Timestamp(0, 0, 600), Audio::Timestamp(0, 1814, 600));
_vm->_video->waitUntilMovieEnds(water);
@@ -2979,7 +2979,7 @@ void Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv)
// Let movies stop playing
for (uint i = 0; i < ARRAYSIZE(videos); i++) {
- VideoHandle handle = _vm->_video->findVideoHandle(_vm->wrapMovieFilename(videos[i], kMystStack));
+ VideoEntryPtr handle = _vm->_video->findVideo(_vm->wrapMovieFilename(videos[i], kMystStack));
if (handle)
_vm->_video->waitUntilMovieEnds(handle);
}
@@ -3063,7 +3063,7 @@ void Myst::clockReset() {
// Let movies stop playing
for (uint i = 0; i < ARRAYSIZE(videos); i++) {
- VideoHandle handle = _vm->_video->findVideoHandle(_vm->wrapMovieFilename(videos[i], kMystStack));
+ VideoEntryPtr handle = _vm->_video->findVideo(_vm->wrapMovieFilename(videos[i], kMystStack));
if (handle)
_vm->_video->waitUntilMovieEnds(handle);
}
@@ -3077,7 +3077,7 @@ void Myst::clockReset() {
_vm->_sound->replaceSoundMyst(7113);
// Gear closing movie
- VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wggat", kMystStack));
+ VideoEntryPtr handle = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wggat", kMystStack));
if (!handle)
error("Failed to open cl1wggat movie");
@@ -3355,7 +3355,7 @@ void Myst::imager_run() {
_imagerRunning = false;
if (_state.imagerActive && _state.imagerSelection == 67) {
- VideoHandle water = _imagerMovie->playMovie();
+ VideoEntryPtr water = _imagerMovie->playMovie();
water->setBounds(Audio::Timestamp(0, 1814, 600), Audio::Timestamp(0, 4204, 600));
water->setLooping(true);
}
@@ -3469,7 +3469,7 @@ void Myst::gullsFly1_run() {
else
x = _vm->_rnd->getRandomNumber(160) + 260;
- VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
+ VideoEntryPtr handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
if (!handle)
error("Failed to open gulls movie");
@@ -3614,7 +3614,7 @@ void Myst::gullsFly2_run() {
if (time > _gullsNextTime) {
uint16 video = _vm->_rnd->getRandomNumber(3);
if (video != 3) {
- VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
+ VideoEntryPtr handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
if (!handle)
error("Failed to open gulls movie");
@@ -3769,7 +3769,7 @@ void Myst::greenBook_run() {
_vm->_sound->stopSound();
_vm->_sound->pauseBackgroundMyst();
- VideoHandle book = _vm->_video->playMovie(file);
+ VideoEntryPtr book = _vm->_video->playMovie(file);
if (!book)
error("Failed to open '%s'", file.c_str());
@@ -3783,7 +3783,7 @@ void Myst::greenBook_run() {
_tempVar = 0;
}
} else if (_tempVar == 2 && !_vm->_video->isVideoPlaying()) {
- VideoHandle book = _vm->_video->playMovie(file);
+ VideoEntryPtr book = _vm->_video->playMovie(file);
if (!book)
error("Failed to open '%s'", file.c_str());
@@ -3812,7 +3812,7 @@ void Myst::gullsFly3_run() {
if (video != 3) {
uint16 x = _vm->_rnd->getRandomNumber(280) + 135;
- VideoHandle handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
+ VideoEntryPtr handle = _vm->_video->playMovie(_vm->wrapMovieFilename(gulls[video], kMystStack));
if (!handle)
error("Failed to open gulls movie");
@@ -3851,8 +3851,8 @@ void Myst::o_treeEntry_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
void Myst::o_boiler_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Exit boiler card", op);
- _cabinGaugeMovie = VideoHandle();
- _cabinFireMovie = VideoHandle();
+ _cabinGaugeMovie = VideoEntryPtr();
+ _cabinFireMovie = VideoEntryPtr();
_cabinGaugeMovieEnabled = false;
}
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index a44f914c37..870daa8c68 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -199,7 +199,7 @@ protected:
MystAreaSlider *_rocketSlider5; // 264
uint16 _rocketSliderSound; // 294
uint16 _rocketLeverPosition; // 296
- VideoHandle _rocketLinkBook; // 268
+ VideoEntryPtr _rocketLinkBook; // 268
bool _libraryCombinationBookPagesTurning;
int16 _libraryBookPage; // 86
@@ -235,8 +235,8 @@ protected:
uint16 _clockTurningWheel;
- VideoHandle _clockGearsVideos[3]; // 148 to 156
- VideoHandle _clockWeightVideo; // 160
+ VideoEntryPtr _clockGearsVideos[3]; // 148 to 156
+ VideoEntryPtr _clockWeightVideo; // 160
uint16 _clockGearsPositions[3]; // 164 to 168
uint16 _clockWeightPosition; // 172
bool _clockMiddleGearMovedAlone; // 176
@@ -261,10 +261,10 @@ protected:
uint16 _cabinMatchState; // 60
uint32 _matchGoOutTime; // 144
- VideoHandle _cabinFireMovie; // 240
+ VideoEntryPtr _cabinFireMovie; // 240
bool _cabinGaugeMovieEnabled;
- VideoHandle _cabinGaugeMovie; // 244
+ VideoEntryPtr _cabinGaugeMovie; // 244
bool _boilerPressureIncreasing;
bool _boilerPressureDecreasing;
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp
index 2308738957..cd63da44db 100644
--- a/engines/mohawk/myst_stacks/stoneship.cpp
+++ b/engines/mohawk/myst_stacks/stoneship.cpp
@@ -427,7 +427,7 @@ 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));
+ VideoEntryPtr book = _vm->_video->playMovie(_vm->wrapMovieFilename("bkroom", kStoneshipStack));
if (!book)
error("Failed to open bkroom movie");
@@ -598,7 +598,7 @@ void Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint16 argc, uint16 *a
// uint16 direction = argv[2];
_hologramDisplay->setBlocking(false);
- VideoHandle displayMovie = _hologramDisplay->playMovie();
+ VideoEntryPtr displayMovie = _hologramDisplay->playMovie();
if (_hologramTurnedOn) {
if (_hologramDisplayPos)
@@ -629,7 +629,7 @@ void Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint
// Draw handle movie frame
uint16 selectionPos = position * 1500 / 243;
- VideoHandle handleMovie = _hologramSelection->playMovie();
+ VideoEntryPtr handleMovie = _hologramSelection->playMovie();
_vm->_video->drawVideoFrame(handleMovie, Audio::Timestamp(0, selectionPos, 600));
_hologramDisplayPos = position * 1450 / 243 + 350;
@@ -637,7 +637,7 @@ void Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint
// Draw display movie frame
if (_hologramTurnedOn) {
_hologramDisplay->setBlocking(false);
- VideoHandle displayMovie = _hologramDisplay->playMovie();
+ VideoEntryPtr displayMovie = _hologramDisplay->playMovie();
_vm->_video->drawVideoFrame(displayMovie, Audio::Timestamp(0, _hologramDisplayPos, 600));
}
}
@@ -679,7 +679,7 @@ void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *a
if (_state.chestValveState) {
// Valve closing
- VideoHandle valve = _vm->_video->playMovie(movie);
+ VideoEntryPtr valve = _vm->_video->playMovie(movie);
if (!valve)
error("Failed to open '%s'", movie.c_str());
@@ -688,7 +688,7 @@ void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *a
_vm->_video->waitUntilMovieEnds(valve);
} else if (_state.chestWaterState) {
// Valve opening, spilling water
- VideoHandle valve = _vm->_video->playMovie(movie);
+ VideoEntryPtr valve = _vm->_video->playMovie(movie);
if (!valve)
error("Failed to open '%s'", movie.c_str());
@@ -711,7 +711,7 @@ void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *a
_vm->_sound->resumeBackgroundMyst();
} else {
// Valve opening
- VideoHandle valve = _vm->_video->playMovie(movie);
+ VideoEntryPtr valve = _vm->_video->playMovie(movie);
if (!valve)
error("Failed to open '%s'", movie.c_str());
@@ -738,7 +738,7 @@ 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);
+ VideoEntryPtr lock = _vm->_video->playMovie(movie);
if (!lock)
error("Failed to open '%s'", movie.c_str());
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 1a7c019973..64f6f23641 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -24,6 +24,8 @@
#include "mohawk/resource.h"
#include "mohawk/video.h"
+#include "mohawk/myst.h"
+
#include "common/algorithm.h"
#include "common/debug.h"
#include "common/events.h"
@@ -138,13 +140,7 @@ void VideoEntry::setVolume(int volume) {
_video->setVolume(CLIP(volume, 0, 255));
}
-VideoHandle::VideoHandle(VideoEntryPtr ptr) : _ptr(ptr) {
-}
-
-VideoHandle::VideoHandle(const VideoHandle &handle) : _ptr(handle._ptr) {
-}
-
-VideoManager::VideoManager(MohawkEngine* vm) : _vm(vm) {
+VideoManager::VideoManager(MohawkEngine *vm) : _vm(vm) {
// Set dithering enabled, if required
_enableDither = (_vm->getGameType() == GType_MYST || _vm->getGameType() == GType_MAKINGOF) && !(_vm->getFeatures() & GF_ME);
}
@@ -184,7 +180,7 @@ void VideoManager::playMovieBlocking(const Common::String &fileName, uint16 x, u
}
ptr->start();
- waitUntilMovieEnds(VideoHandle(ptr));
+ waitUntilMovieEnds(ptr);
}
void VideoManager::playMovieBlockingCentered(const Common::String &fileName, bool clearScreen) {
@@ -200,20 +196,20 @@ void VideoManager::playMovieBlockingCentered(const Common::String &fileName, boo
ptr->center();
ptr->start();
- waitUntilMovieEnds(VideoHandle(ptr));
+ waitUntilMovieEnds(ptr);
}
-void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
- if (!videoHandle)
+void VideoManager::waitUntilMovieEnds(const VideoEntryPtr &video) {
+ if (!video)
return;
// Sanity check
- if (videoHandle._ptr->isLooping())
+ if (video->isLooping())
error("Called waitUntilMovieEnds() on a looping video");
bool continuePlaying = true;
- while (!videoHandle->endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
+ while (!video->endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
if (updateMovies())
_vm->_system->updateScreen();
@@ -245,25 +241,25 @@ void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
}
// Ensure it's removed
- removeEntry(videoHandle._ptr);
+ removeEntry(video);
}
-VideoHandle VideoManager::playMovie(const Common::String &fileName) {
+VideoEntryPtr VideoManager::playMovie(const Common::String &fileName) {
VideoEntryPtr ptr = open(fileName);
if (!ptr)
- return VideoHandle();
+ return VideoEntryPtr();
ptr->start();
- return VideoHandle(ptr);
+ return ptr;
}
-VideoHandle VideoManager::playMovie(uint16 id) {
+VideoEntryPtr VideoManager::playMovie(uint16 id) {
VideoEntryPtr ptr = open(id);
if (!ptr)
- return VideoHandle();
+ return VideoEntryPtr();
ptr->start();
- return VideoHandle(ptr);
+ return ptr;
}
bool VideoManager::updateMovies() {
@@ -376,9 +372,9 @@ bool VideoManager::drawNextFrame(VideoEntryPtr videoEntry) {
VideoEntryPtr VideoManager::open(uint16 id) {
// If this video is already playing, return that handle
- VideoHandle oldHandle = findVideoHandle(id);
- if (oldHandle._ptr)
- return oldHandle._ptr;
+ VideoEntryPtr oldVideo = findVideo(id);
+ if (oldVideo)
+ return oldVideo;
// Otherwise, create a new entry
Video::QuickTimeDecoder *video = new Video::QuickTimeDecoder();
@@ -399,9 +395,9 @@ VideoEntryPtr VideoManager::open(uint16 id) {
VideoEntryPtr VideoManager::open(const Common::String &fileName) {
// If this video is already playing, return that entry
- VideoHandle oldHandle = findVideoHandle(fileName);
- if (oldHandle._ptr)
- return oldHandle._ptr;
+ VideoEntryPtr oldVideo = findVideo(fileName);
+ if (oldVideo)
+ return oldVideo;
// Otherwise, create a new entry
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(fileName);
@@ -427,26 +423,26 @@ VideoEntryPtr VideoManager::open(const Common::String &fileName) {
return entry;
}
-VideoHandle VideoManager::findVideoHandle(uint16 id) {
+VideoEntryPtr VideoManager::findVideo(uint16 id) {
if (id == 0)
- return VideoHandle();
+ return VideoEntryPtr();
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); it++)
if ((*it)->getID() == id)
- return VideoHandle(*it);
+ return *it;
- return VideoHandle();
+ return VideoEntryPtr();
}
-VideoHandle VideoManager::findVideoHandle(const Common::String &fileName) {
+VideoEntryPtr VideoManager::findVideo(const Common::String &fileName) {
if (fileName.empty())
- return VideoHandle();
+ return VideoEntryPtr();
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); it++)
if ((*it)->getFileName().equalsIgnoreCase(fileName))
- return VideoHandle(*it);
+ return *it;
- return VideoHandle();
+ return VideoEntryPtr();
}
bool VideoManager::isVideoPlaying() {
@@ -457,11 +453,11 @@ bool VideoManager::isVideoPlaying() {
return false;
}
-void VideoManager::drawVideoFrame(VideoHandle handle, const Audio::Timestamp &time) {
- assert(handle);
- handle->seek(time);
- drawNextFrame(handle._ptr);
- handle->stop();
+void VideoManager::drawVideoFrame(const VideoEntryPtr &video, const Audio::Timestamp &time) {
+ assert(video);
+ video->seek(time);
+ drawNextFrame(video);
+ video->stop();
}
VideoManager::VideoList::iterator VideoManager::findEntry(VideoEntryPtr ptr) {
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index 4298298b75..d8b3addc81 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -234,71 +234,16 @@ private:
typedef Common::SharedPtr<VideoEntry> VideoEntryPtr;
-/**
- * A handle for manipulating a video
- */
-class VideoHandle {
- // The private members should be able to be manipulated by VideoManager
- friend class VideoManager;
-
-public:
- /**
- * Default constructor
- */
- VideoHandle() {}
-
- /**
- * Copy constructor
- */
- VideoHandle(const VideoHandle &handle);
-
- /**
- * Is this handle pointing to a valid video entry?
- */
- bool isValid() const { return _ptr && _ptr->isOpen(); }
-
- /**
- * Convenience implicit cast to bool
- */
- operator bool() const { return isValid(); }
-
- /**
- * Simple equality operator
- */
- bool operator==(const VideoHandle &other) const { return _ptr.get() == other._ptr.get(); }
-
- /**
- * Simple inequality operator
- */
- bool operator!=(const VideoHandle &other) const { return !(*this == other); }
-
- /**
- * Convenience operator-> override to give direct access to the VideoEntry
- */
- VideoEntryPtr operator->() const { return _ptr; }
-
-private:
- /**
- * Constructor for internal VideoManager use
- */
- explicit VideoHandle(VideoEntryPtr ptr);
-
- /**
- * The video entry this is associated with
- */
- VideoEntryPtr _ptr;
-};
-
class VideoManager {
public:
VideoManager(MohawkEngine *vm);
- ~VideoManager();
+ virtual ~VideoManager();
// 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);
- VideoHandle playMovie(uint16 id);
+ VideoEntryPtr playMovie(const Common::String &filename);
+ VideoEntryPtr playMovie(uint16 id);
bool updateMovies();
void pauseVideos();
void resumeVideos();
@@ -306,12 +251,12 @@ public:
bool isVideoPlaying();
// Handle functions
- VideoHandle findVideoHandle(uint16 id);
- VideoHandle findVideoHandle(const Common::String &fileName);
- void waitUntilMovieEnds(VideoHandle handle);
- void drawVideoFrame(VideoHandle handle, const Audio::Timestamp &time);
+ VideoEntryPtr findVideo(uint16 id);
+ VideoEntryPtr findVideo(const Common::String &fileName);
+ void waitUntilMovieEnds(const VideoEntryPtr &video);
+ void drawVideoFrame(const VideoEntryPtr &video, const Audio::Timestamp &time);
-private:
+protected:
MohawkEngine *_vm;
// Keep tabs on any videos playing