mirror of
https://github.com/scummvm/scummvm.git
synced 2025-04-02 10:52:32 -04:00
COMPOSER: Migrate engine to Path
This commit is contained in:
parent
f3c7cd6393
commit
bbc4d51fc4
5 changed files with 20 additions and 18 deletions
|
@ -94,7 +94,7 @@ Common::Error ComposerEngine::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPlatform() == Common::kPlatformMacintosh) {
|
if (getPlatform() == Common::kPlatformMacintosh) {
|
||||||
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
const Common::FSNode gameDataDir(ConfMan.getPath("path"));
|
||||||
if (gameId == "sleepingcub")
|
if (gameId == "sleepingcub")
|
||||||
SearchMan.addSubDirectoryMatching(gameDataDir, "sleepcub");
|
SearchMan.addSubDirectoryMatching(gameDataDir, "sleepcub");
|
||||||
if (gameId == "princess")
|
if (gameId == "princess")
|
||||||
|
@ -348,14 +348,14 @@ Common::String ComposerEngine::getStringFromConfig(const Common::String §ion
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String ComposerEngine::getFilename(const Common::String §ion, uint id) {
|
Common::Path ComposerEngine::getFilename(const Common::String §ion, uint id) {
|
||||||
Common::String key = Common::String::format("%d", id);
|
Common::String key = Common::String::format("%d", id);
|
||||||
Common::String filename = getStringFromConfig(section, key);
|
Common::String filename = getStringFromConfig(section, key);
|
||||||
|
|
||||||
return mangleFilename(filename);
|
return mangleFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String ComposerEngine::mangleFilename(Common::String filename) {
|
Common::Path ComposerEngine::mangleFilename(Common::String filename) {
|
||||||
while (filename.size() && (filename[0] == '~' || filename[0] == ':' || filename[0] == '\\'))
|
while (filename.size() && (filename[0] == '~' || filename[0] == ':' || filename[0] == '\\'))
|
||||||
filename = filename.c_str() + 1;
|
filename = filename.c_str() + 1;
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ Common::String ComposerEngine::mangleFilename(Common::String filename) {
|
||||||
else
|
else
|
||||||
outFilename += filename[i];
|
outFilename += filename[i];
|
||||||
}
|
}
|
||||||
return outFilename;
|
return Common::Path(outFilename, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComposerEngine::loadLibrary(uint id) {
|
void ComposerEngine::loadLibrary(uint id) {
|
||||||
|
@ -395,9 +395,10 @@ void ComposerEngine::loadLibrary(uint id) {
|
||||||
unloadLibrary(library->_id);
|
unloadLibrary(library->_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String filename;
|
Common::Path path;
|
||||||
Common::String oldGroup = _bookGroup;
|
Common::String oldGroup = _bookGroup;
|
||||||
if (getGameType() == GType_ComposerV1) {
|
if (getGameType() == GType_ComposerV1) {
|
||||||
|
Common::String filename;
|
||||||
if (getPlatform() == Common::kPlatformMacintosh) {
|
if (getPlatform() == Common::kPlatformMacintosh) {
|
||||||
if (!id || _bookGroup.empty())
|
if (!id || _bookGroup.empty())
|
||||||
filename = getStringFromConfig("splash.rsc", "100");
|
filename = getStringFromConfig("splash.rsc", "100");
|
||||||
|
@ -410,7 +411,7 @@ void ComposerEngine::loadLibrary(uint id) {
|
||||||
else
|
else
|
||||||
filename = getStringFromConfig(_bookGroup, Common::String::format("%d", id));
|
filename = getStringFromConfig(_bookGroup, Common::String::format("%d", id));
|
||||||
}
|
}
|
||||||
filename = mangleFilename(filename);
|
path = mangleFilename(filename);
|
||||||
|
|
||||||
// bookGroup is the basename of the path.
|
// bookGroup is the basename of the path.
|
||||||
// TODO: tidy this up.
|
// TODO: tidy this up.
|
||||||
|
@ -432,7 +433,7 @@ void ComposerEngine::loadLibrary(uint id) {
|
||||||
} else {
|
} else {
|
||||||
if (!id)
|
if (!id)
|
||||||
id = atoi(getStringFromConfig("Common", "StartUp").c_str());
|
id = atoi(getStringFromConfig("Common", "StartUp").c_str());
|
||||||
filename = getFilename("Libs", id);
|
path = getFilename("Libs", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
|
@ -440,8 +441,8 @@ void ComposerEngine::loadLibrary(uint id) {
|
||||||
library._id = id;
|
library._id = id;
|
||||||
library._group = oldGroup;
|
library._group = oldGroup;
|
||||||
library._archive = new ComposerArchive();
|
library._archive = new ComposerArchive();
|
||||||
if (!library._archive->openFile(filename))
|
if (!library._archive->openFile(path))
|
||||||
error("failed to open '%s'", filename.c_str());
|
error("failed to open '%s'", path.toString(Common::Path::kNativeSeparator).c_str());
|
||||||
_libraries.push_front(library);
|
_libraries.push_front(library);
|
||||||
|
|
||||||
Library &newLib = _libraries.front();
|
Library &newLib = _libraries.front();
|
||||||
|
|
|
@ -219,8 +219,8 @@ private:
|
||||||
|
|
||||||
Common::String getSaveStateName(int slot) const override;
|
Common::String getSaveStateName(int slot) const override;
|
||||||
Common::String getStringFromConfig(const Common::String §ion, const Common::String &key);
|
Common::String getStringFromConfig(const Common::String §ion, const Common::String &key);
|
||||||
Common::String getFilename(const Common::String §ion, uint id);
|
Common::Path getFilename(const Common::String §ion, uint id);
|
||||||
Common::String mangleFilename(Common::String filename);
|
Common::Path mangleFilename(Common::String filename);
|
||||||
void loadLibrary(uint id);
|
void loadLibrary(uint id);
|
||||||
void unloadLibrary(uint id);
|
void unloadLibrary(uint id);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ Archive::~Archive() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Archive::openFile(const Common::String &fileName) {
|
bool Archive::openFile(const Common::Path &fileName) {
|
||||||
Common::SeekableReadStream *file
|
Common::SeekableReadStream *file
|
||||||
= Common::MacResManager::openFileOrDataFork(fileName);
|
= Common::MacResManager::openFileOrDataFork(fileName);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
Archive();
|
Archive();
|
||||||
virtual ~Archive();
|
virtual ~Archive();
|
||||||
|
|
||||||
bool openFile(const Common::String &fileName);
|
bool openFile(const Common::Path &fileName);
|
||||||
virtual bool openStream(Common::SeekableReadStream *stream) = 0;
|
virtual bool openStream(Common::SeekableReadStream *stream) = 0;
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
|
|
@ -616,9 +616,10 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
if (!_bookIni.hasKey(Common::String::format("%d", param1), "Data"))
|
if (!_bookIni.hasKey(Common::String::format("%d", param1), "Data"))
|
||||||
return 0;
|
return 0;
|
||||||
filename = getFilename("Data", param1);
|
Common::Path path = getFilename("Data", param1);
|
||||||
Common::SeekableReadStream *file =
|
Common::SeekableReadStream *file =
|
||||||
Common::MacResManager::openFileOrDataFork(filename);
|
Common::MacResManager::openFileOrDataFork(path);
|
||||||
|
filename = path.toString(Common::Path::kNativeSeparator);
|
||||||
if (!file)
|
if (!file)
|
||||||
error("couldn't open '%s' to get vars id '%d'", filename.c_str(), param1);
|
error("couldn't open '%s' to get vars id '%d'", filename.c_str(), param1);
|
||||||
stream = file;
|
stream = file;
|
||||||
|
@ -684,14 +685,14 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1
|
||||||
case kFuncLoadData:
|
case kFuncLoadData:
|
||||||
debug(3, "kFuncLoadData(%d, %d, %d)", param1, param2, param3);
|
debug(3, "kFuncLoadData(%d, %d, %d)", param1, param2, param3);
|
||||||
{
|
{
|
||||||
Common::String filename = getFilename("Data", param1);
|
Common::Path filename = getFilename("Data", param1);
|
||||||
Common::File *file = new Common::File();
|
Common::File *file = new Common::File();
|
||||||
if (!file->open(filename))
|
if (!file->open(filename))
|
||||||
error("couldn't open '%s' to get data id '%d'", filename.c_str(), param1);
|
error("couldn't open '%s' to get data id '%d'", filename.toString(Common::Path::kNativeSeparator).c_str(), param1);
|
||||||
if (param3 == 0)
|
if (param3 == 0)
|
||||||
param3 = 1000;
|
param3 = 1000;
|
||||||
if (param2 < 0 || param3 < 0 || param2 + param3 > 1000)
|
if (param2 < 0 || param3 < 0 || param2 + param3 > 1000)
|
||||||
error("can't read %d entries into %d from file '%s' for data id '%d'", param3, param2, filename.c_str(), param1);
|
error("can't read %d entries into %d from file '%s' for data id '%d'", param3, param2, filename.toString(Common::Path::kNativeSeparator).c_str(), param1);
|
||||||
for (uint i = 0; i < (uint)param3; i++) {
|
for (uint i = 0; i < (uint)param3; i++) {
|
||||||
if (file->pos() + 1 > file->size())
|
if (file->pos() + 1 > file->size())
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue