Disk is now completely responsible for retrieving localized location scripts

svn-id: r26094
This commit is contained in:
Nicola Mettifogo 2007-03-11 16:53:20 +00:00
parent 319a1c9b65
commit 63ae591e5f
4 changed files with 39 additions and 28 deletions

View File

@ -34,6 +34,32 @@ Disk::Disk(Parallaction* vm) : _vm(vm) {
Disk::~Disk() {
}
void Disk::setLanguage(uint16 language) {
switch (language) {
case 0:
strcpy(_languageDir, "it/");
break;
case 1:
strcpy(_languageDir, "fr/");
break;
case 2:
strcpy(_languageDir, "en/");
break;
case 3:
strcpy(_languageDir, "ge/");
break;
default:
error("unknown language");
}
return;
}
//
// decompress a graphics block
@ -208,22 +234,22 @@ Script* Disk::loadLocation(const char *name) {
char archivefile[PATH_LEN];
if (IS_MINI_CHARACTER(_vm->_characterName)) {
sprintf(archivefile, "%s%s", _vm->_characterName+4, _vm->_languageDir);
sprintf(archivefile, "%s%s", _vm->_characterName+4, _languageDir);
} else {
if (IS_DUMMY_CHARACTER(_vm->_characterName)) strcpy(archivefile, _vm->_languageDir);
if (IS_DUMMY_CHARACTER(_vm->_characterName)) strcpy(archivefile, _languageDir);
else {
sprintf(archivefile, "%s%s", _vm->_characterName, _vm->_languageDir);
sprintf(archivefile, "%s%s", _vm->_characterName, _languageDir);
}
}
strcat(archivefile, name);
strcat(archivefile, ".loc");
_vm->_languageDir[2] = '\0';
_archive.open(_vm->_languageDir);
_vm->_languageDir[2] = '/';
_languageDir[2] = '\0';
_archive.open(_languageDir);
_languageDir[2] = '/';
if (!_archive.openArchivedFile(archivefile)) {
sprintf(archivefile, "%s%s.loc", _vm->_languageDir, name);
sprintf(archivefile, "%s%s.loc", _languageDir, name);
if (!_archive.openArchivedFile(archivefile))
error("can't find location file '%s'", name);
}

View File

@ -88,16 +88,18 @@ private:
void loadMaskAndPath(const char *name);
protected:
Archive _archive;
Archive _archive;
char _languageDir[3];
Parallaction *_vm;
Graphics *_gfx;
Parallaction *_vm;
Graphics *_gfx;
public:
Disk(Parallaction *vm);
virtual ~Disk();
void selectArchive(const char *name);
void setLanguage(uint16 language);
Script* loadLocation(const char *name);
Script* loadScript(const char* name);

View File

@ -128,23 +128,7 @@ void Menu::start() {
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
_language = chooseLanguage();
switch (_language) {
case 0:
strcpy(_engine->_languageDir, "it/");
break;
case 1:
strcpy(_engine->_languageDir, "fr/");
break;
case 2:
strcpy(_engine->_languageDir, "en/");
break;
case 3:
strcpy(_engine->_languageDir, "ge/");
break;
}
_vm->_disk->setLanguage(_language);
_vm->_disk->loadSlide("restore");
_vm->_graphics->palUnk0(_palette);

View File

@ -299,7 +299,6 @@ public:
Graphics* _graphics;
Menu* _menu;
char _characterName[30];
char _languageDir[6];
Disk* _disk;
char _locationNames[120][32];