added engine states, separate fullscreen smush playback depend on engine mode
This commit is contained in:
parent
4b07d850fc
commit
098f0b2b2c
6 changed files with 73 additions and 42 deletions
20
engine.cpp
20
engine.cpp
|
@ -84,6 +84,21 @@ void Engine::mainLoop() {
|
|||
// Run asynchronous tasks
|
||||
lua_runtasks();
|
||||
|
||||
if (_mode == ENGINE_MODE_SMUSH) {
|
||||
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();
|
||||
}
|
||||
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
|
||||
}
|
||||
// Draw text
|
||||
for (text_list_type::iterator i = textObjects_.begin(); i != textObjects_.end(); i++) {
|
||||
(*i)->draw();
|
||||
}
|
||||
g_driver->flipBuffer();
|
||||
} else if (_mode == ENGINE_MODE_NORMAL) {
|
||||
if (SCREENBLOCKS_GLOBAL == 1)
|
||||
screenBlocksReset();
|
||||
|
||||
|
@ -100,11 +115,9 @@ void Engine::mainLoop() {
|
|||
if (SCREENBLOCKS_GLOBAL == 1)
|
||||
screenBlocksBlitDirtyBlocks();
|
||||
|
||||
if (!g_smush->isPlaying() || (g_smush->isPlaying() && !g_smush->isFullSize())) {
|
||||
Bitmap::prepareDraw();
|
||||
if (currScene_ != NULL)
|
||||
currScene_->drawBackground();
|
||||
}
|
||||
|
||||
if (g_smush->isPlaying()) {
|
||||
movieTime_ = g_smush->getMovieTime();
|
||||
|
@ -122,7 +135,7 @@ void Engine::mainLoop() {
|
|||
currScene_->setupCamera();
|
||||
|
||||
// Draw actors
|
||||
if (!g_smush->isPlaying() || (g_smush->isPlaying() && !g_smush->isFullSize())) {
|
||||
if (!g_smush->isPlaying()) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
for (actor_list_type::iterator i = actors_.begin(); i != actors_.end(); i++) {
|
||||
Actor *a = *i;
|
||||
|
@ -139,6 +152,7 @@ void Engine::mainLoop() {
|
|||
}
|
||||
|
||||
g_driver->flipBuffer();
|
||||
}
|
||||
|
||||
// don't kill CPU
|
||||
SDL_Delay(1);
|
||||
|
|
9
engine.h
9
engine.h
|
@ -26,6 +26,12 @@
|
|||
|
||||
class Actor;
|
||||
|
||||
#define ENGINE_MODE_IDLE 0
|
||||
#define ENGINE_MODE_PAUSE 1
|
||||
#define ENGINE_MODE_NORMAL 2
|
||||
#define ENGINE_MODE_SMUSH 3
|
||||
#define ENGINE_MODE_DRAW 4
|
||||
|
||||
// Fake SDLK_* values for joystick and mouse events
|
||||
enum {
|
||||
SDLK_JOY1_B1 = SDLK_LAST,
|
||||
|
@ -86,6 +92,8 @@ public:
|
|||
return instance_;
|
||||
}
|
||||
|
||||
void setMode(int mode) { _mode = mode; }
|
||||
|
||||
void mainLoop();
|
||||
unsigned frameStart() const { return frameStart_; }
|
||||
unsigned frameTime() const { return frameTime_; }
|
||||
|
@ -137,6 +145,7 @@ private:
|
|||
~Engine() { }
|
||||
|
||||
Scene *currScene_;
|
||||
int _mode;
|
||||
|
||||
unsigned frameStart_, frameTime_, movieTime_;
|
||||
|
||||
|
|
2
lua.cpp
2
lua.cpp
|
@ -1028,6 +1028,7 @@ static void GetTextObjectDimensions() {
|
|||
|
||||
static void StartFullscreenMovie() {
|
||||
bool mode = getbool(2);
|
||||
Engine::instance()->setMode(ENGINE_MODE_SMUSH);
|
||||
pushbool(g_smush->play(luaL_check_string(1), 0, 0));
|
||||
}
|
||||
|
||||
|
@ -1035,6 +1036,7 @@ static void StartMovie() {
|
|||
bool mode = getbool(2);
|
||||
int x = lua_getparam(3);
|
||||
int y = lua_getparam(4);
|
||||
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||
pushbool(g_smush->play(luaL_check_string(1), x, y));
|
||||
}
|
||||
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -121,6 +121,7 @@ int main(int argc, char *argv[]) {
|
|||
lua_call("BOOT");
|
||||
lua_endblock();
|
||||
|
||||
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||
Engine::instance()->mainLoop();
|
||||
|
||||
delete g_smush;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "mixer/mixer.h"
|
||||
#include "driver_gl.h"
|
||||
#include "resource.h"
|
||||
#include "engine.h"
|
||||
|
||||
Smush *g_smush;
|
||||
|
||||
|
@ -217,6 +218,11 @@ bool Smush::setupAnim(const char *file, int x, int y) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Smush::stop() {
|
||||
deinit();
|
||||
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||
}
|
||||
|
||||
bool Smush::play(const char *filename, int x, int y) {
|
||||
deinit();
|
||||
|
||||
|
|
3
smush.h
3
smush.h
|
@ -74,7 +74,7 @@ public:
|
|||
~Smush();
|
||||
|
||||
bool play(const char *filename, int x, int y);
|
||||
void stop() { deinit(); }
|
||||
void stop();
|
||||
void pause(bool pause) { _videoPause = pause; }
|
||||
bool isPlaying() { return !_videoFinished; }
|
||||
bool isUpdateNeeded() { return _updateNeeded; }
|
||||
|
@ -84,7 +84,6 @@ public:
|
|||
int getWidth() {return _width; }
|
||||
int getHeight() { return _height; }
|
||||
void clearUpdateNeeded() { _updateNeeded = false; }
|
||||
bool isFullSize() { return ( _width == 640 && _height == 480); }
|
||||
int32 getMovieTime() { return _movieTime; }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue