void PreloadInitialisation(bool ask) { LKLanguageReady=false; LKReadLanguageFile(szLanguageFile); FillDataOptions(); // Load infobox list if (ask) { // Load default profile and status file: we are at an early stage LKProfileResetDefault(); LKProfileLoad(startAircraftFile); LKProfileLoad(startPilotFile); LKProfileLoad(startDeviceFile); // if DEFAULT PROFILE does not exist, initialize ResetDefaults! // This is because LKProfileLoad will do this at its end, normally. // Notice: aircraft and pilot files will not be overridden by defaults if (!LKProfileLoad(startProfileFile)) { LKProfileInitRuntime(); } StatusFileInit(); } else { // We are in the dialog startup phase FullScreen(); short retstartup; do { retstartup=dlgStartupShowModal(); } while (retstartup>0); if (retstartup<0) return; if (_tcscmp(startProfileFile,_T("PROFILE_RESET"))==0) { StartupStore(_T(". USER ASKED FOR PROFILE FULL RESET!%s"),NEWLINE); DoStatusMessage(gettext(_T("_@M1757_"))); // LK8000 PROFILES RESET LKProfileResetDefault(); LKProfileInitRuntime(); // Notice: this is also resetting the default Aircraft and Pilot profiles to demo settings } else { if (!LKProfileLoad(startPilotFile)) { #if TESTBENCH StartupStore(_T(". PilotFile RESET to defaults%s"),NEWLINE); #endif } if (!LKProfileLoad(startDeviceFile)) { #if TESTBENCH StartupStore(_T(". DeviceFile RESET to defaults%s"),NEWLINE); #endif } if (!LKProfileLoad(startAircraftFile)) { #if TESTBENCH StartupStore(_T(". AircraftFile RESET to defaults%s"),NEWLINE); #endif } LKProfileLoad(startProfileFile); // this is calling adjust and InitRuntime itself } // LKTOKEN _@M1206_ "Initialising..." CreateProgressDialog(gettext(TEXT("_@M1206_"))); } // Interface (before interface) if (!ask) { LKReadLanguageFile(szLanguageFile); InputEvents::readFile(); } InitCustomHardware(); }
void LKReadLanguageFile(const TCHAR* szFileName) { static TCHAR oldLang[4]; if (DoInit[MDI_READLANGUAGEFILE]) { _tcscpy(LKLangSuffix,_T("")); _tcscpy(oldLang,_T("XXX")); DoInit[MDI_READLANGUAGEFILE]=false; } bool english=false; TCHAR szFile1[MAX_PATH] = _T("\0"); _tcscpy(LKLangSuffix,_T("")); _tcscpy(szFile1,szFileName); tryeng: if (_tcslen(szFile1)==0) { _tcscpy(szFile1,_T("%LOCAL_PATH%\\\\_Language\\ENGLISH.LNG")); english=true; } ExpandLocalPath(szFile1); // SetRegistryString(szRegistryLanguageFile, TEXT("\0")); // ? ZZIP_FILE *langFile = openzip(szFile1, "rt"); if (langFile == NULL) { if (english) { StartupStore(_T("--- CRITIC, NO ENGLISH LANGUAGE FILES!%s"),NEWLINE); // critic point, no default language! BIG PROBLEM here! } else { StartupStore(_T("--- NO LANGUAGE FILE FOUND <%s>, retrying with ENGlish!%s"),szFile1,NEWLINE); _tcscpy(szFile1,_T("")); goto tryeng; } return; } bool found=false; TCHAR sTmp[200]; TCHAR mylang[30]; while (ReadULine(langFile, sTmp, array_size(sTmp))) { if (_tcslen(sTmp)<3) continue; if ((sTmp[0]=='L')&&(sTmp[1]=='=')) { _tcscpy(mylang,&sTmp[2]); for (unsigned short i=0; i<_tcslen(mylang); i++) { if (mylang[i]=='\r' || mylang[i]=='\n') { mylang[i]='\0'; break; } } found=true; break; } } if (found) { if (_tcslen(mylang)>3) mylang[3]='\0'; _tcscpy(LKLangSuffix,mylang); } if (_tcscmp(oldLang,LKLangSuffix)!=0) { if ( !LKLoadMessages(false) ) { // force reload of english if (_tcscmp(_T("ENG"),LKLangSuffix) == 0 ) { StartupStore(_T("... CRITICAL, no english langauge available!%s"),NEWLINE); } else { StartupStore(_T("... LoadText failed, fallback to english language\n")); _tcscpy(LKLangSuffix,_T("ENG")); LKLoadMessages(false); } } else { _tcscpy(oldLang,mylang); // Now overload english messages filling gaps in translations // only if current lang is not english of course: no reason to load it twice if (_tcscmp(_T("ENG"),LKLangSuffix) != 0 ) { _tcscpy(LKLangSuffix,_T("ENG")); LKLoadMessages(true); _tcscpy(LKLangSuffix,oldLang); } } } zzip_fclose(langFile); FillDataOptions(); // Load infobox list return; }