aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-11-12 00:45:28 +0000
committerRobert Špalek2009-11-12 00:45:28 +0000
commitd281fe4717f4dad20a0390e81ada17d10cead2bb (patch)
tree2d9b9f61456f49e5b2dd8571a034bfb4d3da6543 /engines/draci/game.cpp
parentc0fc64ecbf8964a6047faf2c86240ca5e8608f4f (diff)
downloadscummvm-rg350-d281fe4717f4dad20a0390e81ada17d10cead2bb.tar.gz
scummvm-rg350-d281fe4717f4dad20a0390e81ada17d10cead2bb.tar.bz2
scummvm-rg350-d281fe4717f4dad20a0390e81ada17d10cead2bb.zip
Added runWrapper() calling run() and some actions around it.
This simplifies a lot of code calling run(). Also, scripts called from the inventory are now called with disabled mouse and title, as desired. svn-id: r45848
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp46
1 files changed, 10 insertions, 36 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 0336dd4320..7e521f56c0 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -329,7 +329,7 @@ void Game::handleInventoryLoop() {
// If there is an inventory item under the cursor and we aren't
// holding any item, run its look GPL program
if (_itemUnderCursor && !_currentItem) {
- _vm->_script->run(_itemUnderCursor->_program, _itemUnderCursor->_look);
+ _vm->_script->runWrapper(_itemUnderCursor->_program, _itemUnderCursor->_look, true, false);
// Otherwise, if we are holding an item, try to place it inside the
// inventory
} else if (_currentItem) {
@@ -368,7 +368,7 @@ void Game::handleInventoryLoop() {
// run the use script for the item.
} else {
if (_vm->_script->testExpression(_itemUnderCursor->_program, _itemUnderCursor->_canUse)) {
- _vm->_script->run(_itemUnderCursor->_program, _itemUnderCursor->_use);
+ _vm->_script->runWrapper(_itemUnderCursor->_program, _itemUnderCursor->_use, true, false);
}
}
updateInventoryCursor();
@@ -801,7 +801,9 @@ void Game::dialogueMenu(int dialogueID) {
break;
}
_currentBlock = _lines[hit];
- runDialogueProg(_dialogueBlocks[_lines[hit]]._program, 1);
+
+ // Run the dialogue program
+ _vm->_script->runWrapper(_dialogueBlocks[_lines[hit]]._program, 1, false, true);
} else {
break;
}
@@ -931,16 +933,6 @@ void Game::dialogueDone() {
_vm->_mouse->setCursorType(kNormalCursor);
}
-void Game::runDialogueProg(GPL2Program prog, int offset) {
- // Mark last animation
- int lastAnimIndex = _vm->_anims->getLastIndex();
-
- // Run the dialogue program
- _vm->_script->run(prog, offset);
-
- deleteAnimationsAfterIndex(lastAnimIndex);
-}
-
int Game::playHeroAnimation(int anim_index) {
GameObject *dragon = getObject(kDragonObject);
const int current_anim_index = dragon->_playingAnim;
@@ -1183,22 +1175,18 @@ bool Game::enterNewRoom() {
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
_vm->_screen->setPalette(f->_data, 0, kNumColours);
- // Clean the mouse and animation title. It gets first updated in
- // loop(), hence if the hero walks during the initialization scripts,
- // the old values would remain otherwise.
- _vm->_mouse->setCursorType(kNormalCursor);
- _titleAnim->markDirtyRect(_vm->_screen->getSurface());
- Text *title = reinterpret_cast<Text *>(_titleAnim->getCurrentFrame());
- title->setText("");
-
// Run the program for the gate the dragon came through
- runGateProgram(_newGate);
+ debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", _newGate);
+ _vm->_script->runWrapper(_currentRoom._program, _currentRoom._gates[_newGate], true, true);
+
+ setExitLoop(false);
// Set cursor state
// Need to do this after we set the palette since the cursors use it
if (_currentRoom._mouseOn) {
debugC(6, kDraciLogicDebugLevel, "Mouse: ON");
_vm->_mouse->cursorOn();
+ _vm->_mouse->setCursorType(kNormalCursor);
} else {
debugC(6, kDraciLogicDebugLevel, "Mouse: OFF");
_vm->_mouse->cursorOff();
@@ -1217,20 +1205,6 @@ bool Game::enterNewRoom() {
return true;
}
-void Game::runGateProgram(int gate) {
- debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", gate);
-
- // Mark last animation
- int lastAnimIndex = _vm->_anims->getLastIndex();
-
- // Run gate program
- _vm->_script->run(_currentRoom._program, _currentRoom._gates[gate]);
-
- deleteAnimationsAfterIndex(lastAnimIndex);
-
- setExitLoop(false);
-}
-
void Game::positionAnimAsHero(Animation *anim) {
// Calculate scaling factors
const double scale = getPers0() + getPersStep() * _hero.y;