SCI: Set the printLang and parseLang selectors again when restarting, if necessary.

This sets the language again correctly to the language selected in the launcher when
restarting multilingual games.

svn-id: r55561
This commit is contained in:
Filippos Karapetis 2011-01-27 10:49:11 +00:00
parent 73a440cfe2
commit a6e9fe69c3
2 changed files with 23 additions and 17 deletions

View File

@ -262,19 +262,8 @@ Common::Error SciEngine::run() {
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()));
// Patch in our save/restore code, so that dialogs are replaced
patchGameSaveRestore(segMan);
if (_gameDescription->flags & ADGF_ADDENGLISH) {
// if game is multilingual
Common::Language selectedLanguage = Common::parseLanguage(ConfMan.get("language"));
if (selectedLanguage == Common::EN_ANY) {
// and english was selected as language
if (SELECTOR(printLang) != -1) // set text language to english
writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(printLang), 1);
if (SELECTOR(parseLang) != -1) // and set parser language to english as well
writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(parseLang), 1);
}
}
patchGameSaveRestore();
setLauncherLanguage();
// Check whether loading a savestate was requested
int directSaveSlotLoading = ConfMan.getInt("save_slot");
@ -434,7 +423,8 @@ static byte patchGameRestoreSave[] = {
0x48, // ret
};
void SciEngine::patchGameSaveRestore(SegManager *segMan) {
void SciEngine::patchGameSaveRestore() {
SegManager *segMan = _gamestate->_segMan;
const Object *gameObject = segMan->getObject(_gameObjectAddress);
const uint16 gameMethodCount = gameObject->getMethodCount();
const Object *gameSuperObject = segMan->getObject(_gameSuperClassAddress);
@ -680,7 +670,8 @@ void SciEngine::runGame() {
_gamestate->_segMan->resetSegMan();
initGame();
initStackBaseWithSelector(SELECTOR(play));
patchGameSaveRestore(_gamestate->_segMan);
patchGameSaveRestore();
setLauncherLanguage();
_gamestate->gameIsRestarting = GAMEISRESTARTING_RESTART;
if (_gfxMenu)
_gfxMenu->reset();
@ -689,7 +680,8 @@ void SciEngine::runGame() {
_gamestate->abortScriptProcessing = kAbortNone;
_gamestate->_executionStack.clear();
initStackBaseWithSelector(SELECTOR(replay));
patchGameSaveRestore(_gamestate->_segMan);
patchGameSaveRestore();
setLauncherLanguage();
_gamestate->shrinkStackToBase();
_gamestate->abortScriptProcessing = kAbortNone;
@ -798,6 +790,19 @@ int SciEngine::inQfGImportRoom() const {
return 0;
}
void SciEngine::setLauncherLanguage() {
if (_gameDescription->flags & ADGF_ADDENGLISH) {
// If game is multilingual
if (Common::parseLanguage(ConfMan.get("language")) == Common::EN_ANY) {
// and English was selected as language
if (SELECTOR(printLang) != -1) // set text language to English
writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang), K_LANG_ENGLISH);
if (SELECTOR(parseLang) != -1) // and set parser language to English as well
writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(parseLang), K_LANG_ENGLISH);
}
}
}
void SciEngine::pauseEngineIntern(bool pause) {
_mixer->pauseAll(pause);
if (_soundCmd)

View File

@ -268,7 +268,7 @@ public:
bool checkExportBreakpoint(uint16 script, uint16 pubfunct);
bool checkSelectorBreakpoint(BreakpointType breakpointType, reg_t send_obj, int selector);
void patchGameSaveRestore(SegManager *segMan);
void patchGameSaveRestore();
public:
@ -352,6 +352,7 @@ private:
void initStackBaseWithSelector(Selector selector);
bool gameHasFanMadePatch();
void setLauncherLanguage();
const ADGameDescription *_gameDescription;
const SciGameId _gameId;