aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/draci.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-10-01 08:32:35 +0000
committerRobert Špalek2009-10-01 08:32:35 +0000
commit24d649b972235d85d0e4d96de4607fa87d4f26c1 (patch)
tree6e02d575205b5dd0a20871bb95ec3bcb0b5e7abe /engines/draci/draci.cpp
parent2d29625f0e8afba7a447be49615742f6612d38a0 (diff)
downloadscummvm-rg350-24d649b972235d85d0e4d96de4607fa87d4f26c1.tar.gz
scummvm-rg350-24d649b972235d85d0e4d96de4607fa87d4f26c1.tar.bz2
scummvm-rg350-24d649b972235d85d0e4d96de4607fa87d4f26c1.zip
Clean up room changing code and support returning from the map.
Completely changed the interface, removing unused methods and attributes, renaming other ones to reflect what they do, and moving some methods into the private section. Code changing the location, originally scattered over many pieces of code, has been unified into one place. Remember the previous room when entering the map so that one can return there. Also, the event handler processes one event at a time, preventing lost clicks on touchpads. svn-id: r44508
Diffstat (limited to 'engines/draci/draci.cpp')
-rw-r--r--engines/draci/draci.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 55c42c9097..6290ee01dc 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -173,15 +173,6 @@ int DraciEngine::init() {
return Common::kNoError;
}
-int DraciEngine::go() {
- debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()");
-
- _game->init();
- _game->start();
-
- return Common::kNoError;
-}
-
bool DraciEngine::handleEvents() {
Common::Event event;
bool quit = false;
@@ -193,20 +184,19 @@ bool DraciEngine::handleEvents() {
break;
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
- _game->setRoomNum(_game->nextRoomNum());
- _game->setGateNum(0);
+ _game->scheduleEnteringRoomUsingGate(_game->nextRoomNum(), 0);
} else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
- _game->setRoomNum(_game->prevRoomNum());
- _game->setGateNum(0);
+ _game->scheduleEnteringRoomUsingGate(_game->prevRoomNum(), 0);
} else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
- int escRoom = _game->getEscRoom();
+ const int escRoom = _game->getRoomNum() != _game->getMapRoom()
+ ? _game->getEscRoom() : _game->getPreviousRoomNum();
// Check if there is an escape room defined for the current room
if (escRoom != kNoEscRoom) {
// Schedule room change
- _game->setRoomNum(_game->getEscRoom());
- _game->setGateNum(0);
+ // TODO: gate 0 is not always the best one for returning from the map
+ _game->scheduleEnteringRoomUsingGate(escRoom, 0);
_game->setExitLoop(true);
// End any currently running GPL programs
@@ -214,11 +204,9 @@ bool DraciEngine::handleEvents() {
}
} else if (event.kbd.keycode == Common::KEYCODE_m) {
if (_game->getLoopStatus() == kStatusOrdinary) {
- // TODO: record the current room number
- // so that we can quickly exit there
- // when Escape is pressed
- _game->setRoomNum(_game->getMapRoom());
- _game->setGateNum(0);
+ const int new_room = _game->getRoomNum() != _game->getMapRoom()
+ ? _game->getMapRoom() : _game->getPreviousRoomNum();
+ _game->scheduleEnteringRoomUsingGate(new_room, 0);
}
} else if (event.kbd.keycode == Common::KEYCODE_w) {
// Show walking map toggle
@@ -236,6 +224,12 @@ bool DraciEngine::handleEvents() {
default:
_mouse->handleEvent(event);
}
+
+ // TODO: I place the break here to make sure that each event is
+ // processed. If I don't do that and allow more than 1 event,
+ // then a very quick succession of mouse button down and up
+ // (occuring on a touchpad) cancels each other.
+ break;
}
// Show walking map overlay
@@ -282,7 +276,8 @@ DraciEngine::~DraciEngine() {
Common::Error DraciEngine::run() {
init();
- go();
+ _game->init();
+ _game->start();
return Common::kNoError;
}