[Scummvm-cvs-logs] SF.net SVN: scummvm:[42899] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Wed Jul 29 21:38:02 CEST 2009
Revision: 42899
http://scummvm.svn.sourceforge.net/scummvm/?rev=42899&view=rev
Author: dkasak13
Date: 2009-07-29 19:38:02 +0000 (Wed, 29 Jul 2009)
Log Message:
-----------
* 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())
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
scummvm/branches/gsoc2009-draci/engines/draci/game.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-29 18:35:34 UTC (rev 42898)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-29 19:38:02 UTC (rev 42899)
@@ -159,6 +159,7 @@
void Game::init() {
_shouldQuit = false;
+ _shouldExitLoop = false;
_loopStatus = kStatusOrdinary;
_objUnderCursor = kOverlayImage;
@@ -179,54 +180,57 @@
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 @@
// 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);
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-07-29 18:35:34 UTC (rev 42898)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-07-29 19:38:02 UTC (rev 42899)
@@ -215,6 +215,9 @@
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 @@
LoopStatus _loopStatus;
bool _shouldQuit;
+ bool _shouldExitLoop;
int _objUnderCursor;
int _markedAnimationIndex; //!< Used by the Mark GPL command
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list