SUPERNOVA: Load info files from .dat file
This commit is contained in:
parent
16bad91f4b
commit
37c53c420f
3 changed files with 83 additions and 15 deletions
|
@ -265,19 +265,13 @@ void GameManager::processInput(Common::KeyState &state) {
|
||||||
// show game manual
|
// show game manual
|
||||||
if (!_guiEnabled)
|
if (!_guiEnabled)
|
||||||
return;
|
return;
|
||||||
if (_vm->_MSPart == 1)
|
_vm->showTextReader("doc");
|
||||||
_vm->showTextReader("msn.doc");
|
|
||||||
else if (_vm->_MSPart == 2)
|
|
||||||
_vm->showTextReader("ms2.doc");
|
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_F3:
|
case Common::KEYCODE_F3:
|
||||||
// show game info
|
// show game info
|
||||||
if (!_guiEnabled)
|
if (!_guiEnabled)
|
||||||
return;
|
return;
|
||||||
if (_vm->_MSPart == 1)
|
_vm->showTextReader("inf");
|
||||||
_vm->showTextReader("msn.inf");
|
|
||||||
else if (_vm->_MSPart == 2)
|
|
||||||
_vm->showTextReader("ms2.inf");
|
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_F4:
|
case Common::KEYCODE_F4:
|
||||||
if (!_guiEnabled)
|
if (!_guiEnabled)
|
||||||
|
|
|
@ -510,14 +510,87 @@ void SupernovaEngine::showHelpScreen2() {
|
||||||
_gm->animationOn();
|
_gm->animationOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error SupernovaEngine::showTextReader(const char *filename) {
|
Common::SeekableReadStream *SupernovaEngine::getBlockFromDatFile(Common::String name) {
|
||||||
Common::File file;
|
Common::String cur_lang = ConfMan.get("language");
|
||||||
|
|
||||||
if (!file.open(filename)) {
|
// Validate the data file header
|
||||||
GUIErrorMessageFormat(_("Unable to find '%s' in game folder."), filename);
|
Common::File f;
|
||||||
return Common::kReadingFailed;
|
char id[5], lang[5];
|
||||||
|
id[4] = lang[4] = '\0';
|
||||||
|
if (_MSPart == 1) {
|
||||||
|
if (!f.open(SUPERNOVA_DAT)) {
|
||||||
|
GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
f.read(id, 3);
|
||||||
|
if (strncmp(id, "MSN", 3) != 0) {
|
||||||
|
GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int version = f.readByte();
|
||||||
|
if (version != SUPERNOVA_DAT_VERSION) {
|
||||||
|
GUIErrorMessageFormat(
|
||||||
|
_("Incorrect version of the '%s' engine data file found. Expected %d but got %d."),
|
||||||
|
SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_MSPart == 2) {
|
||||||
|
if (!f.open(SUPERNOVA2_DAT)) {
|
||||||
|
GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA2_DAT);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
f.read(id, 3);
|
||||||
|
if (strncmp(id, "MS2", 3) != 0) {
|
||||||
|
GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA2_DAT);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int version = f.readByte();
|
||||||
|
if (version != SUPERNOVA2_DAT_VERSION) {
|
||||||
|
GUIErrorMessageFormat(
|
||||||
|
_("Incorrect version of the '%s' engine data file found. Expected %d but got %d."),
|
||||||
|
SUPERNOVA2_DAT, SUPERNOVA2_DAT_VERSION, version);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while (!f.eos()) {
|
||||||
|
f.read(id, 4);
|
||||||
|
f.read(lang, 4);
|
||||||
|
uint32 size = f.readUint32LE();
|
||||||
|
if (f.eos())
|
||||||
|
break;
|
||||||
|
if (name == id && cur_lang == lang) {
|
||||||
|
return f.readStream(size);
|
||||||
|
} else
|
||||||
|
f.skip(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::Error SupernovaEngine::showTextReader(const char *extension) {
|
||||||
|
Common::SeekableReadStream *stream;
|
||||||
|
Common::String blockName;
|
||||||
|
blockName = Common::String::format("%s%d", extension, _MSPart);
|
||||||
|
blockName.toUppercase();
|
||||||
|
if ((stream = getBlockFromDatFile(blockName)) == nullptr) {
|
||||||
|
Common::File file;
|
||||||
|
Common::String filename;
|
||||||
|
if (_MSPart == 1)
|
||||||
|
filename = Common::String::format("msn.%s", extension);
|
||||||
|
if (_MSPart == 2)
|
||||||
|
filename = Common::String::format("ms2.%s", extension);
|
||||||
|
|
||||||
|
if (!file.open(filename)) {
|
||||||
|
GUIErrorMessageFormat(_("Unable to find '%s' in game folder or the engine data file."), filename);
|
||||||
|
return Common::kReadingFailed;
|
||||||
|
}
|
||||||
|
stream = file.readStream(file.size());
|
||||||
}
|
}
|
||||||
Common::SeekableReadStream *stream = file.readStream(file.size());
|
|
||||||
int linesInFile = 0;
|
int linesInFile = 0;
|
||||||
while (!stream->eos()) {
|
while (!stream->eos()) {
|
||||||
stream->readLine();
|
stream->readLine();
|
||||||
|
|
|
@ -105,7 +105,8 @@ public:
|
||||||
void setGameString(int idx, const Common::String &string);
|
void setGameString(int idx, const Common::String &string);
|
||||||
void showHelpScreen1();
|
void showHelpScreen1();
|
||||||
void showHelpScreen2();
|
void showHelpScreen2();
|
||||||
Common::Error showTextReader(const char *filename);
|
Common::SeekableReadStream *getBlockFromDatFile(Common::String name);
|
||||||
|
Common::Error showTextReader(const char *extension);
|
||||||
|
|
||||||
// forwarding calls
|
// forwarding calls
|
||||||
void playSound(AudioId sample);
|
void playSound(AudioId sample);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue