aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorThierry Crozat2013-08-19 21:11:23 +0100
committerThierry Crozat2013-08-19 21:11:23 +0100
commitefbf1ff5f999786675fdf28b53970af0eacfa759 (patch)
tree1ecb0b96fef0a9e00ced497af1e015dd25a37513 /engines
parent9eaf978e334861fa7da2f9304633cef5202d6745 (diff)
downloadscummvm-rg350-efbf1ff5f999786675fdf28b53970af0eacfa759.tar.gz
scummvm-rg350-efbf1ff5f999786675fdf28b53970af0eacfa759.tar.bz2
scummvm-rg350-efbf1ff5f999786675fdf28b53970af0eacfa759.zip
MORTEVIELLE: Store German menu data in data file and clean menu code
This opens the door to a better translation of the menu to German. Also the code will now always try to read the menu data from the mort.data file and only if this fails it will use the game data. And remove some dead code that was to support the corrupted menu.mor file.
Diffstat (limited to 'engines')
-rw-r--r--engines/mortevielle/menu.cpp95
-rw-r--r--engines/mortevielle/menu.h2
2 files changed, 61 insertions, 36 deletions
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index 1077f66fc2..c75409311b 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -591,47 +591,72 @@ void Menu::setParent(MortevielleEngine *vm) {
void Menu::initMenu() {
Common::File f;
- bool enMenuLoaded = false;
- if (_vm->getLanguage() == Common::EN_ANY) {
- // Open the mort.dat file
- if (!f.open(MORT_DAT))
- warning("File %s not found. Using default menu from game data", MORT_DAT);
- else {
- // Validate the data file header
- char fileId[4];
- f.read(fileId, 4);
- // Do not display warnings here. They would already have been displayed in MortevielleEngine::loadMortDat().
- if (strncmp(fileId, "MORT", 4) == 0 && f.readByte() >= MORT_DAT_REQUIRED_VERSION) {
- f.readByte(); // Minor version
- // Loop to load resources from the data file
- while (f.pos() < f.size()) {
- // Get the Id and size of the next resource
- char dataType[4];
- int dataSize;
- f.read(dataType, 4);
- dataSize = f.readUint16LE();
- if (!strncmp(dataType, "MENU", 4)) {
- // MENU section
- if (dataSize <= 7 * 24) {
- f.read(_charArr, dataSize);
- enMenuLoaded = true;
- } else
- warning("Wrong size %d for menu data. Expected %d or less", dataSize, 7*24);
- break;
- } else {
- // Other sections
+ bool menuLoaded = false;
+ // First try to read it from mort.dat
+ if (!f.open(MORT_DAT))
+ warning("File %s not found. Using default menu from game data", MORT_DAT);
+ else {
+ // Figure out what language Id is needed
+ byte desiredLanguageId;
+ switch(_vm->getLanguage()) {
+ case Common::EN_ANY:
+ desiredLanguageId = MORTDAT_LANG_ENGLISH;
+ break;
+ case Common::FR_FRA:
+ desiredLanguageId = MORTDAT_LANG_FRENCH;
+ break;
+ case Common::DE_DEU:
+ desiredLanguageId = MORTDAT_LANG_GERMAN;
+ break;
+ default:
+ warning("Language not supported, switching to English");
+ desiredLanguageId = MORTDAT_LANG_ENGLISH;
+ break;
+ }
+
+ // Validate the data file header
+ char fileId[4];
+ f.read(fileId, 4);
+ // Do not display warnings here. They would already have been displayed in MortevielleEngine::loadMortDat().
+ if (strncmp(fileId, "MORT", 4) == 0 && f.readByte() >= MORT_DAT_REQUIRED_VERSION) {
+ f.readByte(); // Minor version
+ // Loop to load resources from the data file
+ while (f.pos() < f.size()) {
+ // Get the Id and size of the next resource
+ char dataType[4];
+ int dataSize;
+ f.read(dataType, 4);
+ dataSize = f.readUint16LE();
+ if (!strncmp(dataType, "MENU", 4)) {
+ // Read in the language
+ byte languageId = f.readByte();
+ --dataSize;
+
+ // If the language isn't correct, then skip the entire block
+ if (languageId != desiredLanguageId) {
f.skip(dataSize);
+ continue;
}
+ if (dataSize == 6 * 24) {
+ f.read(_charArr, dataSize);
+ menuLoaded = true;
+ } else
+ warning("Wrong size %d for menu data. Expected %d or less", dataSize, 6 * 24);
+ break;
+ } else {
+ // Other sections
+ f.skip(dataSize);
}
}
- // Close the file
- f.close();
- if (!enMenuLoaded)
- warning("Failed to load English menu. Will use default menu from game data instead");
}
+ // Close the file
+ f.close();
+ if (!menuLoaded)
+ warning("Failed to load menu from mort.dat. Will use default menu from game data instead.");
}
- if (!enMenuLoaded) {
+ if (!menuLoaded) {
+ // Load menu from game data using the original language
if (_vm->getOriginalLanguage() == Common::FR_FRA) {
if (!f.open("menufr.mor"))
error("Missing file - menufr.mor");
@@ -639,7 +664,7 @@ void Menu::initMenu() {
if (!f.open("menual.mor"))
error("Missing file - menual.mor");
}
- f.read(_charArr, 7 * 24);
+ f.read(_charArr, 6 * 24);
f.close();
}
diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h
index d1271bca2e..debf5b09b6 100644
--- a/engines/mortevielle/menu.h
+++ b/engines/mortevielle/menu.h
@@ -51,7 +51,7 @@ class Menu {
private:
MortevielleEngine *_vm;
- byte _charArr[7][24];
+ byte _charArr[6][24];
int _msg3;
int _msg4;