From 7f3af129f218ee47f806e7672ffe4074b86194c2 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Tue, 7 Jul 2009 15:21:41 +0000 Subject: mplemented changing rooms properly (overlays and objects' animations are deleted before a new room is loaded) and set up a quick demonstration (left click advances to the next room, right click goes back). svn-id: r42224 --- engines/draci/game.cpp | 15 +++++++++++++++ engines/draci/game.h | 14 ++++++++++++++ engines/draci/mouse.cpp | 20 +++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index ab2302cae4..ddb5a58a5a 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -319,6 +319,21 @@ void Game::loadOverlays() { } void Game::changeRoom(uint roomNum) { + _vm->_roomsArchive->clearCache(); + _vm->_anims->deleteOverlays(); + + int oldRoomNum = _currentRoom._roomNum; + + for (uint i = 0; i < _info->_numObjects; ++i) { + GameObject *obj = &_objects[i]; + + if (i != 0 && obj->_location == oldRoomNum) { + for (uint j = 0; j < obj->_numSeq; ++j) { + _vm->_anims->deleteAnimation(obj->_seqTab[j]); + } + } + } + _currentRoom._roomNum = roomNum; loadRoom(roomNum); loadOverlays(); diff --git a/engines/draci/game.h b/engines/draci/game.h index 14140f44e3..5ba0626557 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -106,6 +106,20 @@ public: int getRoomNum(); + // HACK: this is only for testing + void incRoomNum() { + int n = _currentRoom._roomNum; + n = n < 25 ? n+1 : n; + _currentRoom._roomNum = n; + } + + // HACK: same as above + void decRoomNum() { + int n = _currentRoom._roomNum; + n = n > 0 ? n-1 : n; + _currentRoom._roomNum = n; + } + void loadRoom(uint roomNum); int loadAnimation(uint animNum); void loadOverlays(); diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp index b342487209..09216085a7 100644 --- a/engines/draci/mouse.cpp +++ b/engines/draci/mouse.cpp @@ -41,27 +41,45 @@ Mouse::Mouse(DraciEngine *vm) { void Mouse::handleEvent(Common::Event event) { _x = (uint16) event.mouse.x; _y = (uint16) event.mouse.y; - + int room; + switch (event.type) { case Common::EVENT_LBUTTONDOWN: debugC(6, kDraciGeneralDebugLevel, "Left button down (x: %u y: %u)", _x, _y); _lButton = true; + + // HACK: We change to the next room when the left mouse button is pressed. + // This is only for testing. + _vm->_game->incRoomNum(); + room = _vm->_game->getRoomNum(); + _vm->_game->changeRoom(room); break; + case Common::EVENT_LBUTTONUP: debugC(6, kDraciGeneralDebugLevel, "Left button up (x: %u y: %u)", _x, _y); _lButton = false; break; + case Common::EVENT_RBUTTONDOWN: debugC(6, kDraciGeneralDebugLevel, "Right button down (x: %u y: %u)", _x, _y); _rButton = true; + + // HACK: We change to the previous room when the right mouse button is pressed. + // This is only for testing. + _vm->_game->decRoomNum(); + room = _vm->_game->getRoomNum(); + _vm->_game->changeRoom(room); break; + case Common::EVENT_RBUTTONUP: debugC(6, kDraciGeneralDebugLevel, "Right button up (x: %u y: %u)", _x, _y); _rButton = false; break; + case Common::EVENT_MOUSEMOVE: setPosition(_x, _y); break; + default: break; } -- cgit v1.2.3