diff options
author | Strangerke | 2016-04-24 15:00:52 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | 01f8cfd8af22a56ec2f09d96bf3d0a6a19c5515c (patch) | |
tree | 8b95016132c5a9873dc0f44791d4e163e0f6c436 | |
parent | f7e7a45f12351e07851a960c814411de94b346f1 (diff) | |
download | scummvm-rg350-01f8cfd8af22a56ec2f09d96bf3d0a6a19c5515c.tar.gz scummvm-rg350-01f8cfd8af22a56ec2f09d96bf3d0a6a19c5515c.tar.bz2 scummvm-rg350-01f8cfd8af22a56ec2f09d96bf3d0a6a19c5515c.zip |
GNAP: Refactor scene 40
-rw-r--r-- | engines/gnap/gnap.h | 6 | ||||
-rw-r--r-- | engines/gnap/scenes/scene40.cpp | 158 | ||||
-rw-r--r-- | engines/gnap/scenes/scene40.h | 46 | ||||
-rw-r--r-- | engines/gnap/scenes/scenecore.cpp | 9 |
4 files changed, 129 insertions, 90 deletions
diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index fe641ceb86..1864d66dca 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -605,12 +605,6 @@ public: // Shared by scenes 17 & 18 int _s18_garbageCanPos; - - // Scene 40 - int scene40_init(); - void scene40_updateHotspots(); - void scene40_run(); - void scene40_updateAnimations(); // Scene 4x void toyUfoSetStatus(int flagNum); diff --git a/engines/gnap/scenes/scene40.cpp b/engines/gnap/scenes/scene40.cpp index 001a923272..c3adbf2f50 100644 --- a/engines/gnap/scenes/scene40.cpp +++ b/engines/gnap/scenes/scene40.cpp @@ -23,6 +23,7 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scene40.h" namespace Gnap { @@ -38,68 +39,68 @@ enum { kHSDevice = 8 }; -int GnapEngine::scene40_init() { - _gameSys->setAnimation(0, 0, 0); - _gameSys->setAnimation(0, 0, 1); - return isFlag(kGFUnk23) ? 0x01 : 0x00; +Scene40::Scene40(GnapEngine *vm) : Scene(vm) { } -void GnapEngine::scene40_updateHotspots() { - setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_DISABLED | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); - setHotspot(kHSExitCave, 169, 510, 264, 600, SF_EXIT_D_CURSOR, 0, 8); - setHotspot(kHSExitToyStand, 238, 297, 328, 376, SF_EXIT_L_CURSOR, 0, 8); - setHotspot(kHSExitBBQ, 328, 220, 401, 306, SF_EXIT_L_CURSOR, 0, 8); - setHotspot(kHSExitUfo, 421, 215, 501, 282, SF_EXIT_U_CURSOR, 0, 8); - setHotspot(kHSExitKissinBooth, 476, 284, 556, 345, SF_EXIT_R_CURSOR, 0, 8); - setHotspot(kHSExitDancefloor, 317, 455, 445, 600, SF_EXIT_D_CURSOR, 0, 8); - setHotspot(kHSExitShoe, 455, 346, 549, 417, SF_EXIT_D_CURSOR, 0, 8); - setDeviceHotspot(kHSDevice, -1, -1, -1, -1); - _hotspotsCount = 9; +int Scene40::init() { + _vm->_gameSys->setAnimation(0, 0, 0); + _vm->_gameSys->setAnimation(0, 0, 1); + return _vm->isFlag(kGFUnk23) ? 0x01 : 0x00; } -void GnapEngine::scene40_run() { - - queueInsertDeviceIcon(); - endSceneInit(); +void Scene40::updateHotspots() { + _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_DISABLED | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); + _vm->setHotspot(kHSExitCave, 169, 510, 264, 600, SF_EXIT_D_CURSOR, 0, 8); + _vm->setHotspot(kHSExitToyStand, 238, 297, 328, 376, SF_EXIT_L_CURSOR, 0, 8); + _vm->setHotspot(kHSExitBBQ, 328, 220, 401, 306, SF_EXIT_L_CURSOR, 0, 8); + _vm->setHotspot(kHSExitUfo, 421, 215, 501, 282, SF_EXIT_U_CURSOR, 0, 8); + _vm->setHotspot(kHSExitKissinBooth, 476, 284, 556, 345, SF_EXIT_R_CURSOR, 0, 8); + _vm->setHotspot(kHSExitDancefloor, 317, 455, 445, 600, SF_EXIT_D_CURSOR, 0, 8); + _vm->setHotspot(kHSExitShoe, 455, 346, 549, 417, SF_EXIT_D_CURSOR, 0, 8); + _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1); + _vm->_hotspotsCount = 9; +} - while (!_sceneDone) { +void Scene40::run() { + _vm->queueInsertDeviceIcon(); + _vm->endSceneInit(); - if (!isSoundPlaying(0x1094B)) - playSound(0x1094B, true); + while (!_vm->_sceneDone) { + if (!_vm->isSoundPlaying(0x1094B)) + _vm->playSound(0x1094B, true); - updateMouseCursor(); - updateCursorByHotspot(); + _vm->updateMouseCursor(); + _vm->updateCursorByHotspot(); - testWalk(0, 0, -1, -1, -1, -1); + _vm->testWalk(0, 0, -1, -1, -1, -1); - _sceneClickedHotspot = getClickedHotspotId(); - updateGrabCursorSprite(0, 0); + _vm->_sceneClickedHotspot = _vm->getClickedHotspotId(); + _vm->updateGrabCursorSprite(0, 0); - switch (_sceneClickedHotspot) { - + switch (_vm->_sceneClickedHotspot) { case kHSDevice: - runMenu(); - scene40_updateHotspots(); + _vm->runMenu(); + updateHotspots(); break; case kHSPlatypus: - if (_gnapActionStatus < 0) { - if (_grabCursorSpriteIndex >= 0) { - playGnapImpossible(_platX, _platY); + if (_vm->_gnapActionStatus < 0) { + if (_vm->_grabCursorSpriteIndex >= 0) { + _vm->playGnapImpossible(_vm->_platX, _vm->_platY); } else { - switch (_verbCursor) { + switch (_vm->_verbCursor) { case LOOK_CURSOR: - playGnapMoan1(_platX, _platY); + _vm->playGnapMoan1(_vm->_platX, _vm->_platY); break; case GRAB_CURSOR: - gnapKissPlatypus(0); + _vm->gnapKissPlatypus(0); break; case TALK_CURSOR: - playGnapBrainPulsating(_platX, _platY); - playPlatypusSequence(getPlatypusSequenceId()); + _vm->playGnapBrainPulsating(_vm->_platX, _vm->_platY); + _vm->playPlatypusSequence(_vm->getPlatypusSequenceId()); break; case PLAT_CURSOR: - playGnapImpossible(_platX, _platY); + _vm->playGnapImpossible(_vm->_platX, _vm->_platY); break; } } @@ -107,87 +108,82 @@ void GnapEngine::scene40_run() { break; case kHSExitCave: - if (_gnapActionStatus < 0) { - _newSceneNum = 39; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 39; + _vm->_sceneDone = true; } break; case kHSExitToyStand: - if (_gnapActionStatus < 0) { - _newSceneNum = 41; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 41; + _vm->_sceneDone = true; } break; case kHSExitBBQ: - if (_gnapActionStatus < 0) { - _newSceneNum = 42; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 42; + _vm->_sceneDone = true; } break; case kHSExitUfo: - if (_gnapActionStatus < 0) { - _newSceneNum = 43; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 43; + _vm->_sceneDone = true; } break; case kHSExitKissinBooth: - if (_gnapActionStatus < 0) { - _newSceneNum = 44; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 44; + _vm->_sceneDone = true; } break; case kHSExitDancefloor: - if (_gnapActionStatus < 0) { - _newSceneNum = 45; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 45; + _vm->_sceneDone = true; } break; case kHSExitShoe: - if (_gnapActionStatus < 0) { - _newSceneNum = 46; - _sceneDone = true; + if (_vm->_gnapActionStatus < 0) { + _vm->_newSceneNum = 46; + _vm->_sceneDone = true; } break; default: - if (_mouseClickState._left && _gnapActionStatus < 0) - _mouseClickState._left = false; + if (_vm->_mouseClickState._left && _vm->_gnapActionStatus < 0) + _vm->_mouseClickState._left = false; break; } - scene40_updateAnimations(); - - checkGameKeys(); + updateAnimations(); + _vm->checkGameKeys(); - if (isKeyStatus1(8)) { - clearKeyStatus1(8); - runMenu(); - scene40_updateHotspots(); + if (_vm->isKeyStatus1(8)) { + _vm->clearKeyStatus1(8); + _vm->runMenu(); + updateHotspots(); } - gameUpdateTick(); - + _vm->gameUpdateTick(); } - } -void GnapEngine::scene40_updateAnimations() { - - if (_gameSys->getAnimationStatus(0) == 2) { - _gameSys->setAnimation(0, 0, 0); - if (_gnapActionStatus) - _gnapActionStatus = -1; +void Scene40::updateAnimations() { + if (_vm->_gameSys->getAnimationStatus(0) == 2) { + _vm->_gameSys->setAnimation(0, 0, 0); + if (_vm->_gnapActionStatus) + _vm->_gnapActionStatus = -1; else - _sceneDone = true; + _vm->_sceneDone = true; } - } } // End of namespace Gnap diff --git a/engines/gnap/scenes/scene40.h b/engines/gnap/scenes/scene40.h new file mode 100644 index 0000000000..f4f10103df --- /dev/null +++ b/engines/gnap/scenes/scene40.h @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GNAP_SCENE40_H +#define GNAP_SCENE40_H + +#include "gnap/debugger.h" +#include "gnap/scenes/scenecore.h" + +namespace Gnap { + +class GnapEngine; + +class Scene40: public Scene { +public: + Scene40(GnapEngine *vm); + ~Scene40() {} + + virtual int init(); + virtual void updateHotspots(); + virtual void run(); + virtual void updateAnimations(); + virtual void updateAnimationsCb() {}; +}; + +} // End of namespace Gnap +#endif // GNAP_SCENE40_H diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp index cd793fd8e3..291fe73e16 100644 --- a/engines/gnap/scenes/scenecore.cpp +++ b/engines/gnap/scenes/scenecore.cpp @@ -61,6 +61,7 @@ #include "gnap/scenes/scene33.h" #include "gnap/scenes/scene38.h" #include "gnap/scenes/scene39.h" +#include "gnap/scenes/scene40.h" #include "gnap/scenes/scene47.h" #include "gnap/scenes/scene48.h" #include "gnap/scenes/scene54.h" @@ -348,8 +349,9 @@ int GnapEngine::initSceneLogic() { initSceneGrid(21, 146, 11, 10); break; case 40: - backgroundId = scene40_init(); - scene40_updateHotspots(); + _scene = new Scene40(this); + backgroundId = _scene->init(); + _scene->updateHotspots(); _gameSys->setScaleValues(0, 500, 1, 1000); initSceneGrid(21, 146, 11, 10); break; @@ -666,7 +668,8 @@ void GnapEngine::runSceneLogic() { _newSceneNum = 37; break; case 40: - scene40_run(); + _scene->run(); + delete _scene; if (_newSceneNum == 55) _newSceneNum = 37; break; |