GRIM: restore factory-functions in movie player

This commit is contained in:
Pawel Kolodziejski 2011-05-14 18:17:26 +02:00
parent 9bc415cce2
commit 43eee42916
5 changed files with 25 additions and 6 deletions

View File

@ -50,9 +50,7 @@
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/actor.h"
#include "engines/grim/movie/smush.h"
#include "engines/grim/movie/bink.h"
#include "engines/grim/movie/mpeg.h"
#include "engines/grim/movie/movie.h"
#include "engines/grim/savegame.h"
#include "engines/grim/registry.h"
#include "engines/grim/resource.h"
@ -460,12 +458,12 @@ Common::Error GrimEngine::run() {
g_resourceloader = new ResourceLoader();
g_localizer = new Localizer();
if (getGameType() == GType_GRIM)
g_movie = new SmushPlayer();
g_movie = CreateSmushPlayer();
else if (getGameType() == GType_MONKEY4) {
if (_gamePlatform == Common::kPlatformPS2)
g_movie = new MpegPlayer();
g_movie = CreateMpegPlayer();
else
g_movie = new BinkPlayer();
g_movie = CreateBinkPlayer();
}
g_imuse = new Imuse(20);

View File

@ -50,11 +50,16 @@
namespace Grim {
MoviePlayer *CreateBinkPlayer() {
return new BinkPlayer();
}
void BinkPlayer::timerCallback(void *) {
((BinkPlayer *)g_movie)->handleFrame();
}
BinkPlayer::BinkPlayer() : MoviePlayer() {
g_movie = this;
_speed = 50;
}

View File

@ -108,6 +108,12 @@ protected:
virtual void deinit() = 0;
};
// Factory-like functions:
MoviePlayer *CreateMpegPlayer();
MoviePlayer *CreateSmushPlayer();
MoviePlayer *CreateBinkPlayer();
extern MoviePlayer *g_movie;
} // end of namespace Grim

View File

@ -50,6 +50,10 @@
namespace Grim {
MoviePlayer *CreateMpegPlayer() {
return new MpegPlayer();
}
class MpegHandler : public Video::BaseAnimationState {
public:
MpegHandler(MpegPlayer *vid, OSystem *sys, int width, int height) : BaseAnimationState(sys, width, height) {
@ -68,6 +72,7 @@ void MpegPlayer::timerCallback(void *) {
}
MpegPlayer::MpegPlayer() : MoviePlayer() {
g_movie = this;
_speed = 50;
_videoBase = new MpegHandler(this, g_system, MWIDTH, MHEIGHT);
}

View File

@ -55,6 +55,10 @@ namespace Grim {
static uint16 smushDestTable[5786];
MoviePlayer *CreateSmushPlayer() {
return new SmushPlayer();
}
void SmushPlayer::timerCallback(void *) {
if (g_grim->getGameFlags() & ADGF_DEMO)
((SmushPlayer *)g_movie)->handleFrameDemo();
@ -63,6 +67,7 @@ void SmushPlayer::timerCallback(void *) {
}
SmushPlayer::SmushPlayer() {
g_movie = this;
_IACTpos = 0;
_nbframes = 0;
}