MACVENTURE: Migrate engine to Path

This commit is contained in:
Le Philousophe 2023-10-31 23:21:39 +01:00 committed by Eugene Sandulenko
parent 8e05d9c349
commit cd9c525b6d
8 changed files with 21 additions and 21 deletions

View File

@ -31,11 +31,11 @@
namespace MacVenture {
Container::Container(Common::String filename) {
Container::Container(const Common::Path &filename) {
_filename = filename;
if (!_file.open(_filename)) {
error("CONTAINER: Could not open %s", _filename.c_str());
error("CONTAINER: Could not open %s", _filename.toString().c_str());
}
_res = _file.readStream(_file.size());

View File

@ -48,7 +48,7 @@ typedef uint32 ContainerHeader;
class Container {
public:
Container(Common::String filename);
Container(const Common::Path &filename);
~Container();
public:
@ -75,7 +75,7 @@ protected:
Common::Array<uint8> _lens; // huffman lengths
Common::Array<ItemGroup> _groups;
Common::String _filename;
Common::Path _filename;
Common::File _file;
Common::SeekableReadStream *_res;

View File

@ -37,7 +37,7 @@
namespace MacVenture {
#define MACVENTURE_DATA_BUNDLE Common::String("macventure.dat")
#define MACVENTURE_DATA_BUNDLE "macventure.dat"
struct BorderName {
MVWindowType type;
@ -75,15 +75,15 @@ Common::String windowTypeName(MVWindowType windowType) {
void MacVentureEngine::loadDataBundle() {
_dataBundle = Common::makeZipArchive(MACVENTURE_DATA_BUNDLE);
if (!_dataBundle) {
error("ENGINE: Couldn't load data bundle '%s'.", MACVENTURE_DATA_BUNDLE.c_str());
error("ENGINE: Couldn't load data bundle '%s'.", MACVENTURE_DATA_BUNDLE);
}
}
Common::SeekableReadStream *MacVentureEngine::getBorderFile(MVWindowType windowType, bool isActive) {
Common::String filename = windowTypeName(windowType);
filename += (isActive ? "_act.bmp" : "_inac.bmp");
Common::Path filename(windowTypeName(windowType));
filename.appendInPlace(isActive ? "_act.bmp" : "_inac.bmp");
if (!_dataBundle->hasFile(filename)) {
warning("Missing border file '%s' in data bundle", filename.c_str());
warning("Missing border file '%s' in data bundle", filename.toString().c_str());
return nullptr;
}

View File

@ -457,7 +457,7 @@ Common::String MacVentureEngine::getUserInput() {
}
Common::String MacVentureEngine::getStartGameFileName() {
Common::Path MacVentureEngine::getStartGameFileName() {
Common::SeekableReadStream *res;
res = _resourceManager->getResource(MKTAG('S', 'T', 'R', ' '), kStartGameFilenameID);
if (!res)
@ -474,7 +474,7 @@ Common::String MacVentureEngine::getStartGameFileName() {
delete[] fileName;
delete res;
return result;
return Common::Path(result);
}
const GlobalSettings& MacVentureEngine::getGlobalSettings() const {
@ -956,11 +956,11 @@ Common::String MacVentureEngine::getCommandsPausedString() const {
return Common::String("Click to continue");
}
Common::String MacVentureEngine::getFilePath(FilePathID id) const {
Common::Path MacVentureEngine::getFilePath(FilePathID id) const {
if (id <= 3) { // We don't want a file in the subdirectory
return _filenames->getString(id);
return Common::Path(_filenames->getString(id));
} else { // We want a game file
return _filenames->getString(3) + "/" + _filenames->getString(id);
return Common::Path(_filenames->getString(3) + "/" + _filenames->getString(id));
}
}

View File

@ -242,12 +242,12 @@ public:
Common::String getUserInput();
// Data retrieval
Common::String getStartGameFileName();
Common::Path getStartGameFileName();
bool isPaused();
bool needsClickToContinue();
Common::String getCommandsPausedString() const;
const GlobalSettings &getGlobalSettings() const;
Common::String getFilePath(FilePathID id) const;
Common::Path getFilePath(FilePathID id) const;
bool isOldText() const;
const HuffmanLists *getDecodingHuffman() const;
uint32 randBetween(uint32 min, uint32 max);

View File

@ -38,10 +38,10 @@ namespace MacVenture {
// SoundManager
SoundManager::SoundManager(MacVentureEngine *engine, Audio::Mixer *mixer) {
_container = nullptr;
Common::String filename = engine->getFilePath(kSoundPathID);
Common::Path filename = engine->getFilePath(kSoundPathID);
_container = new Container(filename);
_mixer = mixer;
debugC(1, kMVDebugSound, "Created sound manager with file %s", filename.c_str());
debugC(1, kMVDebugSound, "Created sound manager with file %s", filename.toString().c_str());
}
SoundManager::~SoundManager() {

View File

@ -65,14 +65,14 @@ void World::startNewGame() {
if (_saveGame)
delete _saveGame;
if ((_startGameFileName = _engine->getStartGameFileName()) == "")
if ((_startGameFileName = _engine->getStartGameFileName()).empty())
error("WORLD: Could not load initial game configuration");
Common::File saveGameFile;
if (!saveGameFile.open(_startGameFileName))
error("WORLD: Could not load initial game configuration");
debugC(2, kMVDebugMain, "Loading save game state from %s", _startGameFileName.c_str());
debugC(2, kMVDebugMain, "Loading save game state from %s", _startGameFileName.toString().c_str());
Common::SeekableReadStream *saveGameRes = saveGameFile.readStream(saveGameFile.size());
_saveGame = new SaveGame(_engine, saveGameRes);

View File

@ -131,7 +131,7 @@ private:
MacVentureEngine *_engine;
Common::MacResManager *_resourceManager;
Common::String _startGameFileName;
Common::Path _startGameFileName;
SaveGame *_saveGame;