diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/ai-cinematic.cpp | 96 | ||||
-rw-r--r-- | engines/hdb/ai.h | 3 | ||||
-rw-r--r-- | engines/hdb/lua-script.cpp | 48 |
3 files changed, 144 insertions, 3 deletions
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp index 24ecd291d1..5eafd47f05 100644 --- a/engines/hdb/ai-cinematic.cpp +++ b/engines/hdb/ai-cinematic.cpp @@ -65,6 +65,7 @@ static const char *cineTypeStr[] = { void AI::processCines() { AIEntity *e; + Picture *p; bool complete, bailOut; if (!_cineActive) { @@ -311,6 +312,49 @@ void AI::processCines() { complete = true; } break; + case C_DRAWPIC: + + if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) { + p = g_hdb->_gfx->loadPic(_cine[i]->string); + cineAddToFreeList(p); + cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, false); + } + _cine[i]->pic = p; + _cine[i]->pic->draw((int)_cine[i]->x, (int)_cine[i]->y); + complete = true; + break; + case C_DRAWMASKEDPIC: + + if ((p = cineFindInBlitList(_cine[i]->id)) == NULL) { + p = g_hdb->_gfx->loadPic(_cine[i]->string); + cineAddToFreeList(p); + cineAddToBlitList(_cine[i]->id, p, (int)_cine[i]->x, (int)_cine[i]->y, true); + } + _cine[i]->pic = p; + _cine[i]->pic->drawMasked((int)_cine[i]->x, (int)_cine[i]->y); + complete = true; + break; + + case C_MOVEPIC: + if (!_cine[i]->start) { + Picture *pic = cineFindInBlitList(_cine[i]->id); + if (!pic) { + pic = g_hdb->_gfx->loadPic(_cine[i]->string); + cineAddToFreeList(pic); + } else + cineRemoveFromBlitList(_cine[i]->id); + _cine[i]->pic = pic; + _cine[i]->start = 1; + } + + cineRemoveFromBlitList(_cine[i]->id); + _cine[i]->x += _cine[i]->xv; + _cine[i]->y += _cine[i]->yv; + cineAddToBlitList(_cine[i]->id, _cine[i]->pic, (int)_cine[i]->x, (int)_cine[i]->y, false); + if (abs((int)(_cine[i]->x - _cine[i]->x2)) <= 1 && abs((int)(_cine[i]->y - _cine[i]->y2)) <= 1) + complete = true; + break; + case C_MOVEMASKEDPIC: if (!_cine[i]->start) { Picture *pic = cineFindInBlitList(_cine[i]->id); @@ -330,6 +374,7 @@ void AI::processCines() { if (abs((int)(_cine[i]->x - _cine[i]->x2)) <= 1 && abs((int)(_cine[i]->y - _cine[i]->y2)) <= 1) complete = true; break; + case C_USEENTITY: for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) { if ((*it)->entityName && Common::matchString((*it)->entityName, _cine[i]->string, true)) { @@ -676,6 +721,57 @@ void AI::cineCenterTextOut(const char *text, int y, int timer) { _cine.push_back(cmd); } +void AI::cineDrawPic(const char *id, const char *pic, int x, int y) { + if (!pic || !id) { + warning("cineDrawPic: Missing ID or PIC"); + return; + } + + CineCommand *cmd = new CineCommand; + cmd->x = x; + cmd->y = y; + cmd->string = pic; + cmd->id = id; + cmd->cmdType = C_DRAWPIC; + _cine.push_back(cmd); +} + +void AI::cineDrawMaskedPic(const char *id, const char *pic, int x, int y) { + if (!pic || !id) { + warning("cineDrawMaskedPic: Missing ID or PIC"); + return; + } + + CineCommand *cmd = new CineCommand; + cmd->x = x; + cmd->y = y; + cmd->string = pic; + cmd->id = id; + cmd->cmdType = C_DRAWMASKEDPIC; + _cine.push_back(cmd); +} + +void AI::cineMovePic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) { + if (!pic || !id) { + warning("cineMovePic: Missing ID or PIC"); + return; + } + + CineCommand *cmd = new CineCommand; + cmd->x = x1; + cmd->y = y1; + cmd->x2 = x2; + cmd->y2 = y2; + cmd->speed = speed; + cmd->xv = ((double)(x2-x1)) / (double)speed; + cmd->yv = ((double)(y2-y1)) / (double)speed; + cmd->start = 0; + cmd->string = pic; + cmd->id = id; + cmd->cmdType = C_MOVEPIC; + _cine.push_back(cmd); +} + void AI::cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed) { if (!pic || !id) { warning("cineMoveMaskedPic: Missing ID or PIC"); diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 47c8f75768..9c5acfce36 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -992,6 +992,9 @@ public: void cineDialog(const char *title, const char *string, int seconds); void cineTextOut(const char *text, int x, int y, int timer); void cineCenterTextOut(const char *text, int y, int timer); + void cineDrawPic(const char *id, const char *pic, int x, int y); + void cineDrawMaskedPic(const char *id, const char *pic, int x, int y); + void cineMovePic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed); void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed); void cineUse(const char *entName); void cinePlaySound(int index); diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 37e4d6d486..626272eb07 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -452,17 +452,59 @@ static int cineDialog(lua_State *L) { } static int cineDrawPic(lua_State *L) { - warning("STUB: CINE DRAW PIC"); + const char *id = lua_tostring(L, 1); + const char *pic = lua_tostring(L, 2); + double x = lua_tonumber(L, 3); + double y = lua_tonumber(L, 3); + + g_hdb->_lua->checkParameters("cineDrawPic", 4); + + x += kCameraXOff; + y += kCameraYOff; + + lua_pop(L, 4); + g_hdb->_ai->cineDrawPic(id, pic, (int)x, (int)y); + return 0; } static int cineDrawMaskedPic(lua_State *L) { - warning("STUB: CINE DRAW MASKED PIC"); + const char *id = lua_tostring(L, 1); + const char *pic = lua_tostring(L, 2); + double x = lua_tonumber(L, 3); + double y = lua_tonumber(L, 3); + + g_hdb->_lua->checkParameters("cineDrawMaskedPic", 4); + + x += kCameraXOff; + y += kCameraYOff; + + lua_pop(L, 4); + g_hdb->_ai->cineDrawMaskedPic(id, pic, (int)x, (int)y); + return 0; } static int cineMovePic(lua_State *L) { - warning("STUB: CINE MOVE PIC"); + const char *id = lua_tostring(L, 1); + const char *pic = lua_tostring(L, 2); + double x1 = lua_tonumber(L, 3); + double y1 = lua_tonumber(L, 4); + double x2 = lua_tonumber(L, 5); + double y2 = lua_tonumber(L, 6); + double speed = lua_tonumber(L, 7); + + g_hdb->_lua->checkParameters("cineMovePic", 7); + + x1 += kCameraXOff; + y1 += kCameraYOff; + x2 += kCameraXOff; + y2 += kCameraYOff; + + lua_pop(L, 7); + + g_hdb->_ai->cineMovePic(id, pic, (int)x1, (int)y1, (int)x2, (int)y2, (int)speed); + return 0; } |