diff options
author | Paul Gilbert | 2011-04-25 17:06:35 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-04-25 17:06:35 +1000 |
commit | 1d58ccac8172d81c4e4a983e148ebd7929b9a5a5 (patch) | |
tree | 6c7765c2216c5101ebfbb3e842fc792b096aa8b8 | |
parent | de5ec741ffbc491ec33100f7b60d1e4928e8f302 (diff) | |
download | scummvm-rg350-1d58ccac8172d81c4e4a983e148ebd7929b9a5a5.tar.gz scummvm-rg350-1d58ccac8172d81c4e4a983e148ebd7929b9a5a5.tar.bz2 scummvm-rg350-1d58ccac8172d81c4e4a983e148ebd7929b9a5a5.zip |
TSAGE: Combined the resource files into a single generic overall ResourceManager
-rw-r--r-- | engines/tsage/converse.cpp | 8 | ||||
-rw-r--r-- | engines/tsage/core.cpp | 26 | ||||
-rw-r--r-- | engines/tsage/dialogs.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/events.cpp | 8 | ||||
-rw-r--r-- | engines/tsage/globals.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/globals.h | 4 | ||||
-rw-r--r-- | engines/tsage/graphics.cpp | 12 | ||||
-rw-r--r-- | engines/tsage/resources.cpp | 116 | ||||
-rw-r--r-- | engines/tsage/resources.h | 28 | ||||
-rw-r--r-- | engines/tsage/ringworld_scenes10.cpp | 4 | ||||
-rw-r--r-- | engines/tsage/ringworld_scenes3.cpp | 4 | ||||
-rw-r--r-- | engines/tsage/scenes.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/tsage.cpp | 17 | ||||
-rw-r--r-- | engines/tsage/tsage.h | 2 |
14 files changed, 175 insertions, 60 deletions
diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index 57c5c48975..8d0262485b 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -304,7 +304,7 @@ void SequenceManager::attached(EventHandler *newOwner, EventHandler *fmt, va_lis // Get the sequence number to use _resNum = va_arg(va, int); - byte *seqData = _vm->_dataManager->getResource(RES_SEQUENCE, _resNum, 0); + byte *seqData = _resourceManager->getResource(RES_SEQUENCE, _resNum, 0); uint seqSize = _vm->_memoryManager.getSize(seqData); _sequenceData.resize(seqSize); @@ -340,7 +340,7 @@ void SequenceManager::setMessage(int resNum, int lineNum, int color, const Commo _sceneText._width = width; // Get the display message - Common::String msg = _vm->_dataManager->getMessage(resNum, lineNum); + Common::String msg = _resourceManager->getMessage(resNum, lineNum); // Get the needed rect, and move it to the desired position Rect textRect; @@ -560,7 +560,7 @@ void StripManager::reset() { void StripManager::load() { // Get the script - byte *script = _vm->_dataManager->getResource(RES_STRIP, _stripNum, 2); + byte *script = _resourceManager->getResource(RES_STRIP, _stripNum, 2); uint scriptSize = _vm->_memoryManager.getSize(script); _script.resize(scriptSize); @@ -569,7 +569,7 @@ void StripManager::load() { DEALLOCATE(script); // Get the object list - byte *obj44List = _vm->_dataManager->getResource(RES_STRIP, _stripNum, 1); + byte *obj44List = _resourceManager->getResource(RES_STRIP, _stripNum, 1); int dataSize = _vm->_memoryManager.getSize(obj44List); assert((dataSize % 0x44) == 0); diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 1b38599df1..5aa33b5467 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -51,7 +51,7 @@ InvObject::InvObject(int sceneNumber, int rlbNum, int cursorNum, CursorType curs // Decode the image for the inventory item to get it's display bounds uint size; - byte *imgData = _vm->_dataManager->getSubResource(_displayResNum, _rlbNum, _cursorNum, &size); + byte *imgData = _resourceManager->getSubResource(_displayResNum, _rlbNum, _cursorNum, &size); GfxSurface s = surfaceFromRes(imgData); _bounds = s.getBounds(); @@ -1240,7 +1240,7 @@ ScenePalette::ScenePalette(int paletteNum) { } bool ScenePalette::loadPalette(int paletteNum) { - byte *palData = _vm->_dataManager->getResource(RES_PALETTE, paletteNum, 0, true); + byte *palData = _resourceManager->getResource(RES_PALETTE, paletteNum, 0, true); if (!palData) return false; @@ -1481,7 +1481,7 @@ bool SceneItem::contains(const Common::Point &pt) { } void SceneItem::display(int resNum, int lineNum, ...) { - Common::String msg = !resNum ? Common::String() : _vm->_dataManager->getMessage(resNum, lineNum); + Common::String msg = !resNum ? Common::String() : _resourceManager->getMessage(resNum, lineNum); if (_globals->_sceneObjects->contains(&_globals->_sceneText)) { _globals->_sceneText.remove(); @@ -2646,7 +2646,7 @@ void Visage::setVisage(int resNum, int rlbNum) { _resNum = resNum; _rlbNum = rlbNum; DEALLOCATE(_data); - _data = _vm->_dataManager->getResource(RES_VISAGE, resNum, rlbNum); + _data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum); assert(_data); } } @@ -2736,7 +2736,7 @@ void Player::synchronise(Serialiser &s) { Region::Region(int resNum, int rlbNum, ResourceType ctlType) { _regionId = rlbNum; - byte *regionData = _vm->_dataManager->getResource(ctlType, resNum, rlbNum); + byte *regionData = _resourceManager->getResource(ctlType, resNum, rlbNum); assert(regionData); // Set the region bounds @@ -2948,7 +2948,7 @@ void Region::uniteRect(const Rect &rect) { void SceneRegions::load(int sceneNum) { clear(); - byte *regionData = _vm->_dataManager->getResource(RES_CONTROL, sceneNum, 9999, true); + byte *regionData = _resourceManager->getResource(RES_CONTROL, sceneNum, 9999, true); if (regionData) { int regionCount = READ_LE_UINT16(regionData); @@ -3212,7 +3212,7 @@ void WalkRegions::load(int sceneNum) { clear(); _resNum = sceneNum; - byte *regionData = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 1, true); + byte *regionData = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 1, true); if (!regionData) { // No data, so return _resNum = -1; @@ -3223,7 +3223,7 @@ void WalkRegions::load(int sceneNum) { int dataSize; // Load the field 18 list - dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 2); + dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 2); dataSize = _vm->_memoryManager.getSize(dataP); assert(dataSize % 10 == 0); @@ -3237,7 +3237,7 @@ void WalkRegions::load(int sceneNum) { DEALLOCATE(dataP); // Load the idx list - dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 3); + dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 3); dataSize = _vm->_memoryManager.getSize(dataP); assert(dataSize % 2 == 0); @@ -3248,7 +3248,7 @@ void WalkRegions::load(int sceneNum) { DEALLOCATE(dataP); // Load the secondary idx list - dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 4); + dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 4); dataSize = _vm->_memoryManager.getSize(dataP); assert(dataSize % 2 == 0); @@ -3259,7 +3259,7 @@ void WalkRegions::load(int sceneNum) { DEALLOCATE(dataP); // Handle the loading of the actual regions themselves - dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 5); + dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 5); byte *pWalkRegion = regionData + 16; byte *srcP = dataP; @@ -3305,7 +3305,7 @@ void ScenePriorities::load(int resNum) { _resNum = resNum; clear(); - byte *regionData = _vm->_dataManager->getResource(RES_PRIORITY, resNum, 9999, true); + byte *regionData = _resourceManager->getResource(RES_PRIORITY, resNum, 9999, true); if (regionData) { int regionCount = READ_LE_UINT16(regionData); @@ -3719,7 +3719,7 @@ void Game::restart() { void Game::endGame(int resNum, int lineNum) { _globals->_events.setCursor(CURSOR_WALK); - Common::String msg = _vm->_dataManager->getMessage(resNum, lineNum); + Common::String msg = _resourceManager->getMessage(resNum, lineNum); bool savesExist = _saver->savegamesExist(); if (!savesExist) { diff --git a/engines/tsage/dialogs.cpp b/engines/tsage/dialogs.cpp index 688f266133..c73263ce17 100644 --- a/engines/tsage/dialogs.cpp +++ b/engines/tsage/dialogs.cpp @@ -139,7 +139,7 @@ void RightClickButton::highlight() { _savedButton = Surface_getArea(_globals->gfxManager().getSurface(), _bounds); uint size; - byte *imgData = _vm->_dataManager->getSubResource(7, 2, _buttonIndex, &size); + byte *imgData = _resourceManager->getSubResource(7, 2, _buttonIndex, &size); GfxSurface btnSelected = surfaceFromRes(imgData); _globals->gfxManager().copyFrom(btnSelected, _bounds.left, _bounds.top); diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 83cafcaac5..a92cbb9df9 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -159,25 +159,25 @@ void EventsClass::setCursor(CursorType cursorType) { switch (cursorType) { case CURSOR_CROSSHAIRS: // Crosshairs cursor - cursor = _vm->_dataManager->getSubResource(4, 1, 6, &size); + cursor = _resourceManager->getSubResource(4, 1, 6, &size); _globals->setFlag(122); break; case CURSOR_LOOK: // Look cursor - cursor = _vm->_dataManager->getSubResource(4, 1, 5, &size); + cursor = _resourceManager->getSubResource(4, 1, 5, &size); _currentCursor = CURSOR_LOOK; break; case CURSOR_USE: // Use cursor - cursor = _vm->_dataManager->getSubResource(4, 1, 4, &size); + cursor = _resourceManager->getSubResource(4, 1, 4, &size); _currentCursor = CURSOR_USE; break; case CURSOR_TALK: // Talk cursor - cursor = _vm->_dataManager->getSubResource(4, 1, 3, &size); + cursor = _resourceManager->getSubResource(4, 1, 3, &size); _currentCursor = CURSOR_TALK; break; diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index 7f41ab0978..808806bed8 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -24,10 +24,12 @@ */ #include "tsage/globals.h" +#include "tsage/tsage.h" namespace tSage { Globals *_globals = NULL; +ResourceManager *_resourceManager = NULL; /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index 6fe8e6295a..b8ff441117 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -95,6 +95,10 @@ public: extern Globals *_globals; +// Note: Currently this can't be part of the _globals structure, since it needs to be constructed +// prior to many of the fields in Globals execute their constructors +extern ResourceManager *_resourceManager; + } // End of namespace tSage #endif diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index 77316d2d7d..b99fcb616a 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -122,7 +122,7 @@ GfxSurface surfaceFromRes(const byte *imgData) { GfxSurface surfaceFromRes(int resNum, int rlbNum, int subNum) { uint size; - byte *imgData = _vm->_dataManager->getSubResource(resNum, rlbNum, subNum, &size); + byte *imgData = _resourceManager->getSubResource(resNum, rlbNum, subNum, &size); GfxSurface surface = surfaceFromRes(imgData); DEALLOCATE(imgData); @@ -390,7 +390,7 @@ void GfxSurface::loadScreenSection(Graphics::Surface &dest, int xHalf, int yHalf if (xSection < xHalfCount && ySection < yHalfCount) { int rlbNum = xSection * yHalfCount + ySection; - byte *data = _vm->_dataManager->getResource(RES_BITMAP, screenNum, rlbNum); + byte *data = _resourceManager->getResource(RES_BITMAP, screenNum, rlbNum); for (int y = 0; y < updateRect.height(); ++y) { byte *pSrc = data + y * 160; @@ -713,7 +713,7 @@ void GfxImage::setDefaults() { // Decode the image uint size; - byte *imgData = _vm->_dataManager->getSubResource(_resNum, _rlbNum, _cursorNum, &size); + byte *imgData = _resourceManager->getSubResource(_resNum, _rlbNum, _cursorNum, &size); _surface = surfaceFromRes(imgData); DEALLOCATE(imgData); @@ -1074,7 +1074,7 @@ void GfxManager::setDialogPalette() { // Get the main palette information byte palData[256 * 3]; uint count, start; - _vm->_dataManager->getPalette(0, &palData[0], &start, &count); + _resourceManager->getPalette(0, &palData[0], &start, &count); g_system->getPaletteManager()->setPalette(&palData[0], start, count); // Miscellaneous @@ -1133,9 +1133,9 @@ void GfxFont::setFontNumber(uint32 fontNumber) { _fontNumber = fontNumber; - _fontData = _vm->_tSageManager->getResource(RES_FONT, _fontNumber, 0, true); + _fontData = _resourceManager->getResource(RES_FONT, _fontNumber, 0, true); if (!_fontData) - _fontData = _vm->_dataManager->getResource(RES_FONT, _fontNumber, 0); + _fontData = _resourceManager->getResource(RES_FONT, _fontNumber, 0); _numChars = READ_LE_UINT16(_fontData + 4); _fontSize.y = READ_LE_UINT16(_fontData + 6); diff --git a/engines/tsage/resources.cpp b/engines/tsage/resources.cpp index 21397f238a..5320a573b2 100644 --- a/engines/tsage/resources.cpp +++ b/engines/tsage/resources.cpp @@ -29,6 +29,7 @@ #include "common/stack.h" #include "common/util.h" #include "tsage/resources.h" +#include "tsage/tsage.h" namespace tSage { @@ -134,7 +135,7 @@ uint16 BitReader::readToken() { /*-------------------------------------------------------------------------*/ -RlbManager::RlbManager(MemoryManager &memManager, const Common::String filename) : +TLib::TLib(MemoryManager &memManager, const Common::String &filename) : _memoryManager(memManager) { // If the resource strings list isn't yet loaded, load them @@ -154,11 +155,11 @@ RlbManager::RlbManager(MemoryManager &memManager, const Common::String filename) loadIndex(); } -RlbManager::~RlbManager() { +TLib::~TLib() { _resStrings.clear(); } -void RlbManager::loadSection(uint32 fileOffset) { +void TLib::loadSection(uint32 fileOffset) { _resources.clear(); _file.seek(fileOffset); _sections.fileOffset = fileOffset; @@ -197,7 +198,7 @@ struct DecodeReference { /** * Gets a resource from the currently loaded section */ -byte *RlbManager::getResource(uint16 id, bool suppressErrors) { +byte *TLib::getResource(uint16 id, bool suppressErrors) { // Scan for an entry for the given Id ResourceEntry *re= NULL; ResourceList::iterator i; @@ -307,7 +308,7 @@ byte *RlbManager::getResource(uint16 id, bool suppressErrors) { /** * Finds the correct section and loads the specified resource within it */ -byte *RlbManager::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors) { +byte *TLib::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors) { SectionList::iterator i = _sections.begin(); while ((i != _sections.end()) && ((*i).resType != resType || (*i).resNum != resNum)) ++i; @@ -322,7 +323,7 @@ byte *RlbManager::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum return getResource(rlbNum, suppressErrors); } -void RlbManager::loadIndex() { +void TLib::loadIndex() { uint16 resNum, configId, fileOffset; // Load the root resources section @@ -356,10 +357,11 @@ void RlbManager::loadIndex() { * * @paletteNum Specefies the palette number */ -void RlbManager::getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries) { +bool TLib::getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries) { // Get the specified palette - byte *dataIn = getResource(RES_PALETTE, 0, paletteNum); - assert(dataIn); + byte *dataIn = getResource(RES_PALETTE, 0, paletteNum, true); + if (!dataIn) + return false; *startNum = READ_LE_UINT16(dataIn); *numEntries = READ_LE_UINT16(dataIn + 2); @@ -369,12 +371,18 @@ void RlbManager::getPalette(int paletteNum, byte *palData, uint *startNum, uint Common::copy(&dataIn[6], &dataIn[6 + *numEntries * 3], palData); _memoryManager.deallocate(dataIn); + return true; } -byte *RlbManager::getSubResource(int resNum, int rlbNum, int index, uint *size) { +byte *TLib::getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors) { // Get the specified image set byte *dataIn = getResource(RES_VISAGE, resNum, rlbNum); - assert(dataIn); + if (!dataIn) { + if (suppressErrors) + return NULL; + + error("Unknown sub resource %d/%d index %d", resNum, rlbNum, index); + } int numEntries = READ_LE_UINT16(dataIn); uint32 entryOffset = READ_LE_UINT32(dataIn + 2 + (index - 1) * 4); @@ -393,9 +401,14 @@ byte *RlbManager::getSubResource(int resNum, int rlbNum, int index, uint *size) /** * Retrieves a given message resource, and returns the specified message number */ -Common::String RlbManager::getMessage(int resNum, int lineNum) { +Common::String TLib::getMessage(int resNum, int lineNum, bool suppressErrors) { byte *msgData = getResource(RES_MESSAGE, resNum, 0); - assert(msgData); + if (!msgData) { + if (suppressErrors) + return Common::String(); + + error("Unknown message %d line %d", resNum, lineNum); + } const char *srcP = (const char *)msgData; while (lineNum-- > 0) @@ -406,4 +419,81 @@ Common::String RlbManager::getMessage(int resNum, int lineNum) { return result; } +/*--------------------------------------------------------------------------*/ + +ResourceManager::~ResourceManager() { + for (uint idx = 0; idx < _libList.size(); ++idx) + delete _libList[idx]; +} + +void ResourceManager::addLib(const Common::String &libName) { + assert(_libList.size() < 5); + + _libList.push_back(new TLib(_vm->_memoryManager, libName)); +} + +byte *ResourceManager::getResource(uint16 id, bool suppressErrors) { + byte *result = NULL; + for (uint idx = 0; idx < _libList.size(); ++idx) { + result = _libList[idx]->getResource(id, true); + if (result) + return result; + } + + if (!result && !suppressErrors) + error("Could not find resource Id #%d", id); + return NULL; +} + +byte *ResourceManager::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors) { + byte *result = NULL; + for (uint idx = 0; idx < _libList.size(); ++idx) { + result = _libList[idx]->getResource(resType, resNum, rlbNum, true); + if (result) + return result; + } + + if (!result && !suppressErrors) + error("Unknown resource type %d num %d", resType, resNum); + return NULL; +} + +void ResourceManager::getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries, bool suppressErrors) { + for (uint idx = 0; idx < _libList.size(); ++idx) { + if (_libList[idx]->getPalette(paletteNum, palData, startNum, numEntries)) + return; + } + + if (!suppressErrors) + error("Unknown palette resource %d", paletteNum); + *numEntries = 0; +} + +byte *ResourceManager::getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors) { + byte *result = NULL; + for (uint idx = 0; idx < _libList.size(); ++idx) { + result = _libList[idx]->getSubResource(resNum, rlbNum, index, size, true); + if (result) + return result; + } + + if (!result && !suppressErrors) + error("Unknown resource %d/%d index %d", resNum, rlbNum, index); + return NULL; +} + +Common::String ResourceManager::getMessage(int resNum, int lineNum, bool suppressErrors) { + Common::String result; + + for (uint idx = 0; idx < _libList.size(); ++idx) { + result = _libList[idx]->getMessage(resNum, lineNum, true); + if (!result.empty()) + return result; + } + + if (!suppressErrors) + error("Unknown message %d line %d", resNum, lineNum); + return result; +} + } // end of namespace tSage diff --git a/engines/tsage/resources.h b/engines/tsage/resources.h index 2cf5069d36..b33cc37266 100644 --- a/engines/tsage/resources.h +++ b/engines/tsage/resources.h @@ -27,6 +27,7 @@ #define RING_RESOURCES_H #include "common/scummsys.h" +#include "common/array.h" #include "common/file.h" #include "common/list.h" #include "common/str.h" @@ -138,7 +139,7 @@ public: int numBits; }; -class RlbManager { +class TLib { private: Common::StringArray _resStrings; MemoryManager &_memoryManager; @@ -150,14 +151,29 @@ private: void loadSection(uint32 fileOffset); void loadIndex(); public: - RlbManager(MemoryManager &memManager, const Common::String filename); - ~RlbManager(); + TLib(MemoryManager &memManager, const Common::String &filename); + ~TLib(); byte *getResource(uint16 id, bool suppressErrors = false); byte *getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors = false); - void getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries); - byte *getSubResource(int resNum, int rlbNum, int index, uint *size); - Common::String getMessage(int resNum, int lineNum); + bool getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries); + byte *getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors = false); + Common::String getMessage(int resNum, int lineNum, bool suppressErrors = false); +}; + +class ResourceManager { +private: + Common::Array<TLib *> _libList; +public: + ~ResourceManager(); + + void addLib(const Common::String &libName); + + byte *getResource(uint16 id, bool suppressErrors = false); + byte *getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors = false); + void getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries, bool suppressErrors = false); + byte *getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors = false); + Common::String getMessage(int resNum, int lineNum, bool suppressErrors = false); }; diff --git a/engines/tsage/ringworld_scenes10.cpp b/engines/tsage/ringworld_scenes10.cpp index 5e0cabde6a..ecfb1f3847 100644 --- a/engines/tsage/ringworld_scenes10.cpp +++ b/engines/tsage/ringworld_scenes10.cpp @@ -1684,7 +1684,7 @@ void Scene9900::strAction2::signal() { _var3 = 0; // No break on purpose case 1: { - Common::String msg = _vm->_dataManager->getMessage(8030, _lineNum++); + Common::String msg = _resourceManager->getMessage(8030, _lineNum++); if (!msg.compareTo("LASTCREDIT")) { if (_var3 == 0) { // Not used? @@ -1721,7 +1721,7 @@ void Scene9900::strAction2::signal() { _txtArray2[_txtArray1Index]._fontNumber = 2; _txtArray2[_txtArray1Index]._color1 = 23; - msg = _vm->_dataManager->getMessage(8030, _lineNum++); + msg = _resourceManager->getMessage(8030, _lineNum++); _txtArray2[_txtArray1Index].setup(msg); _txtArray2[_txtArray1Index]._field7A = 20; _txtArray2[_txtArray1Index]._moveDiff.y = 2; diff --git a/engines/tsage/ringworld_scenes3.cpp b/engines/tsage/ringworld_scenes3.cpp index 6205571f34..26cddc9964 100644 --- a/engines/tsage/ringworld_scenes3.cpp +++ b/engines/tsage/ringworld_scenes3.cpp @@ -4874,7 +4874,7 @@ void Scene2310::postInit(SceneObjectList *OwnerList) { void Scene2310::signal() { switch (_sceneMode++) { case 0: { - Common::String fmtString = _vm->_dataManager->getMessage(2300, 22); + Common::String fmtString = _resourceManager->getMessage(2300, 22); Common::String msg = Common::String::format(fmtString.c_str(), _pageList[_pageIndex]._pageNumber); _sceneText._width = 280; @@ -4887,7 +4887,7 @@ void Scene2310::signal() { break; } case 1: { - Common::String msg = _vm->_dataManager->getMessage(2300, 23); + Common::String msg = _resourceManager->getMessage(2300, 23); _sceneText.setup(msg); _sceneText.setPriority2(255); _sceneText.setPosition(Common::Point(30, 170)); diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index 8454c7ebd4..e316a601fb 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -292,7 +292,7 @@ void Scene::loadSceneData(int sceneNum) { _globals->_sceneManager._scene->_activeScreenNumber = sceneNum; // Get the basic scene size - byte *data = _vm->_dataManager->getResource(RES_BITMAP, sceneNum, 9999); + byte *data = _resourceManager->getResource(RES_BITMAP, sceneNum, 9999); _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); _globals->_sceneManager._scene->_sceneBounds.contain(_backgroundBounds); DEALLOCATE(data); diff --git a/engines/tsage/tsage.cpp b/engines/tsage/tsage.cpp index 9d5d7223cb..ba88a0b4a0 100644 --- a/engines/tsage/tsage.cpp +++ b/engines/tsage/tsage.cpp @@ -46,7 +46,6 @@ TSageEngine::TSageEngine(OSystem *system, const tSageGameDescription *gameDesc) _vm = this; DebugMan.addDebugChannel(kRingDebugScripts, "scripts", "Scripts debugging"); _debugger = new Debugger(); - _dataManager = NULL; } Common::Error TSageEngine::init() { @@ -69,19 +68,25 @@ bool TSageEngine::hasFeature(EngineFeature f) const { } void TSageEngine::initialise() { - _tSageManager = new RlbManager(_memoryManager, "tsage.rlb"); - _dataManager = new RlbManager(_memoryManager, "ring.rlb"); - _saver = new Saver(); + + // Set up the resource manager + _resourceManager = new ResourceManager(); + if (_vm->getFeatures() & GF_DEMO) { + _resourceManager->addLib("DEMORING.RLB"); + } else { + _resourceManager->addLib("RING.RLB"); + _resourceManager->addLib("TSAGE.RLB"); + } + _globals = new Globals(); _globals->gfxManager().setDefaults(); } void TSageEngine::deinitialise() { delete _globals; + delete _resourceManager; delete _saver; - delete _tSageManager; - delete _dataManager; } Common::Error TSageEngine::run() { diff --git a/engines/tsage/tsage.h b/engines/tsage/tsage.h index 25a99f094b..7be171c56a 100644 --- a/engines/tsage/tsage.h +++ b/engines/tsage/tsage.h @@ -74,8 +74,6 @@ public: MemoryManager _memoryManager; Debugger *_debugger; - RlbManager *_tSageManager; - RlbManager *_dataManager; const char *getGameId() const; uint32 getGameID() const; |