diff options
author | Denis Kasak | 2009-07-29 19:38:02 +0000 |
---|---|---|
committer | Denis Kasak | 2009-07-29 19:38:02 +0000 |
commit | 07042e31bcabd4c33f38a7c3a41ca6c603525011 (patch) | |
tree | a461bc778e19daf45306ee40defe3f6619da28e9 /engines | |
parent | bc89ce23d38c2d26ae5336297d628099cdbf8498 (diff) | |
download | scummvm-rg350-07042e31bcabd4c33f38a7c3a41ca6c603525011.tar.gz scummvm-rg350-07042e31bcabd4c33f38a7c3a41ca6c603525011.tar.bz2 scummvm-rg350-07042e31bcabd4c33f38a7c3a41ca6c603525011.zip |
* Made Game::loop() exit conditionally depending on whether the internal Game::_shouldExitLoop variable is set.
* Added mechanisms for signalling whether the main game loop should exit or not (Game::setExitLoop() and Game::shouldExitLoop())
svn-id: r42899
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/game.cpp | 80 | ||||
-rw-r--r-- | engines/draci/game.h | 4 |
2 files changed, 46 insertions, 38 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 094364be6c..0122ae1626 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -159,6 +159,7 @@ void Game::start() { void Game::init() { _shouldQuit = false; + _shouldExitLoop = false; _loopStatus = kStatusOrdinary; _objUnderCursor = kOverlayImage; @@ -179,54 +180,57 @@ void Game::init() { void Game::loop() { - _vm->handleEvents(); + do { + _vm->handleEvents(); - if (shouldQuit()) - return; + if (_currentRoom._mouseOn) { + int x = _vm->_mouse->getPosX(); + int y = _vm->_mouse->getPosY(); - if (_currentRoom._mouseOn) { - int x = _vm->_mouse->getPosX(); - int y = _vm->_mouse->getPosY(); + if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) { + walkHero(x, y); + } - if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) { - walkHero(x, y); - } + int animUnderCursor = _vm->_anims->getTopAnimationID(x, y); + //Animation *anim = _vm->_anims->getAnimation(animUnderCursor); - int animUnderCursor = _vm->_anims->getTopAnimationID(x, y); - //Animation *anim = _vm->_anims->getAnimation(animUnderCursor); + int curObject = getObjectWithAnimation(animUnderCursor); + GameObject *obj = &_objects[curObject]; - int curObject = getObjectWithAnimation(animUnderCursor); - GameObject *obj = &_objects[curObject]; + Animation *titleAnim = _vm->_anims->getAnimation(kTitleText); - Animation *titleAnim = _vm->_anims->getAnimation(kTitleText); + // TODO: Handle displaying title in the proper location - // TODO: Handle displaying title in the proper location + if (curObject != kNotFound) { + titleAnim->markDirtyRect(_vm->_screen->getSurface()); + reinterpret_cast<Text *>(titleAnim->getFrame())->setText(obj->_title); - if (curObject != kNotFound) { - titleAnim->markDirtyRect(_vm->_screen->getSurface()); - reinterpret_cast<Text *>(titleAnim->getFrame())->setText(obj->_title); + // HACK: Test running look and use scripts + if (_vm->_mouse->lButtonPressed()) { + _vm->_mouse->lButtonSet(false); + _vm->_script->run(obj->_program, obj->_look); + } - // HACK: Test running look and use scripts - if (_vm->_mouse->lButtonPressed()) { - _vm->_mouse->lButtonSet(false); - _vm->_script->run(obj->_program, obj->_look); + if (_vm->_mouse->rButtonPressed()) { + _vm->_mouse->rButtonSet(false); + _vm->_script->run(obj->_program, obj->_use); + } + } else { + titleAnim->markDirtyRect(_vm->_screen->getSurface()); + reinterpret_cast<Text *>(titleAnim->getFrame())->setText(""); } - if (_vm->_mouse->rButtonPressed()) { - _vm->_mouse->rButtonSet(false); - _vm->_script->run(obj->_program, obj->_use); - } - } else { - titleAnim->markDirtyRect(_vm->_screen->getSurface()); - reinterpret_cast<Text *>(titleAnim->getFrame())->setText(""); + debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor); } - debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor); - } + if (shouldQuit()) + return; + + _vm->_anims->drawScene(_vm->_screen->getSurface()); + _vm->_screen->copyToScreen(); + _vm->_system->delayMillis(20); - _vm->_anims->drawScene(_vm->_screen->getSurface()); - _vm->_screen->copyToScreen(); - _vm->_system->delayMillis(20); + } while (!shouldExitLoop()); } int Game::getObjectWithAnimation(int animID) { @@ -382,10 +386,10 @@ void Game::loadRoom(int roomNum) { // HACK: Gates' scripts shouldn't be run unconditionally // This is for testing - for (uint i = 0; i < _currentRoom._numGates; ++i) { - debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", i); - _vm->_script->run(_currentRoom._program, gates[i]); - } + //for (uint i = 0; i < _currentRoom._numGates; ++i) { + // debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", i); + // _vm->_script->run(_currentRoom._program, gates[i]); + //} // Set room palette f = _vm->_paletteArchive->getFile(_currentRoom._palette); diff --git a/engines/draci/game.h b/engines/draci/game.h index 5cfa5d894e..6393ea7573 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -215,6 +215,9 @@ public: bool shouldQuit() { return _shouldQuit; } void setQuit(bool quit) { _shouldQuit = quit; } + bool shouldExitLoop() { return _shouldExitLoop; } + void setExitLoop(bool exit) { _shouldExitLoop = exit; } + private: DraciEngine *_vm; @@ -230,6 +233,7 @@ private: LoopStatus _loopStatus; bool _shouldQuit; + bool _shouldExitLoop; int _objUnderCursor; int _markedAnimationIndex; //!< Used by the Mark GPL command |