added movieTime stuff, now it try handle subtitles for smush

This commit is contained in:
Pawel Kolodziejski 2004-03-03 21:43:34 +00:00
parent 1c3e5443cc
commit 397d822587
6 changed files with 24 additions and 2 deletions

View File

@ -38,6 +38,7 @@ Engine::Engine() :
}
void Engine::mainLoop() {
movieTime_ = 0;
frameTime_ = 0;
frameStart_ = SDL_GetTicks();
@ -106,6 +107,7 @@ void Engine::mainLoop() {
}
if (g_smush->isPlaying()) {
movieTime_ = g_smush->getMovieTime();
if (g_smush->isUpdateNeeded()) {
g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
g_smush->clearUpdateNeeded();
@ -149,6 +151,10 @@ void Engine::mainLoop() {
lua_beginblock();
set_frameTime(frameTime_);
lua_endblock();
lua_beginblock();
set_movieTime(movieTime_);
lua_endblock();
}
}

View File

@ -138,7 +138,7 @@ private:
Scene *currScene_;
unsigned frameStart_, frameTime_;
unsigned frameStart_, frameTime_, movieTime_;
bool controlsEnabled_[SDLK_EXTRA_LAST];

View File

@ -844,6 +844,13 @@ void set_frameTime(float frameTime) {
lua_settable();
}
void set_movieTime(float movieTime) {
lua_pushobject(lua_getglobal("system"));
lua_pushstring("movieTime");
lua_pushnumber(movieTime);
lua_settable();
}
void PerSecond() {
float rate = luaL_check_number(1);
lua_pushnumber(Engine::instance()->perSecond(rate));

3
lua.h
View File

@ -34,6 +34,9 @@ int bundle_dofile(const char *filename);
// Set system.frameTime
void set_frameTime(float frameTime);
// Set smush.movieTime
void set_movieTime(float movieTime);
// Get the event handler function with the given name, pushing the handler
// object if appropriate
lua_Object getEventHandler(const char *name);

View File

@ -43,6 +43,7 @@ Smush::Smush() {
_freq = 22050;
_videoFinished = false;
_videoPause = true;
_movieTime = 0;
}
Smush::~Smush() {
@ -51,6 +52,7 @@ Smush::~Smush() {
void Smush::init() {
_frame = 0;
_movieTime = 0;
_videoFinished = false;
_videoPause = false;
g_timer->installTimerProc(&timerCallback, _speed, NULL);
@ -137,6 +139,8 @@ void Smush::handleFrame() {
if (_frame == _nbframes) {
_videoFinished = true;
}
_movieTime += _speed / 1000;
}
void Smush::handleFramesHeader() {

View File

@ -107,6 +107,7 @@ private:
int32 _frame;
bool _updateNeeded;
int32 _speed;
int32 _movieTime;
int _channels;
int _freq;
bool _videoFinished;
@ -131,7 +132,8 @@ public:
int getWidth() {return _width; }
int getHeight() { return _height; }
void clearUpdateNeeded() { _updateNeeded = false; }
bool isFullSize() { return (_width == 640 && _height == 480); }
bool isFullSize() { return ( _width == 640 && _height == 480); }
int32 getMovieTime() { return _movieTime; }
private:
static void timerCallback(void *ptr);