diff --git a/engines/macventure/container.h b/engines/macventure/container.h index e960ddb9c39..0c6a41ee177 100644 --- a/engines/macventure/container.h +++ b/engines/macventure/container.h @@ -42,7 +42,7 @@ typedef uint32 ContainerHeader; class Container { public: - Container(char *filename) { + Container(const char *filename) { if (!_file.open(filename)) error("Could not open %s", filename); diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 92ae709b5ed..821a7869243 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -53,6 +53,10 @@ MacVentureEngine::~MacVentureEngine() { delete _rnd; delete _debugger; delete _gui; + + if (_filenames) { + delete _filenames; + } } Common::Error MacVentureEngine::run() { @@ -72,6 +76,10 @@ Common::Error MacVentureEngine::run() { if (!loadGlobalSettings()) error("Could not load the engine settings"); + // Engine-wide loading + _filenames = new StringTable(this, _resourceManager, kFilenamesStringTableID); + + // Big class instantiation _gui = new Gui(this, _resourceManager); _world = new World(this, _resourceManager); @@ -96,7 +104,7 @@ void MacVentureEngine::requestUnpause() { _paused = false; } -const GlobalSettings& MacVentureEngine::getGlobalSettings() { +const GlobalSettings& MacVentureEngine::getGlobalSettings() const { return _globalSettings; } @@ -106,7 +114,7 @@ bool MacVentureEngine::isPaused() { return _paused; } -Common::String MacVentureEngine::getCommandsPausedString() { +Common::String MacVentureEngine::getCommandsPausedString() const { return Common::String("Click to continue"); } @@ -127,6 +135,15 @@ void MacVentureEngine::processEvents() { } } +Common::String MacVentureEngine::getFilePath(FilePathID id) const { + const Common::Array *names = _filenames->getStrings(); + if (id <= 3) { // We don't want a file in the subdirectory + return Common::String((*names)[id]); + } else { // We want a game file + return Common::String((*names)[3] + "/" + (*names)[id]); + } +} + // Data loading bool MacVentureEngine::loadGlobalSettings() { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 3a20bbe2a85..d4f1a33fb99 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -32,6 +32,7 @@ #include "macventure/gui.h" #include "macventure/world.h" +#include "macventure/stringtable.h" struct ADGameDescription; @@ -65,6 +66,18 @@ enum { kStartGameFilenameID = 0x85 }; +enum FilePathID { + kMCVID = 1, + kTitlePathID = 2, + kSubdirPathID = 3, + kObjectPathID = 4, + kFilterPathID = 5, + kTextPathID = 6, + kGraphicPathID = 7, + kSoundPathID = 8 +}; + + struct GlobalSettings { uint16 numObjects; // number of game objects defined uint16 numGlobals; // number of globals defined @@ -99,8 +112,9 @@ public: // Data retrieval bool isPaused(); - Common::String getCommandsPausedString(); - const GlobalSettings& getGlobalSettings(); + Common::String getCommandsPausedString() const; + const GlobalSettings& getGlobalSettings() const; + Common::String getFilePath(FilePathID id) const; private: void processEvents(); @@ -121,6 +135,7 @@ private: // Attributes // Engine state GlobalSettings _globalSettings; + StringTable *_filenames; bool _shouldQuit; bool _paused; diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index 68faa0a5d1b..cdc0e1682e0 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -19,12 +19,8 @@ World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { _saveGame = new SaveGame(_engine, saveGameRes); - _objectConstants = new Container("Shadowgate II/Shadow Graphic"); - - uint32 size = _objectConstants->getItemByteSize(2); - char * ob1 = new char[size]; - _objectConstants->getItem(2, ob1); - + _objectConstants = new Container(_engine->getFilePath(kObjectPathID).c_str()); + delete saveGameRes; saveGameFile.close(); } diff --git a/engines/macventure/world.h b/engines/macventure/world.h index 38eb4bbc9dd..eed7b50363e 100644 --- a/engines/macventure/world.h +++ b/engines/macventure/world.h @@ -66,6 +66,7 @@ private: SaveGame *_saveGame; Container *_objectConstants; + Container *_gameText; };