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

View file

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

View file

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

3
lua.h
View file

@ -34,6 +34,9 @@ int bundle_dofile(const char *filename);
// Set system.frameTime // Set system.frameTime
void set_frameTime(float 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 // Get the event handler function with the given name, pushing the handler
// object if appropriate // object if appropriate
lua_Object getEventHandler(const char *name); lua_Object getEventHandler(const char *name);

View file

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

View file

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