diff options
author | Filippos Karapetis | 2017-03-15 10:28:18 +0200 |
---|---|---|
committer | Filippos Karapetis | 2017-03-15 10:28:59 +0200 |
commit | e069605d25f0d6d3206c92367f57c57e0885d5dc (patch) | |
tree | 31fbc61d7f525f1cc78b918adf4f999bb4c21005 /engines | |
parent | 6c17fc85ad3de5689b055e193d89c60dd56c9095 (diff) | |
download | scummvm-rg350-e069605d25f0d6d3206c92367f57c57e0885d5dc.tar.gz scummvm-rg350-e069605d25f0d6d3206c92367f57c57e0885d5dc.tar.bz2 scummvm-rg350-e069605d25f0d6d3206c92367f57c57e0885d5dc.zip |
CHEWY: Initial work on speech for hotspot actions
Diffstat (limited to 'engines')
-rw-r--r-- | engines/chewy/cursor.cpp | 29 | ||||
-rw-r--r-- | engines/chewy/cursor.h | 9 | ||||
-rw-r--r-- | engines/chewy/events.cpp | 2 | ||||
-rw-r--r-- | engines/chewy/scene.cpp | 90 | ||||
-rw-r--r-- | engines/chewy/scene.h | 1 |
5 files changed, 114 insertions, 17 deletions
diff --git a/engines/chewy/cursor.cpp b/engines/chewy/cursor.cpp index 4795221e44..54496ef848 100644 --- a/engines/chewy/cursor.cpp +++ b/engines/chewy/cursor.cpp @@ -63,6 +63,35 @@ Cursor::~Cursor() { delete _cursorSprites; } +// TODO: This may need to be refactored, since in the original the user +// selects the cursor to use from a pop-up menu +CurrentCursor Cursor::getCurrentCursor() const { + switch (_curCursor) { + case 0: + case 1: + case 2: + case 3: + return kWalk; + case 4: + case 5: + case 6: + case 7: + return kUse; + case 13: + case 14: + case 15: + case 16: + return kLook; + case 17: + case 18: + case 19: + case 20: + return kTalk; + default: + return kOther; + } +} + void Cursor::setCursor(uint num, bool newCursor) { TAFChunk *cursor = _cursorSprites->getSprite(num); if (newCursor) diff --git a/engines/chewy/cursor.h b/engines/chewy/cursor.h index de5a707ca6..bb39abb463 100644 --- a/engines/chewy/cursor.h +++ b/engines/chewy/cursor.h @@ -30,6 +30,14 @@ namespace Chewy { class SpriteResource; class Font; +enum CurrentCursor { + kWalk, + kLook, + kUse, + kTalk, + kOther +}; + class Cursor { public: Cursor(); @@ -40,6 +48,7 @@ public: void hideCursor(); void animateCursor(); void nextCursor(); + CurrentCursor getCurrentCursor() const; private: uint _curCursor; diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp index 3da9da2803..532b1acce7 100644 --- a/engines/chewy/events.cpp +++ b/engines/chewy/events.cpp @@ -55,6 +55,8 @@ void Events::processEvents() { default: break; } + } else if (_event.type == Common::EVENT_LBUTTONUP) { + _vm->_scene->mouseClick(_event.mouse); } else if (_event.type == Common::EVENT_RBUTTONUP) { _vm->_cursor->nextCursor(); } else if (_event.type == Common::EVENT_MOUSEMOVE) { diff --git a/engines/chewy/scene.cpp b/engines/chewy/scene.cpp index 7f10b75025..df8dd66148 100644 --- a/engines/chewy/scene.cpp +++ b/engines/chewy/scene.cpp @@ -30,6 +30,7 @@ #include "chewy/graphics.h" #include "chewy/scene.h" #include "chewy/resource.h" +#include "chewy/sound.h" #include "chewy/text.h" #include "chewy/video/cfo_decoder.h" @@ -38,6 +39,7 @@ namespace Chewy { #define MAX_DETAILS 32 #define MAX_HOTSPOTS 50 #define MAX_AUTOMOVE 20 +#define MAX_SOUNDS 3 // Animated details - scene animations struct AnimatedDetails { @@ -76,6 +78,16 @@ struct Hotspot { Common::String desc; }; +struct RoomInfo { + byte roomNum; + byte picNum; + byte autoMoveCount; + byte loadTaf; + Common::String tafName; // 14 bytes + byte zoomFactor; + // 1 byte dummy +}; + struct AutoMove { int16 x; int16 y; @@ -83,6 +95,12 @@ struct AutoMove { // 1 byte dummy }; +struct HotspotSpeech { + int16 look; + int16 use; + int16 talk; +}; + struct SceneInfo { uint16 staticDetailsCount; uint16 animatedDetailsCount; @@ -90,16 +108,10 @@ struct SceneInfo { AnimatedDetails animatedDetails[MAX_DETAILS]; StaticDetails staticDetails[MAX_DETAILS]; Hotspot hotspot[MAX_HOTSPOTS]; - byte roomNum; - byte picNum; - byte autoMoveCount; - byte loadTaf; - Common::String tafName; // 14 bytes - byte zoomFactor; - // 1 byte dummy + RoomInfo roomInfo; AutoMove autoMove[MAX_AUTOMOVE]; - // MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO - // MAX_DETAILS * 3 = 96 bytes samples - TODO + HotspotSpeech hotspotSpeech[MAX_DETAILS]; + byte hotspotSound[MAX_DETAILS][MAX_SOUNDS]; }; Scene::Scene(ChewyEngine *vm) : _vm(vm) { @@ -155,6 +167,33 @@ void Scene::updateMouse(Common::Point coords) { } } +void Scene::mouseClick(Common::Point coords) { + // Static details + for (uint16 i = 0; i < MAX_HOTSPOTS; i++) { + //_vm->_graphics->drawRect(_sceneInfo->hotspot[i].rect, 0); // debug + if (_sceneInfo->hotspot[i].rect.contains(coords)) { + int sample = -1; + + switch (_vm->_cursor->getCurrentCursor()) { + case kLook: + sample = _sceneInfo->hotspotSpeech[i].look; + break; + case kUse: + sample = _sceneInfo->hotspotSpeech[i].use; + break; + case kTalk: + sample = _sceneInfo->hotspotSpeech[i].talk; + break; + default: + break; + } + + if (sample >= 0) + _vm->_sound->playSpeech(sample); + } + } +} + void Scene::loadSceneInfo() { const uint32 sceneInfoSize = 3784; const uint32 headerRDI = MKTAG('R', 'D', 'I', '\0'); @@ -230,15 +269,17 @@ void Scene::loadSceneInfo() { } } - _sceneInfo->roomNum = indexFile.readByte(); - _sceneInfo->picNum = indexFile.readByte(); - _sceneInfo->autoMoveCount = indexFile.readByte(); - _sceneInfo->loadTaf = indexFile.readByte(); + // Room info + _sceneInfo->roomInfo.roomNum = indexFile.readByte(); + _sceneInfo->roomInfo.picNum = indexFile.readByte(); + _sceneInfo->roomInfo.autoMoveCount = indexFile.readByte(); + _sceneInfo->roomInfo.loadTaf = indexFile.readByte(); + _sceneInfo->roomInfo.tafName = ""; for (int i = 0; i < 14; i++) - _sceneInfo->tafName += indexFile.readByte(); + _sceneInfo->roomInfo.tafName += indexFile.readByte(); - _sceneInfo->zoomFactor = indexFile.readByte(); + _sceneInfo->roomInfo.zoomFactor = indexFile.readByte(); indexFile.readByte(); // padding for (int i = 0; i < MAX_AUTOMOVE; i++) { @@ -246,10 +287,25 @@ void Scene::loadSceneInfo() { _sceneInfo->autoMove[i].y = indexFile.readSint16LE(); _sceneInfo->autoMove[i].spriteNum = indexFile.readByte(); indexFile.readByte(); // padding + if (i > _sceneInfo->roomInfo.autoMoveCount && !(_sceneInfo->autoMove[i].x <= 0 || _sceneInfo->autoMove[i].y <= 0)) + warning("Auto move %d should be unused, but it isn't (max auto move items are %d)", i, _sceneInfo->roomInfo.autoMoveCount); + } + + for (int i = 0; i < MAX_DETAILS; i++) { + // FIXME: These are all wrong... investigate why + _sceneInfo->hotspotSpeech[i].look = indexFile.readSint16LE(); + _sceneInfo->hotspotSpeech[i].use = indexFile.readSint16LE(); + _sceneInfo->hotspotSpeech[i].talk = indexFile.readSint16LE(); + } + + for (int i = 0; i < MAX_DETAILS; i++) { + _sceneInfo->hotspotSound[i][0] = indexFile.readSint16LE(); + _sceneInfo->hotspotSound[i][1] = indexFile.readSint16LE(); + _sceneInfo->hotspotSound[i][2] = indexFile.readSint16LE(); } - // MAX_DETAILS * 3 * 2 = 192 bytes voc - TODO: read these - // MAX_DETAILS * 3 = 96 bytes samples - TODO: read these + // TODO: We seem to be missing a chunk of data (186 bytes) from the end of + // the room info structure delete text; indexFile.close(); diff --git a/engines/chewy/scene.h b/engines/chewy/scene.h index c5b87ac7ae..bcbbf6761e 100644 --- a/engines/chewy/scene.h +++ b/engines/chewy/scene.h @@ -37,6 +37,7 @@ public: void change(uint scene); void draw(); void updateMouse(Common::Point coords); + void mouseClick(Common::Point coords); uint getCurScene() const { return _curScene; } |