diff options
author | johndoe123 | 2011-10-17 15:32:56 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:43 +0200 |
commit | c56c93f085a7861e19a6a0befdbdd69b9837b41f (patch) | |
tree | 8e67de7193f74128259bd572d1108af3f7fa74e9 /engines | |
parent | 6315ccb5528a9a4d810779055df9184f4b2960c1 (diff) | |
download | scummvm-rg350-c56c93f085a7861e19a6a0befdbdd69b9837b41f.tar.gz scummvm-rg350-c56c93f085a7861e19a6a0befdbdd69b9837b41f.tar.bz2 scummvm-rg350-c56c93f085a7861e19a6a0befdbdd69b9837b41f.zip |
NEVERHOOD: Add Scene2702 (needs cleanup)
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 4 | ||||
-rw-r--r-- | engines/neverhood/module2700.cpp | 177 | ||||
-rw-r--r-- | engines/neverhood/module2700.h | 23 |
3 files changed, 200 insertions, 4 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 64117ad39a..95fe521e23 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -297,8 +297,8 @@ void GameModule::startup() { createModule(2600, -1); #endif #if 1 - _vm->gameState().which = 4; - _vm->gameState().sceneNum = 0; + _vm->gameState().which = 0; + _vm->gameState().sceneNum = 1; createModule(2700, -1); #endif } diff --git a/engines/neverhood/module2700.cpp b/engines/neverhood/module2700.cpp index e8d3105f6a..8c81ddf5e7 100644 --- a/engines/neverhood/module2700.cpp +++ b/engines/neverhood/module2700.cpp @@ -121,7 +121,7 @@ void Module2700::createScene(int sceneNum, int which) { _childObject = new Scene2701(_vm, this, which); break; case 1: -//TODO _childObject = new Scene2702(_vm, this, which); + _childObject = new Scene2702(_vm, this, which); break; case 2: if (which == 6 || which == 7) @@ -617,6 +617,181 @@ uint32 Scene2701::handleMessage42F600(int messageNum, const MessageParam ¶m, return 0; } +static const uint32 kScene2702Infos[2][3] = { + {0x004B5F68, 0x004B5F8C, 0x004B5FB0}, + {0x004B5FD8, 0x004B5FFC, 0x004B6020} +}; + + +Scene2702::Scene2702(NeverhoodEngine *vm, Module *parentModule, int which) + : Scene(vm, parentModule, true), _flag1(true), _newTrackIndex(-1), _count(3) { + + for (int i = 0; i < 2; i++) + for (int j = 0; j < 3; j++) + _sceneInfos[i][j] = _vm->_staticData->getSceneInfo2700(kScene2702Infos[i][j]); + + _surfaceFlag = true; + SetMessageHandler(&Scene2702::handleMessage); + SetUpdateHandler(&Scene2702::update); + + setBackground(0x18808B00); + setPalette(0x18808B00); + + _palette->addPalette(calcHash("paPodFloor"), 65, 31, 65); + _palette->addPalette(calcHash("paKlayFloor"), 0, 65, 0); + addEntity(_palette); + + insertMouse433(0x08B04180); + + //TODO _class437 = insertSprite<Class437>(0x12002035); + _class521 = insertSprite<Class521>(this, 320, 240); + //TODO _class517 = insertSprite<Class517>(_class521, _class437->getSurface(), 4); + //TODO insertSprite<Class518>(_class521); + //TODO _class520 = insertSprite<Class520>(_class521, _class437->getSurface(), 4); + //TODO _class519 = insertSprite<Class519>(_class521, _class437->getSurface(), 4); + + _dataResource.load(0x04310014); + + if (which == 1) { + _currSceneInfos = _sceneInfos[1]; + _currTrackIndex = 1; + } else if (which == 2) { + _currSceneInfos = _sceneInfos[1]; + _currTrackIndex = 2; + _palette->addPalette(calcHash("paPodShade"), 65, 31, 65); + _palette->addPalette(calcHash("paKlayShade"), 0, 65, 0); + _flag1 = false; + } else if (which == 3) { + _currSceneInfos = _sceneInfos[0]; + _currTrackIndex = 0; + } else if (which == 4) { + _currSceneInfos = _sceneInfos[0]; + _currTrackIndex = 2; + _palette->addPalette(calcHash("paPodShade"), 65, 31, 65); + _palette->addPalette(calcHash("paKlayShade"), 0, 65, 0); + _flag1 = false; + } else if (which == 5) { + _currSceneInfos = _sceneInfos[0]; + _currTrackIndex = 1; + _palette->addPalette(calcHash("paPodShade"), 65, 31, 65); + _palette->addPalette(calcHash("paKlayShade"), 0, 65, 0); + _flag1 = false; + } else { + _currSceneInfos = _sceneInfos[1]; + _currTrackIndex = 0; + } + + _trackPoints = _dataResource.getPointArray(_currSceneInfos[_currTrackIndex]->pointListName); + _class521->setPathPoints(_trackPoints); + + if (which == _currSceneInfos[_currTrackIndex]->which2) { + sendMessage(_class521, 0x2002, _trackPoints->size() - 1); + sendMessage(_class521, 0x2007, 150); + } else { + sendMessage(_class521, 0x2002, 0); + sendMessage(_class521, 0x2008, 150); + } + + _palette->copyBasePalette(0, 256, 0); + +} + +void Scene2702::update() { + Scene::update(); + if (_flag1 && _class521->getX() > 422) { + debug("fade #1"); + _palette->addBasePalette(calcHash("paPodShade"), 65, 31, 65); + _palette->addBasePalette(calcHash("paKlayShade"), 0, 65, 0); + _palette->startFadeToPalette(12); + _flag1 = false; + } else if (!_flag1 && _class521->getX() <= 422) { + debug("fade #2"); + _palette->addBasePalette(calcHash("paPodFloor"), 65, 31, 65); + _palette->addBasePalette(calcHash("paKlayFloor"), 0, 65, 0); + _palette->startFadeToPalette(12); + _flag1 = true; + } +} + +uint32 Scene2702::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x0001: + findClosestTrack(param.asPoint()); + break; + case 0x2005: + if (_newTrackIndex >= 0) { + if (_currSceneInfos[_currTrackIndex]->which1 < 0) + changeTrack(); + } else if (_currSceneInfos[_currTrackIndex]->which1 >= 0) + leaveScene(_currSceneInfos[_currTrackIndex]->which1); + break; + case 0x2006: + if (_newTrackIndex >= 0) { + if (_currSceneInfos[_currTrackIndex]->which2 < 0) + changeTrack(); + } else if (_currSceneInfos[_currTrackIndex]->which2 >= 0) + leaveScene(_currSceneInfos[_currTrackIndex]->which2); + break; + case 0x200D: + sendMessage(_parentModule, 0x200D, 0); + break; + } + return 0; +} + +void Scene2702::findClosestTrack(NPoint pt) { + int minMatchTrackIndex = -1; + int minMatchDistance = 640; + // Find the track which contains a point closest to pt + for (int infoIndex = 0; infoIndex < _count; infoIndex++) { + NPointArray *pointList = _dataResource.getPointArray(_currSceneInfos[infoIndex]->pointListName); + for (uint pointIndex = 0; pointIndex < pointList->size(); pointIndex++) { + NPoint testPt = (*pointList)[pointIndex]; + int distance = calcDistance(testPt.x, testPt.y, pt.x, pt.y); + if (distance < minMatchDistance) { + minMatchTrackIndex = infoIndex; + minMatchDistance = distance; + } + } + } + if (minMatchTrackIndex >= 0 && minMatchTrackIndex != _currTrackIndex) { + _newTrackIndex = minMatchTrackIndex; + _newTrackDestX = pt.x; + if (_currSceneInfos == _sceneInfos[0]) { + if (_currTrackIndex == 0) + sendMessage(_class521, 0x2003, _trackPoints->size() - 1); + else + sendMessage(_class521, 0x2003, 0); + } else if (_currTrackIndex == 2) { + sendMessage(_class521, 0x2003, 0); + } else { + sendMessage(_class521, 0x2003, _trackPoints->size() - 1); + } + } else { + _newTrackIndex = -1; + sendMessage(_class521, 0x2004, pt.x); + } +} + +void Scene2702::changeTrack() { + _currTrackIndex = _newTrackIndex; + _trackPoints = _dataResource.getPointArray(_currSceneInfos[_currTrackIndex]->pointListName); + _class521->setPathPoints(_trackPoints); + if (_currSceneInfos == _sceneInfos[0]) { + if (_currTrackIndex == 0) + sendMessage(_class521, 0x2002, _trackPoints->size() - 1); + else + sendMessage(_class521, 0x2002, 0); + } else if (_currTrackIndex == 2) { + sendMessage(_class521, 0x2002, 0); + } else { + sendMessage(_class521, 0x2002, _trackPoints->size() - 1); + } + sendMessage(_class521, 0x2004, _newTrackDestX); + _newTrackIndex = -1; +} + Scene2704::Scene2704(NeverhoodEngine *vm, Module *parentModule, int which, uint32 sceneInfoId, int16 value, const uint32 *staticSprites, const NRect *clipRect) : Scene(vm, parentModule, true) { diff --git a/engines/neverhood/module2700.h b/engines/neverhood/module2700.h index 85c5b88f51..a39b52c296 100644 --- a/engines/neverhood/module2700.h +++ b/engines/neverhood/module2700.h @@ -64,13 +64,34 @@ protected: Sprite *_class519; Sprite *_class518; Sprite *_sprite1; - //NRect _rect; int _which1, _which2; NPointArray *_trackPoints; uint32 handleMessage42F500(int messageNum, const MessageParam ¶m, Entity *sender); uint32 handleMessage42F600(int messageNum, const MessageParam ¶m, Entity *sender); }; +class Scene2702 : public Scene { +public: + Scene2702(NeverhoodEngine *vm, Module *parentModule, int which); +protected: + Class521 *_class521; + Sprite *_class437; + Sprite *_class517; + Sprite *_class520; + Sprite *_class519; + int16 _newTrackDestX; + int _currTrackIndex, _newTrackIndex; + int _count; + bool _flag1; + SceneInfo2700 *_sceneInfos[2][3]; + SceneInfo2700 **_currSceneInfos; + NPointArray *_trackPoints; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void findClosestTrack(NPoint pt); + void changeTrack(); +}; + class Scene2704 : public Scene { public: Scene2704(NeverhoodEngine *vm, Module *parentModule, int which, uint32 sceneInfoId, int16 value, |