From 397d82258767524abae769c6527ccf308b238b76 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Wed, 3 Mar 2004 21:43:34 +0000 Subject: [PATCH] added movieTime stuff, now it try handle subtitles for smush --- engine.cpp | 6 ++++++ engine.h | 2 +- lua.cpp | 7 +++++++ lua.h | 3 +++ smush.cpp | 4 ++++ smush.h | 4 +++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/engine.cpp b/engine.cpp index 42e600d2558..23300b61140 100644 --- a/engine.cpp +++ b/engine.cpp @@ -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(); } } diff --git a/engine.h b/engine.h index 2e79fb4890e..2b246b491ce 100644 --- a/engine.h +++ b/engine.h @@ -138,7 +138,7 @@ private: Scene *currScene_; - unsigned frameStart_, frameTime_; + unsigned frameStart_, frameTime_, movieTime_; bool controlsEnabled_[SDLK_EXTRA_LAST]; diff --git a/lua.cpp b/lua.cpp index 9f4d10b5659..d090222caee 100644 --- a/lua.cpp +++ b/lua.cpp @@ -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)); diff --git a/lua.h b/lua.h index d13c6d1da4a..43883df94df 100644 --- a/lua.h +++ b/lua.h @@ -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); diff --git a/smush.cpp b/smush.cpp index 066fd9fffa3..a6263087fac 100644 --- a/smush.cpp +++ b/smush.cpp @@ -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() { diff --git a/smush.h b/smush.h index 6ee19579258..2c2c74ed75d 100644 --- a/smush.h +++ b/smush.h @@ -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);