From 8b36d14696f2942d1446e641759e05a8089ee8d9 Mon Sep 17 00:00:00 2001 From: Robert Göffringmann Date: Sat, 12 Jul 2003 03:40:44 +0000 Subject: added support for different languages and fixed memory leak and screen refreshes in load/save dialogs svn-id: r8921 --- sky/control.cpp | 28 +++++++++++++++------------- sky/control.h | 2 +- sky/logic.cpp | 9 ++++----- sky/sky.cpp | 19 ++++++++++++++++++- sky/sky.h | 1 + sky/skydefs.h | 9 +++++++++ 6 files changed, 48 insertions(+), 20 deletions(-) (limited to 'sky') diff --git a/sky/control.cpp b/sky/control.cpp index 3cf1e9f743..0880a5b3c6 100644 --- a/sky/control.cpp +++ b/sky/control.cpp @@ -818,7 +818,8 @@ uint16 SkyControl::saveRestorePanel(bool allowSave) { uint8 *saveGameTexts = (uint8 *)malloc(MAX_SAVE_GAMES * MAX_TEXT_LEN); dataFileHeader *textSprites[MAX_ON_SCREEN + 1]; - textSprites[MAX_ON_SCREEN] = NULL; + for (cnt = 0; cnt < MAX_ON_SCREEN + 1; cnt++) + textSprites[cnt] = NULL; _firstText = 0; loadDescriptions(saveGameTexts); @@ -829,6 +830,7 @@ uint16 SkyControl::saveRestorePanel(bool allowSave) { bool refreshAll = true; uint16 clickRes = 0; while (!quitPanel) { + clickRes = 0; if (refreshNames || refreshAll) { if (refreshAll) { _text->flushForRedraw(); @@ -836,7 +838,11 @@ uint16 SkyControl::saveRestorePanel(bool allowSave) { _quitButton->drawToScreen(NO_MASK); if (withAutoSave) _autoSaveButton->drawToScreen(NO_MASK); + refreshAll = false; } + for (cnt = 0; cnt < MAX_ON_SCREEN; cnt++) + if (textSprites[cnt]) + free(textSprites[cnt]); setUpGameSprites(saveGameTexts, textSprites, _firstText, _selectedGame); showSprites(textSprites, allowSave); refreshNames = false; @@ -1632,7 +1638,6 @@ void SkyControl::showGameQuitMsg(bool useScreen) { _skyText->fnSetFont(0); uint8 *textBuf1 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader)); uint8 *textBuf2 = (uint8 *)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader)); - uint8 textNum; uint8 *screenData; if (useScreen) { if (_skyScreen->sequenceRunning()) @@ -1641,15 +1646,8 @@ void SkyControl::showGameQuitMsg(bool useScreen) { screenData = _skyScreen->giveCurrent(); } else screenData = _screenBuf; - switch (SkyState::_systemVars.language) { - case DE_DEU: textNum = 1; break; - case FR_FRA: textNum = 2; break; - case IT_ITA: textNum = 4; break; - case PT_BRA: textNum = 5; break; - default: textNum = 0; break; - } - _skyText->displayText(_quitTexts[textNum * 2 + 0], textBuf1, true, 320, 255); - _skyText->displayText(_quitTexts[textNum * 2 + 1], textBuf2, true, 320, 255); + _skyText->displayText(_quitTexts[SkyState::_systemVars.language * 2 + 0], textBuf1, true, 320, 255); + _skyText->displayText(_quitTexts[SkyState::_systemVars.language * 2 + 1], textBuf2, true, 320, 255); uint8 *curLine1 = textBuf1 + sizeof(dataFileHeader); uint8 *curLine2 = textBuf2 + sizeof(dataFileHeader); uint8 *targetLine = screenData + GAME_SCREEN_WIDTH * 80; @@ -1671,19 +1669,23 @@ void SkyControl::showGameQuitMsg(bool useScreen) { _system->quit(); } -char SkyControl::_quitTexts[12][30] = { +char SkyControl::_quitTexts[16][35] = { "Game over player one", "BE VIGILANT", "Das Spiel ist aus.", "SEI WACHSAM", "Game over joueur 1", "SOYEZ VIGILANTS", - "Spelet r slut, Agent 1.", + "Game over player one", + "BE VIGILANT", + "SPELET \x8Er SLUT, Agent 1.", "VAR VAKSAM", "Game over giocatore 1", "SIATE VIGILANTI", "Fim de jogo para o jogador um", "BE VIGILANT" + "Game over player one", + "BE VIGILANT", }; uint8 SkyControl::_crossImg[594] = { diff --git a/sky/control.h b/sky/control.h index de1cdad8ef..7b23fe3d84 100644 --- a/sky/control.h +++ b/sky/control.h @@ -285,7 +285,7 @@ private: SkyControlStatus *_statusBar; - static char _quitTexts[12][30]; + static char _quitTexts[16][35]; static uint8 _crossImg[594]; }; diff --git a/sky/logic.cpp b/sky/logic.cpp index 691f3d9ed1..9caf1ba0a1 100644 --- a/sky/logic.cpp +++ b/sky/logic.cpp @@ -2438,11 +2438,10 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 // if sky is configured to speech-only return now - except if we're running another // language than english - if (speechUsed && (!(SkyState::_systemVars.systemFlags & SF_ALLOW_TEXT)) && - (SkyState::_systemVars.language == EN_USA)) { - target->extCompact->spTime = 10; - target->logic = L_TALK; - return ; + if (speechUsed && (!(SkyState::_systemVars.systemFlags & SF_ALLOW_TEXT))) { + target->extCompact->spTime = 10; + target->logic = L_TALK; + return ; } //now form the text sprite diff --git a/sky/sky.cpp b/sky/sky.cpp index 0cfdb9e404..3a444da83e 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -87,7 +87,10 @@ SkyState::SkyState(GameDetector *detector, OSystem *syst) _debugMode = detector->_debugMode; _debugLevel = detector->_debugLevel; - _systemVars.language = detector->_language; + if (detector->_language > 10) + _systemVars.language = SKY_USA; + else + _systemVars.language = _languageTable[detector->_language]; _detector = detector; _floppyIntro = detector->_floppyIntro; @@ -110,6 +113,20 @@ void SkyState::errorString(const char *buf1, char *buf2) { strcpy(buf2, buf1); } +uint8 SkyState::_languageTable[11] = { + SKY_USA, // EN_USA + SKY_GERMAN, // DE_DEU + SKY_FRENCH, // FR_FRA + SKY_ITALIAN, // IT_ITA + SKY_PORTUGUESE, // PT_BRA + SKY_SPANISH, // ES_ESP + SKY_USA, // JA_JPN + SKY_USA, // ZH_TWN + SKY_USA, // KO_KOR + SKY_SWEDISH, // SE_SWE + SKY_ENGLISH // EN_GRB +}; + void SkyState::doCheat(uint8 num) { switch(num) { diff --git a/sky/sky.h b/sky/sky.h index 4d5700ae85..b536979953 100644 --- a/sky/sky.h +++ b/sky/sky.h @@ -61,6 +61,7 @@ class SkyState : public Engine { protected: byte _game; byte _key_pressed; + static uint8 _languageTable[11]; //intro related diff --git a/sky/skydefs.h b/sky/skydefs.h index 0f2030d48f..33d58de5e2 100644 --- a/sky/skydefs.h +++ b/sky/skydefs.h @@ -26,6 +26,15 @@ //This file is incomplete, several flags still missing. +#define SKY_ENGLISH 0 +#define SKY_GERMAN 1 +#define SKY_FRENCH 2 +#define SKY_USA 3 +#define SKY_SWEDISH 4 +#define SKY_ITALIAN 5 +#define SKY_PORTUGUESE 6 +#define SKY_SPANISH 7 + #define ST_COLLISION_BIT 5 #define S_COUNT 0 -- cgit v1.2.3