From 53029635b13c6581031ecae0ed9af841bfbeb3ab Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 9 Jan 2010 02:01:58 +0200 Subject: WAGE: Load scene scripts too. Signed-off-by: Eugene Sandulenko --- engines/wage/macresman.cpp | 22 +++++++++++++++++++++- engines/wage/macresman.h | 3 ++- engines/wage/module.mk | 1 + engines/wage/scene.h | 5 +++-- engines/wage/world.cpp | 7 ++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/engines/wage/macresman.cpp b/engines/wage/macresman.cpp index 0dce789874..02ea6c9156 100644 --- a/engines/wage/macresman.cpp +++ b/engines/wage/macresman.cpp @@ -141,6 +141,26 @@ MacResIDArray MacResManager::getResIDArray(const char *typeID) { return res; } +char *MacResManager::getResName(const char *typeID, int16 resID) { + int i; + int typeNum = -1; + + for (i = 0; i < _resMap.numTypes; i++) + if (strcmp(_resTypes[i].id, typeID) == 0) { + typeNum = i; + break; + } + + if (typeNum == -1) + return NULL; + + for (i = 0; i < _resTypes[typeNum].items; i++) + if (_resLists[typeNum][i].id == resID) + return _resLists[typeNum][i].name; + + return NULL; +} + byte *MacResManager::getResource(const char *typeID, int16 resID, int *size) { int i; int typeNum = -1; @@ -226,7 +246,7 @@ void MacResManager::readMap() { _resFile.seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset); len = _resFile.readByte(); - _resLists[i][j].name = new byte[len + 1]; + _resLists[i][j].name = new char[len + 1]; _resLists[i][j].name[len] = 0; _resFile.read(_resLists[i][j].name, len); } diff --git a/engines/wage/macresman.h b/engines/wage/macresman.h index 58635ae1f4..c09f4f7a6d 100644 --- a/engines/wage/macresman.h +++ b/engines/wage/macresman.h @@ -39,6 +39,7 @@ public: MacResManager(Common::String fileName); ~MacResManager(); byte *getResource(const char *typeID, int16 resID, int *size); + char *getResName(const char *typeID, int16 resID); void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h, int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize); @@ -69,7 +70,7 @@ private: int16 nameOffset; byte attr; int32 dataOffset; - byte *name; + char *name; }; typedef Resource *ResPtr; diff --git a/engines/wage/module.mk b/engines/wage/module.mk index 6f875f8e14..f43886cbe4 100644 --- a/engines/wage/module.mk +++ b/engines/wage/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ designed.o \ detection.o \ macresman.o \ + scene.o \ script.o \ sound.o \ util.o \ diff --git a/engines/wage/scene.h b/engines/wage/scene.h index c239faab5a..509833af0f 100644 --- a/engines/wage/scene.h +++ b/engines/wage/scene.h @@ -51,7 +51,6 @@ public: RANDOM = 1 }; -private: Script *_script; String _text; Common::Rect *_textBounds; @@ -68,7 +67,9 @@ private: Common::List _objs; Common::List _chrs; -public: + Scene() {} + Scene(String name, byte *data); + Common::Rect *getTextBounds() { return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds); } diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index d897d9e9af..5fd46357bb 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -81,7 +81,12 @@ bool World::loadWorld(MacResManager *resMan) { resArray = resMan->getResIDArray("ASCN"); for (iter = resArray.begin(); iter != resArray.end(); ++iter) { - + res = resMan->getResource("ASCND", *iter, &resSize); + Scene *scene = new Scene(resMan->getResName("ASCN", *iter), res); + + res = resMan->getResource("ACOD", *iter, &resSize); + if (res != NULL) + scene->_script = new Script(res); } -- cgit v1.2.3