void StartLogger() { SHOWTHREAD(_T("StartLogger")); HANDLE hFile; int i; TCHAR path[MAX_PATH+1]; TCHAR cAsset[3]; // strAsset is initialized with DUM. if (_tcslen(PilotName_Config)>0) { strAssetNumber[0]= IsAlphaNum(PilotName_Config[0]) ? PilotName_Config[0] : _T('A'); strAssetNumber[1]= IsAlphaNum(PilotName_Config[1]) ? PilotName_Config[1] : _T('A'); } else { strAssetNumber[0]= _T('D'); strAssetNumber[1]= _T('U'); } if (_tcslen(AircraftType_Config)>0) { strAssetNumber[2]= IsAlphaNum(AircraftType_Config[0]) ? AircraftType_Config[0] : _T('A'); } else { strAssetNumber[2]= _T('M'); } strAssetNumber[0]= towupper(strAssetNumber[0]); strAssetNumber[1]= towupper(strAssetNumber[1]); strAssetNumber[2]= towupper(strAssetNumber[2]); strAssetNumber[3]= _T('\0'); for (i=0; i < 3; i++) { // chars must be legal in file names cAsset[i] = IsAlphaNum(strAssetNumber[i]) ? strAssetNumber[i] : _T('A'); } LocalPath(path,TEXT(LKD_LOGS)); if (TaskModified) { SaveDefaultTask(); } wsprintf(szLoggerFileName, TEXT("%s\\LOGGER_TMP.IGC"), path); wsprintf(szSLoggerFileName, TEXT("%s\\LOGGER_SIG.IGC"), path); TCHAR newfile[MAX_PATH+20]; if (GetFileAttributes(szLoggerFileName) != 0xffffffff) { StartupStore(_T("---- Logger recovery: Existing LOGGER_TMP.IGC found, renamed to LOST%s"),NEWLINE); wsprintf(newfile, TEXT("%s\\LOST_%02d%02d%02d.IGC"), path, GPS_INFO.Hour, GPS_INFO.Minute, GPS_INFO.Second); CopyFile(szLoggerFileName,newfile,TRUE); DeleteFile(szLoggerFileName); } if (GetFileAttributes(szSLoggerFileName) != 0xffffffff) { StartupStore(_T("---- Logger recovery (G): Existing LOGGER_SIG.IGC found, renamed to LOSTG%s"),NEWLINE); wsprintf(newfile, TEXT("%s\\LOSTG_%02d%02d%02d.IGC"), path, GPS_INFO.Hour, GPS_INFO.Minute, GPS_INFO.Second); CopyFile(szSLoggerFileName,newfile,TRUE); DeleteFile(szSLoggerFileName); } for(i=1;i<99;i++) { // 2003-12-31-XXX-987-01.IGC // long filename form of IGC file. // XXX represents manufacturer code if (!LoggerShortName) { // Long file name wsprintf(szFLoggerFileName, TEXT("%s\\%04d-%02d-%02d-%s-%c%c%c-%02d.IGC"), path, GPS_INFO.Year, GPS_INFO.Month, GPS_INFO.Day, _T(LOGGER_MANUFACTURER), cAsset[0], cAsset[1], cAsset[2], i); wsprintf(szFLoggerFileNameRoot, TEXT("%s\\%04d-%02d-%02d-%s-%c%c%c-%02d.IGC"), TEXT(""), // this creates it in root if MoveFile() fails GPS_INFO.Year, GPS_INFO.Month, GPS_INFO.Day, _T(LOGGER_MANUFACTURER), cAsset[0], cAsset[1], cAsset[2], i); } else { // Short file name TCHAR cyear, cmonth, cday, cflight; cyear = NumToIGCChar((int)GPS_INFO.Year % 10); cmonth = NumToIGCChar(GPS_INFO.Month); cday = NumToIGCChar(GPS_INFO.Day); cflight = NumToIGCChar(i); wsprintf(szFLoggerFileName, TEXT("%s\\%c%c%cX%c%c%c%c.IGC"), path, cyear, cmonth, cday, cAsset[0], cAsset[1], cAsset[2], cflight); wsprintf(szFLoggerFileNameRoot, TEXT("%s\\%c%c%cX%c%c%c%c.IGC"), TEXT(""), // this creates it in root if MoveFile() fails cyear, cmonth, cday, cAsset[0], cAsset[1], cAsset[2], cflight); } // end if hFile = CreateFile(szFLoggerFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if(hFile!=INVALID_HANDLE_VALUE ) { // file already exists CloseHandle(hFile); DeleteFile(szFLoggerFileName); break; } } // end while StartupStore(_T(". Logger Started %s File <%s>%s"), WhatTimeIsIt(), szFLoggerFileName,NEWLINE); return; }
void WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) { for (const auto &i : waypoint->files_embed) { if (images.full()) break; try { if (!images.append().LoadFile(LocalPath(i.c_str()))) images.shrink(images.size() - 1); } catch (const std::exception &e) { LogFormat("Failed to load %s: %s", (const char *)NarrowPathName(Path(i.c_str())), e.what()); images.shrink(images.size() - 1); } } const Layout layout(rc, *waypoint); WindowStyle dock_style; dock_style.Hide(); dock_style.ControlParent(); WindowStyle button_style; button_style.Hide(); button_style.TabStop(); if (allow_navigation) goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button, button_style, *this, GOTO); if (!images.empty()) { magnify_button.Create(parent, layout.magnify_button, button_style, new SymbolButtonRenderer(look.button, _T("+")), *this, MAGNIFY); shrink_button.Create(parent, layout.shrink_button, button_style, new SymbolButtonRenderer(look.button, _T("-")), *this, SHRINK); } if (allow_navigation) { previous_button.Create(parent, layout.previous_button, button_style, new SymbolButtonRenderer(look.button, _T("<")), *this, PREVIOUS); next_button.Create(parent, layout.next_button, button_style, new SymbolButtonRenderer(look.button, _T(">")), *this, NEXT); } close_button.Create(parent, look.button, _("Close"), layout.close_button, button_style, dialog, mrOK); info_dock.Create(parent, layout.main, dock_style); info_dock.SetWidget(&info_widget); details_panel.Create(parent, look, layout.main, dock_style); details_text.Create(details_panel, layout.details_text); details_text.SetFont(look.text_font); details_text.SetText(waypoint->details.c_str()); #ifdef HAVE_RUN_FILE const unsigned num_files = std::distance(waypoint->files_external.begin(), waypoint->files_external.end()); if (num_files > 0) { file_list.Create(details_panel, layout.file_list, WindowStyle(), layout.file_list_item_height); file_list.SetItemRenderer(&file_list_handler); file_list.SetCursorHandler(&file_list_handler); file_list.SetLength(num_files); } #endif commands_dock.Create(parent, layout.main, dock_style); commands_dock.SetWidget(&commands_widget); if (!images.empty()) image_window.Create(parent, layout.main, dock_style, [this](Canvas &canvas, const PixelRect &rc){ OnImagePaint(canvas, rc); }); last_page = 2 + images.size(); }
void LoadChecklist(void) { nLists = 0; if (ChecklistText[0]) { free(ChecklistText[0]); ChecklistText[0]= NULL; } if (ChecklistTitle[0]) { free(ChecklistTitle[0]); ChecklistTitle[0]= NULL; } TCHAR filename[MAX_PATH]; LocalPath(filename, TEXT(XCSCHKLIST)); FILE *file = _tfopen(filename, TEXT("rt")); if (file == NULL) { return; } ///// TCHAR TempString[MAXTITLE]; TCHAR Details[MAXDETAILS]; TCHAR Name[100]; BOOL inDetails = FALSE; int i; // int k=0; Details[0]= 0; Name[0]= 0; TempString[0]=0; while (ReadStringX(file, MAXTITLE, TempString)) { int len = _tcslen(TempString); if (len>0) { // JMW strip extra \r if it exists if (TempString[len-1]=='\r') { TempString[len-1]= 0; } } if(TempString[0]=='[') { // Look for start if (inDetails) { _tcscat(Details,TEXT("\r\n")); addChecklist(Name, Details); Details[0]= 0; Name[0]= 0; } // extract name for (i=1; i<MAXTITLE; i++) { if (TempString[i]==']') { break; } Name[i-1]= TempString[i]; } Name[i-1]= 0; inDetails = TRUE; } else { // append text to details string _tcsncat(Details,TempString,MAXDETAILS-2); _tcscat(Details,TEXT("\r\n")); // TODO code: check the string is not too long } } if (inDetails) { _tcscat(Details,TEXT("\r\n")); addChecklist(Name, Details); } ///// fclose(file); }
// // 259 still active, very bad // 0 is the only OK that we want! // other values, very bad // int RunSignature() { DWORD retval=99; TCHAR homedir[MAX_PATH]; TCHAR path[MAX_PATH]; LocalPath(path,_T(LKD_LOGS)); #if (WINDOWSPC>0) _tcscat(path,_T("\\LKRECORD_PC.LK8")); #endif // CAREFUL!!! PNA is ALSO PPC2003!! // // ATTENTION: on PNA we are executing LKRECORD_PNA.LK8.EXE really #ifdef PNA _tcscat(path,_T("\\LKRECORD_PNA.LK8")); #else #ifdef PPC2002 _tcscat(path,_T("\\LKRECORD_2002.LK8")); #endif #ifdef PPC2003 _tcscat(path,_T("\\LKRECORD_2003.LK8")); #endif #endif LocalPath(homedir,TEXT(LKD_LOGS)); #if TESTBENCH StartupStore(_T(".... RunSignature: homedir <%s>%s"),homedir,NEWLINE); #endif PROCESS_INFORMATION pi; #if (WINDOWSPC>0) // Sadly, some parameters cannot be passed in the CE version STARTUPINFO si; ZeroMemory(&si,sizeof(STARTUPINFO)); si.cb=sizeof(STARTUPINFO); si.wShowWindow= SW_SHOWNORMAL; si.dwFlags = STARTF_USESHOWWINDOW; if (!::CreateProcess(path,homedir, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { #else if (!::CreateProcess(path,homedir, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &pi)) { #endif DWORD lasterr=GetLastError(); if (lasterr!=2) { // External executable failure, bad ! StartupStore(_T(".... RunSignature exec <%s> FAILED, error code=%d"),path,lasterr,NEWLINE); #if TESTBENCH StartupStore(_T(".... Trying with DoSignature\n")); #endif } #if TESTBENCH else StartupStore(_T(".... no executable <%s> found, proceeding with DoSignature\n"),path); #endif extern int DoSignature(TCHAR *hpath); retval=DoSignature(homedir); return retval; } ::WaitForSingleObject(pi.hProcess, 30000); // 30s GetExitCodeProcess(pi.hProcess,&retval); // STILL_ACTIVE = 259, this retval should be checked for #if TESTBENCH StartupStore(_T(".... RunSignature exec <%s> terminated, retval=%d%s"),path,retval,NEWLINE); #endif return retval; } // // Paolo+Durval: feed external headers to LK for PNAdump software // #define EXTHFILE "COMPE.CNF" //#define DEBUGHFILE 1 void AdditionalHeaders(void) { TCHAR pathfilename[MAX_PATH+1]; wsprintf(pathfilename, TEXT("%s\\%s\\%S"), LKGetLocalPath(), TEXT(LKD_LOGS), EXTHFILE); if (GetFileAttributes(pathfilename) == 0xffffffff) { #if DEBUGHFILE StartupStore(_T("... No additional headers file <%s>\n"),pathfilename); #endif return; } #if DEBUGHFILE StartupStore(_T("... HFILE <%s> FOUND\n"),pathfilename); #endif HANDLE hfile = CreateFile(pathfilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if( hfile == INVALID_HANDLE_VALUE) { StartupStore(_T("... ERROR, extHFILE <%s> not found!%s"),pathfilename,NEWLINE); return; } #define MAXHLINE 100 TCHAR tmpString[MAXHLINE+1]; char tmps[MAXHLINE+1]; //char line[MAXHLINE+12]; tmpString[0]=0; while (ReadString(hfile, MAXHLINE, tmpString)) { size_t len = _tcslen(tmpString); if (len < 2) continue; if (tmpString[0]!='$' ) { #if DEBUGHFILE StartupStore(_T("Line skipped: <%s>\n"),tmpString); #endif continue; } // Remove trailing cr lf, three times to be sure if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) { tmpString[len - 1]= 0; len--; } if (len > 0) { if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) { tmpString[len - 1]= 0; len--; } } if (len > 0) { if ( (tmpString[len - 1] == '\r') || (tmpString[len-1]== '\n')) { tmpString[len - 1]= 0; } } #if DEBUGHFILE StartupStore(_T("ADDING HEADER <%s>\n"),tmpString); #endif /* unicode2ascii(&tmpString[1],tmps,MAXHLINE); strcpy(line,"HFREMARK:"); strcat(line,tmps); strcat(line,"\r\n"); */ sprintf(tmps,"HFREMARK:%S\r\n",&tmpString[1]); IGCWriteRecord(tmps); } CloseHandle(hfile); }
void WeatherMapOverlayListWidget::UpdateList() { items.clear(); struct Visitor : public File::Visitor { std::vector<Item> &items; explicit Visitor(std::vector<Item> &_items):items(_items) {} void Visit(Path path, Path filename) override { items.emplace_back(filename.c_str(), path); } } visitor(items); const auto weather_path = LocalPath(_T("weather")); const auto overlay_path = AllocatedPath::Build(weather_path, _T("overlay")); Directory::VisitSpecificFiles(overlay_path, _T("*.tif"), visitor); Directory::VisitSpecificFiles(overlay_path, _T("*.tiff"), visitor); const unsigned n = items.size(); if (n > 0) std::sort(items.begin(), items.end()); ListControl &list_control = GetList(); list_control.SetLength(n); list_control.Invalidate(); const bool empty = items.empty(); use_button->SetEnabled(!empty);
static void OnSplashPaint(WindowControl * Sender, HDC hDC){ TCHAR srcfile[MAX_PATH]; TCHAR fprefix[20]; if (RUN_MODE==RUN_SHUTDOWN) return; if (RUN_MODE==RUN_WELCOME) _tcscpy(fprefix,_T("LKSTART")); else _tcscpy(fprefix,_T("LKPROFILE")); LoadSplash(hDC,fprefix); if (RUN_MODE==RUN_WELCOME) { TCHAR mes[100]; int pos=0; switch (ScreenSize) { case ss800x480: pos=12; break; case ss400x240: pos=12; break; case ss480x272: if (ScreenSizeX==854) pos=14; else pos=11; break; case ss640x480: pos=12; break; case ss320x240: pos=12; break; case ss896x672: pos=14; break; // --------- portrait ------------- case ss240x320: pos=17; break; case ss480x640: pos=17; break; case ss272x480: pos=18; break; case ss240x400: pos=16; break; case ss480x800: pos=18; break; default: pos=11; break; } if (fullresetasked) { _stprintf(mes,_T("*** %s ***"),gettext(_T("_@M1757_"))); RawWrite(hDC,mes,pos,1, RGB_DARKWHITE,WTMODE_NORMAL); } else { #ifndef LKCOMPETITION _stprintf(mes,_T("Version %S.%S (%S)"),LKVERSION,LKRELEASE,__DATE__); #else _stprintf(mes,_T("V%S.%S COMPETITION"),LKVERSION,LKRELEASE,__DATE__); #endif RawWrite(hDC,mes,pos,1, RGB_DARKWHITE,WTMODE_NORMAL); } } if (RUN_MODE!=RUN_WELCOME) { // FillRect(hDC,&ScreenSizeR, LKBrush_Black); // REMOVE TCHAR mes[100]; #ifndef LKCOMPETITION _stprintf(mes,_T("%S v%S.%S - %s"),LKFORK,LKVERSION,LKRELEASE,gettext(_T("_@M2054_"))); #else _stprintf(mes,_T("%SC v%S.%S - %s"),LKFORK,LKVERSION,LKRELEASE,gettext(_T("_@M2054_"))); #endif RawWrite(hDC,mes,1,1, RGB_LIGHTGREY,WTMODE_NORMAL); unsigned long freeram = CheckFreeRam()/1024; TCHAR buffer[MAX_PATH]; LocalPath(buffer); unsigned long freestorage = FindFreeSpace(buffer); _stprintf(mes,_T("free ram %.1ldM storage %.1ldM"), freeram/1024,freestorage/1024); RawWrite(hDC,mes,3,0, RGB_LIGHTGREY,WTMODE_NORMAL); if ( ScreenSize != ss320x240 && ScreenLandscape ) RawWrite(hDC,_T("_______________________"),2,2, RGB_LIGHTGREY,WTMODE_NORMAL); if (fullresetasked) { _stprintf(mes,_T("%s"),gettext(_T("_@M1757_"))); // LK8000 PROFILES RESET RawWrite(hDC,mes,5,2, RGB_ICEWHITE, WTMODE_OUTLINED); _stprintf(mes,_T("%s"),gettext(_T("_@M1759_"))); // SELECTED IN SYSTEM RawWrite(hDC,mes,6,2, RGB_ICEWHITE, WTMODE_OUTLINED); } else { _stprintf(mes,_T("%s"),PilotName_Config); RawWrite(hDC,mes,4,2, RGB_ICEWHITE, WTMODE_OUTLINED); _stprintf(mes,_T("%s"),AircraftRego_Config); RawWrite(hDC,mes,5,2, RGB_AMBER, WTMODE_OUTLINED); _stprintf(mes,_T("%s"),AircraftType_Config); RawWrite(hDC,mes,6,2, RGB_AMBER, WTMODE_OUTLINED); LKASSERT(szPolarFile[0]); extern void LK_wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext); LK_wsplitpath(szPolarFile, (WCHAR*) NULL, (WCHAR*) NULL, srcfile, (WCHAR*) NULL); _stprintf(mes,_T("%s %s"),gettext(_T("_@M528_")),srcfile); // polar file RawWrite(hDC,mes,7,2, RGB_AMBER, WTMODE_OUTLINED); LKASSERT(startProfileFile[0]); LK_wsplitpath(startProfileFile, (WCHAR*) NULL, (WCHAR*) NULL, srcfile, (WCHAR*) NULL); _stprintf(mes,_T("%s: %s"),MsgToken(1746),srcfile); RawWrite(hDC,mes,11,1, RGB_ICEWHITE, WTMODE_NORMAL); } // RawWrite(hDC,_T("_______________________"),8,2, RGB_LIGHTGREY,WTMODE_NORMAL); // REMOVE FOR THE 3.0 return; } }
static void OnSaveNewClicked(WindowControl * Sender) { (void)Sender; int file_index; TCHAR file_name[MAX_PATH]; TCHAR profile_name[MAX_PATH]; TCHAR tmptext[MAX_PATH]; WndProperty* wp; DataFieldFileReader *dfe; wp = (WndProperty*)wf->FindByName(TEXT("prpFile")); if (!wp) return; dfe = (DataFieldFileReader*) wp->GetDataField(); _tcscpy(profile_name,_T("")); dlgTextEntryShowModal(profile_name, 13); // max length including termination 0 if (_tcslen(profile_name)<=0) return; _tcscat(profile_name, TEXT(LKS_PRF)); LocalPath(file_name,TEXT(LKD_CONF)); _tcscat(file_name,TEXT("\\")); _tcscat(file_name,profile_name); dfe->Lookup(file_name); file_index = dfe->GetAsInteger(); if (file_index==0) { _stprintf(tmptext, TEXT("%s: %s"), // LKTOKEN _@M458_ = "New profile" gettext(TEXT("_@M458_")), profile_name); if(MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M579_ = "Save ?" gettext(TEXT("_@M579_")), MB_YESNO|MB_ICONQUESTION) == IDYES) { WriteProfile(file_name); dfe->addFile(profile_name, file_name); MessageBoxX(hWndMapWindow, // LKTOKEN _@M535_ = "Profile saved!" gettext(TEXT("_@M535_")), _T(""), MB_OK|MB_ICONEXCLAMATION); dfe->Set(0); return; } } if (file_index>0) { _stprintf(tmptext, TEXT("%s: %s"), // LKTOKEN _@M533_ = "Profile already exists" gettext(TEXT("_@M533_")), profile_name); if (CheckClubVersion() ) { MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M162_ = "Cannot overwrite!" gettext(TEXT("_@M162_")), MB_OK|MB_ICONEXCLAMATION); } else { if(MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M510_ = "Overwrite?" gettext(TEXT("_@M510_")), MB_YESNO|MB_ICONQUESTION) == IDYES) { WriteProfile(file_name); MessageBoxX(hWndMapWindow, // LKTOKEN _@M535_ = "Profile saved!" gettext(TEXT("_@M535_")), _T(""), MB_OK|MB_ICONEXCLAMATION); return; } } dfe->Set(0); } }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool Startup() { VerboseOperationEnvironment operation; #ifdef USE_GDI //If "XCSoar" is already running, stop this instance if (MainWindow::Find()) return false; #endif #ifdef HAVE_DOWNLOAD_MANAGER Net::DownloadManager::Initialise(); #endif LogFormat("Display dpi=%u,%u", Display::GetXDPI(), Display::GetYDPI()); // Creates the main window TopWindowStyle style; if (CommandLine::full_screen) style.FullScreen(); if (CommandLine::resizable) style.Resizable(); MainWindow *const main_window = CommonInterface::main_window = new MainWindow(CommonInterface::status_messages); main_window->Create(SystemWindowSize(), style); if (!main_window->IsDefined()) return false; #ifdef ENABLE_OPENGL LogFormat("OpenGL: " #ifdef HAVE_EGL "egl=%d " #endif "npot=%d vbo=%d fbo=%d", #ifdef HAVE_EGL OpenGL::egl, #endif OpenGL::texture_non_power_of_two, OpenGL::vertex_buffer_object, OpenGL::frame_buffer_object); #endif main_window->Initialise(); #ifdef SIMULATOR_AVAILABLE // prompt for simulator if not set by command line argument "-simulator" or "-fly" if (!sim_set_in_cmd_line_flag) { DialogLook white_look; white_look.Initialise(Fonts::map_bold, Fonts::map, Fonts::map_label, Fonts::map_bold, Fonts::map_bold, Fonts::map_bold); white_look.SetBackgroundColor(COLOR_WHITE); SetXMLDialogLook(white_look); SimulatorPromptResult result = dlgSimulatorPromptShowModal(); switch (result) { case SPR_QUIT: return false; case SPR_FLY: global_simulator_flag = false; break; case SPR_SIMULATOR: global_simulator_flag = true; break; } } #endif SetXMLDialogLook(main_window->GetLook().dialog); CommonInterface::SetSystemSettings().SetDefaults(); CommonInterface::SetComputerSettings().SetDefaults(); CommonInterface::SetUISettings().SetDefaults(); CommonInterface::SetUIState().Clear(); const auto &computer_settings = CommonInterface::GetComputerSettings(); const auto &ui_settings = CommonInterface::GetUISettings(); auto &live_blackboard = CommonInterface::GetLiveBlackboard(); if (!LoadProfile()) return false; operation.SetText(_("Initialising")); /* create XCSoarData on the first start */ CreateDataPath(); Display::LoadOrientation(operation); main_window->InitialiseConfigured(); TCHAR path[MAX_PATH]; LocalPath(path, _T("cache")); file_cache = new FileCache(path); ReadLanguageFile(); CommonInterface::status_messages.LoadFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard = new DeviceBlackboard(); DeviceListInitialise(); // Initialize Markers marks = new Markers(); protected_marks = new ProtectedMarkers(*marks); #ifdef HAVE_AYGSHELL_DLL const AYGShellDLL &ayg = main_window->ayg_shell_dll; ayg.SHSetAppKeyWndAssoc(VK_APP1, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP2, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP3, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP4, *main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems ayg.SHSetAppKeyWndAssoc(VK_APP5, *main_window); ayg.SHSetAppKeyWndAssoc(VK_APP6, *main_window); #endif // Initialize main blackboard data task_events = new GlideComputerTaskEvents(); task_manager = new TaskManager(computer_settings.task, way_points); task_manager->SetTaskEvents(*task_events); task_manager->Reset(); protected_task_manager = new ProtectedTaskManager(*task_manager, computer_settings.task); // Read the terrain file operation.SetText(_("Loading Terrain File...")); LogFormat("OpenTerrain"); terrain = RasterTerrain::OpenTerrain(file_cache, operation); logger = new Logger(); glide_computer = new GlideComputer(way_points, airspace_database, *protected_task_manager, *task_events); glide_computer->ReadComputerSettings(computer_settings); glide_computer->SetTerrain(terrain); glide_computer->SetLogger(logger); glide_computer->Initialise(); replay = new Replay(logger, *protected_task_manager); // Load the EGM96 geoid data EGM96::Load(); GlidePolar &gp = CommonInterface::SetComputerSettings().polar.glide_polar_task; gp = GlidePolar(fixed(0)); gp.SetMC(computer_settings.task.safety_mc); gp.SetBugs(computer_settings.polar.degradation_factor); PlaneGlue::FromProfile(CommonInterface::SetComputerSettings().plane); PlaneGlue::Synchronize(computer_settings.plane, CommonInterface::SetComputerSettings(), gp); task_manager->SetGlidePolar(gp); // Read the topography file(s) topography = new TopographyStore(); LoadConfiguredTopography(*topography, operation); // Read the waypoint files WaypointGlue::LoadWaypoints(way_points, terrain, operation); // Read and parse the airfield info file WaypointDetails::ReadFileFromProfile(way_points, operation); // Set the home waypoint WaypointGlue::SetHome(way_points, terrain, CommonInterface::SetComputerSettings().poi, CommonInterface::SetComputerSettings().team_code, device_blackboard, false); // ReSynchronise the blackboards here since SetHome touches them device_blackboard->Merge(); CommonInterface::ReadBlackboardBasic(device_blackboard->Basic()); // Scan for weather forecast LogFormat("RASP load"); RASP.ScanAll(CommonInterface::Basic().location, operation); // Reads the airspace files ReadAirspace(airspace_database, terrain, computer_settings.pressure, operation); { const AircraftState aircraft_state = ToAircraftState(device_blackboard->Basic(), device_blackboard->Calculated()); ProtectedAirspaceWarningManager::ExclusiveLease lease(glide_computer->GetAirspaceWarnings()); lease->Reset(aircraft_state); lease->SetConfig(computer_settings.airspace.warnings); } #ifdef HAVE_NOAA noaa_store = new NOAAStore(); noaa_store->LoadFromProfile(); #endif AudioVarioGlue::Initialise(); AudioVarioGlue::Configure(ui_settings.sound.vario); // Start the device thread(s) operation.SetText(_("Starting devices")); devStartup(); /* -- Reset polar in case devices need the data GlidePolar::UpdatePolar(true, computer_settings); This should be done inside devStartup if it is really required */ operation.SetText(_("Initialising display")); GlueMapWindow *map_window = main_window->GetMap(); if (map_window != NULL) { map_window->SetWaypoints(&way_points); map_window->SetTask(protected_task_manager); map_window->SetRoutePlanner(&glide_computer->GetProtectedRoutePlanner()); map_window->SetGlideComputer(glide_computer); map_window->SetAirspaces(&airspace_database); map_window->SetTopography(topography); map_window->SetTerrain(terrain); map_window->SetWeather(&RASP); map_window->SetMarks(protected_marks); map_window->SetLogger(logger); #ifdef HAVE_NOAA map_window->SetNOAAStore(noaa_store); #endif /* show map at home waypoint until GPS fix becomes available */ if (computer_settings.poi.home_location_available) map_window->SetLocation(computer_settings.poi.home_location); } // Finally ready to go.. all structures must be present before this. // Create the drawing thread #ifndef ENABLE_OPENGL draw_thread = new DrawThread(*map_window); draw_thread->Start(true); #endif // Show the infoboxes InfoBoxManager::Show(); // Create the calculation thread CreateCalculationThread(); // Find unique ID of this PDA ReadAssetNumber(); glide_computer_events = new GlideComputerEvents(); glide_computer_events->Reset(); live_blackboard.AddListener(*glide_computer_events); if (computer_settings.logger.enable_flight_logger) { flight_logger = new GlueFlightLogger(live_blackboard); LocalPath(path, _T("flights.log")); flight_logger->SetPath(path); } if (computer_settings.logger.enable_nmea_logger) NMEALogger::enabled = true; LogFormat("ProgramStarted"); // Give focus to the map main_window->SetDefaultFocus(); Pages::Initialise(ui_settings.pages); // Start calculation thread merge_thread->Start(); calculation_thread->Start(); #ifdef HAVE_TRACKING tracking = new TrackingGlue(); tracking->SetSettings(computer_settings.tracking); #ifdef HAVE_SKYLINES_TRACKING_HANDLER if (map_window != nullptr) map_window->SetSkyLinesData(&tracking->GetSkyLinesData()); #endif #endif assert(!global_running); global_running = true; AfterStartup(); operation.Hide(); main_window->FinishStartup(); return true; }
short dlgStartupShowModal(void) { WndProperty* wp = nullptr; #if TESTBENCH StartupStore(TEXT(". Startup dialog, RUN_MODE=%d %s"), RUN_MODE, NEWLINE); #endif switch(RUN_MODE) { case RUN_WELCOME: // FLY SIM PROFILE EXIT wf = InitFlySim(); break; case RUN_DUALPROF: // PROFILE AIRCRAFT CLOSE wf = InitDualProfile(); break; case RUN_PROFILE: case RUN_AIRCRAFT: case RUN_PILOT: case RUN_DEVICE: // CHOOSE PROFILE wf = InitStartup(RUN_MODE); break; } if (!wf) { return 0; } wf->SetHeight(ScreenSizeY); wf->SetWidth(ScreenSizeX); WindowControl* wSplash = wf->FindByName(TEXT("frmSplash")); if(wSplash) { wSplash->SetWidth(ScreenSizeX); // wSplash->SetHeight(ScreenSizeY);// - IBLSCALE(55)); } if (!CheckRootDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; LocalPath(mydir, _T("")); _stprintf(mes, _T("%s"), mydir); MessageBoxX(_T("NO LK8000 DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 000"), mbOk); MessageBoxX(mes, _T("NO LK8000 DIRECTORY"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } if (!CheckDataDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; SystemPath(mydir, _T(LKD_SYSTEM)); _stprintf(mes, _T("%s"), mydir); MessageBoxX(_T("NO SYSTEM DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 001"), mbOk); MessageBoxX(mes, _T("NO SYSTEM DIRECTORY"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } if (!CheckLanguageDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK LANGUAGE DIRECTORY FAILED!%s"), NEWLINE); LocalPath(mydir, _T(LKD_LANGUAGE)); _stprintf(mes, _T("%s"), mydir); MessageBoxX(_T("LANGUAGE DIRECTORY CHECK FAIL\nCheck Language Install"), _T("FATAL ERROR 002"), mbOk); MessageBoxX(mes, _T("NO LANGUAGE DIRECTORY"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } if (!CheckLanguageEngMsg()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK LANGUAGE ENG_MSG FAILED!%s"), NEWLINE); LocalPath(mydir, _T(LKD_LANGUAGE)); _stprintf(mes, _T("%s/ENG_MSG.TXT"), mydir); MessageBoxX(_T("ENG_MSG.TXT MISSING in LANGUAGE\nCheck Language Install"), _T("FATAL ERROR 012"), mbOk); MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } if (!CheckSystemDefaultMenu()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK SYSTEM DEFAULT_MENU.TXT FAILED!%s"), NEWLINE); SystemPath(mydir, _T(LKD_SYSTEM)); _stprintf(mes, _T("%s/DEFAULT_MENU.TXT"), mydir); MessageBoxX(_T("DEFAULT_MENU.TXT MISSING in SYSTEM\nCheck System Install"), _T("FATAL ERROR 022"), mbOk); MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } if (!CheckSystemBitmaps()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK SYSTEM _BITMAPSH FAILED!%s"), NEWLINE); SystemPath(mydir, _T(LKD_BITMAPS)); _stprintf(mes, _T("%s/_BITMAPSH"), mydir); MessageBoxX(_T("_BITMAPSH MISSING in SYSTEM Bitmaps\nCheck System Install"), _T("FATAL ERROR 032"), mbOk); MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } extern unsigned short Bitmaps_Errors; if (Bitmaps_Errors) { TCHAR mes[MAX_PATH]; _stprintf(mes, _T("MISSING %d SYSTEM BITMAPS! CHECK INSTALLATION."), Bitmaps_Errors); MessageBoxX(mes, _T("MISSING FILES!"), mbOk, true); } if (!CheckPolarsDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK POLARS DIRECTORY FAILED!%s"), NEWLINE); LocalPath(mydir, _T(LKD_POLARS)); _stprintf(mes, _T("%s"), mydir); MessageBoxX(_T("NO POLARS DIRECTORY\nCheck Install"), _T("FATAL ERROR 003"), mbOk); MessageBoxX(mes, _T("NO POLARS DIRECTORY"), mbOk, true); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } extern bool CheckFilesystemWritable(void); if (!CheckFilesystemWritable()) { MessageBoxX(_T("LK8000 CANNOT WRITE IN MEMORY CARD!\nCARD IS LOCKED, OR DAMAGED, OR FULL."), _T("CRITICAL PROBLEM"), mbOk); RUN_MODE = RUN_EXIT; Shutdown(); goto _exit; } // Standby for a system request to close the application during this phase. wf->SetTimerNotify(500, OnTimerNotify); if (wf->ShowModal() == mrCancel) { RUN_MODE = RUN_EXIT; } if (RUN_MODE == RUN_SHUTDOWN) goto _exit; wp = (WndProperty*) wf->FindByName(TEXT("prpProfile")); if (wp) { DataFieldFileReader* dfe = (DataFieldFileReader*) wp->GetDataField(); if (RUN_MODE == RUN_PROFILE) { if (_tcslen(dfe->GetPathFile()) > 0) { if (_tcscmp(dfe->GetPathFile(), startProfileFile)) { // if they are not the same _tcscpy(startProfileFile, dfe->GetPathFile()); if (_tcscmp(startProfileFile, _T("PROFILE_RESET")) == 0) { #if TESTBENCH StartupStore(_T("... Selected FULL RESET virtual profile\n")); #endif MessageBoxX(MsgToken(1758), MsgToken(1757), mbOk); FullResetAsked = true; } else { #if TESTBENCH StartupStore(_T("... Selected new profile, preloading..\n")); #endif FullResetAsked = false; } } } } if (RUN_MODE == RUN_AIRCRAFT) { if (_tcslen(dfe->GetPathFile()) > 0) { if (_tcscmp(dfe->GetPathFile(), startAircraftFile)) { // if they are not the same _tcscpy(startAircraftFile, dfe->GetPathFile()); #if TESTBENCH StartupStore(_T("... Selected new aircraft, preloading..\n")); #endif } } } if (RUN_MODE == RUN_DEVICE) { if (_tcslen(dfe->GetPathFile()) > 0) { if (_tcscmp(dfe->GetPathFile(), startDeviceFile)) { // if they are not the same _tcscpy(startDeviceFile, dfe->GetPathFile()); #if TESTBENCH StartupStore(_T("... Selected new device, preloading..\n")); #endif } } } if (RUN_MODE == RUN_PILOT) { if (_tcslen(dfe->GetPathFile()) > 0) { if (_tcscmp(dfe->GetPathFile(), startPilotFile)) { // if they are not the same _tcscpy(startPilotFile, dfe->GetPathFile()); #if TESTBENCH StartupStore(_T("... Selected new pilot, preloading..\n")); #endif } } } RUN_MODE = RUN_DUALPROF; } if (RUN_MODE == RUN_EXIT) { #if __linux__ RUN_MODE = RUN_WELCOME; #endif LKSound(_T("LK_SLIDE.WAV")); if (MessageBoxX( // LKTOKEN _@M198_ = "Confirm Exit?" MsgToken(198), TEXT("LK8000"), mbYesNo) == IdYes) { Shutdown(); } else { RUN_MODE = RUN_WELCOME; } } _exit: if (wf != NULL) { delete wf; wf = NULL; } StartBitmap.Release(); ProfileBitmap.Release(); if (RUN_MODE == RUN_FLY || RUN_MODE == RUN_SIM) { LKSound(_T("LK_SLIDE.WAV")); return 0; // do not repeat dialog } if (RUN_MODE == RUN_EXIT || RUN_MODE == RUN_SHUTDOWN) return -1; // terminate else return 1; // repeat dialog }
HWND CreateProgressDialog(TCHAR* text) { static int yFontSize, xFontSize; HDC hTempDC = NULL; if (doinitprogress) { doinitprogress=false; DWORD Style=0; Style = WS_CHILD | ES_MULTILINE | ES_CENTER | ES_READONLY | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; hStartupWindow=CreateWindow(TEXT("STATIC"), TEXT("\0"), Style, 0, 0, ScreenSizeX, ScreenSizeY, hWndMainWindow, NULL, hInst, NULL); if (hStartupWindow==NULL) { StartupStore(_T("***** CRITIC, no startup window!%s"),NEWLINE); return NULL; } if (!(hStartupDC = GetDC(hStartupWindow))) { StartupStore(_T("------ Cannot state startup window%s"),NEWLINE); return(NULL); } /* SHFullScreen(hProgress, SHFS_HIDETASKBAR |SHFS_HIDESIPBUTTON |SHFS_HIDESTARTICON); SetWindowPos(hProgress,HWND_TOP,0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); */ //RECT rt; //GetClientRect(hStartupWindow,&rt); //FillRect(hStartupDC,&rt,(HBRUSH)GetStockObject(BLACK_BRUSH)); //SetWindowPos(hStartupWindow,HWND_TOP,0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); //SHFullScreen(hStartupWindow, SHFS_HIDETASKBAR |SHFS_HIDESIPBUTTON |SHFS_HIDESTARTICON); //SetForegroundWindow(hStartupWindow); //UpdateWindow(hStartupWindow); ShowWindow(hStartupWindow,SW_SHOWNORMAL); BringWindowToTop(hStartupWindow); // Load welcome screen bitmap HBITMAP hWelcomeBitmap=NULL; TCHAR sDir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; LocalPath(sDir,TEXT(LKD_BITMAPS)); // first look for lkstart_480x272.bmp for example _stprintf(srcfile,_T("%s\\LKSTART_%s.BMP"),sDir, GetSizeSuffix() ); if ( GetFileAttributes(srcfile) == 0xffffffff ) { // no custom file, get a generic one switch(ScreenSize) { case ss800x480: case ss640x480: case ss720x408: case ss896x672: _stprintf(srcfile,_T("%s\\LKSTART_LB.BMP"),sDir); break; case ss480x272: case ss480x234: case ss400x240: case ss320x240: _stprintf(srcfile,_T("%s\\LKSTART_LS.BMP"),sDir); break; case ss480x640: case ss480x800: _stprintf(srcfile,_T("%s\\LKSTART_PB.BMP"),sDir); break; case ss240x320: case ss272x480: _stprintf(srcfile,_T("%s\\LKSTART_PS.BMP"),sDir); break; default: _stprintf(srcfile,_T("%s\\LKSTART_DEFAULT.BMP"),sDir); break; } } #if (WINDOWSPC>0) hWelcomeBitmap=(HBITMAP)LoadImage(GetModuleHandle(NULL),srcfile,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); #else hWelcomeBitmap=(HBITMAP)SHLoadDIBitmap(srcfile); #endif // still nothing? use internal (poor man) resource if (hWelcomeBitmap==NULL) hWelcomeBitmap=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SWIFT)); hTempDC = CreateCompatibleDC(hStartupDC); // AA HBITMAP oldBitmap = (HBITMAP)SelectObject(hTempDC, hWelcomeBitmap); SelectObject(hTempDC, LKSTARTBOTTOMFONT); SIZE TextSize; GetTextExtentPoint(hTempDC, _T("X"),1, &TextSize); yFontSize = TextSize.cy; xFontSize = TextSize.cx; BITMAP bm; GetObject(hWelcomeBitmap,sizeof(bm), &bm); StretchBlt(hStartupDC,0,0, ScreenSizeX,ScreenSizeY-1, hTempDC, 0, 0, 2,2, BLACKNESS); if ( (bm.bmWidth >ScreenSizeX)||(bm.bmHeight>ScreenSizeY)) { StretchBlt(hStartupDC,0,0, ScreenSizeX,ScreenSizeY-NIBLSCALE(2)-(yFontSize*2)-1, hTempDC, 0, 0, bm.bmWidth,bm.bmHeight, SRCCOPY); } else { BitBlt(hStartupDC,(ScreenSizeX-bm.bmWidth)/2,0,bm.bmWidth,bm.bmHeight,hTempDC, 0, 0, SRCCOPY); } // AA SelectObject(hTempDC, oldBitmap); DeleteObject(hWelcomeBitmap); if (DeleteDC(hTempDC)==0) StartupStore(_T("**** Cannot delete hTempDC\n")); } BringWindowToTop(hStartupWindow); // we shall return here also on shutdown and file reloads // RECT is left, top, right, bottom RECT PrintAreaR; PrintAreaR.left = NIBLSCALE(2); PrintAreaR.bottom = ScreenSizeY-NIBLSCALE(2); PrintAreaR.top = PrintAreaR.bottom - (yFontSize*2); PrintAreaR.right = ScreenSizeX - NIBLSCALE(2); HFONT oldFont=(HFONT)SelectObject(hStartupDC,LKSTARTBOTTOMFONT); HBRUSH hB=LKBrush_Petrol; FillRect(hStartupDC,&PrintAreaR, hB); // Create text area // we cannot use LKPen here because they are not still initialised for startup menu. no problem HPEN hP=(HPEN) CreatePen(PS_SOLID,NIBLSCALE(1),RGB_GREEN); SelectObject(hStartupDC,hP); SelectObject(hStartupDC,hB); Rectangle(hStartupDC, PrintAreaR.left,PrintAreaR.top,PrintAreaR.right,PrintAreaR.bottom); DeleteObject(hP); hP=(HPEN) CreatePen(PS_SOLID,NIBLSCALE(1),RGB_BLACK); SelectObject(hStartupDC,hP); Rectangle(hStartupDC, PrintAreaR.left+NIBLSCALE(2),PrintAreaR.top+NIBLSCALE(2),PrintAreaR.right-NIBLSCALE(2),PrintAreaR.bottom-NIBLSCALE(2)); SetTextColor(hStartupDC,RGB_WHITE); SetBkMode(hStartupDC,TRANSPARENT); unsigned int maxchars= (ScreenSizeX/xFontSize)-1; if (_tcslen(text) <maxchars) { maxchars=_tcslen(text); } ExtTextOut(hStartupDC,PrintAreaR.left+(xFontSize/2),PrintAreaR.top + ((PrintAreaR.bottom - PrintAreaR.top)/2)-(yFontSize/2), ETO_OPAQUE,NULL,text,maxchars,NULL); SelectObject(hStartupDC,oldFont); // Sleep(300); // Slow down display of data? No because in case of important things, Sleep is set by calling part DeleteObject(hP); return hStartupWindow; }
static void OnSplashPaint(WindowControl * Sender, LKSurface& Surface) { TCHAR srcfile[MAX_PATH]; if (RUN_MODE == RUN_SHUTDOWN) return; if(RUN_MODE == RUN_WELCOME) { if(!StartBitmap) { StartBitmap = LoadSplash(_T("LKSTART")); } if(StartBitmap) { DrawSplash(Surface, StartBitmap); } } else { if(!ProfileBitmap) { ProfileBitmap = LoadSplash(_T("LKPROFILE")); } if(ProfileBitmap) { DrawSplash(Surface, ProfileBitmap); } } if (RUN_MODE == RUN_WELCOME) { TCHAR mes[100]; int pos = 0; switch (ScreenSize) { case ss480x272: if (ScreenSizeX == 854) pos = 14; else #ifdef __linux__ pos = 12; #else pos = 11; #endif break; // --------- portrait ------------- case ss240x320: #ifdef __linux__ pos = 19; #else pos = 17; #endif break; default: // customized definition if (ScreenLandscape) { switch (ScreenGeometry) { case SCREEN_GEOMETRY_43: pos = 12; break; case SCREEN_GEOMETRY_53: pos = 12; break; case SCREEN_GEOMETRY_169: pos = 11; break; default: pos = 11; break; } } else { // Portrait // try to get a rule for text position... switch (ScreenGeometry) { case SCREEN_GEOMETRY_43: #ifdef __linux__ pos = 18; #else pos = 17; #endif break; case SCREEN_GEOMETRY_53: pos = 20; break; case SCREEN_GEOMETRY_169: #ifdef __linux__ pos = 22; #else pos = 20; #endif break; default: pos = 21; break; } } break; } if (FullResetAsked) { _stprintf(mes, _T("*** %s ***"), MsgToken(1757)); RawWrite(Surface, mes, pos, 1, RGBDARKWHITE, WTMODE_NORMAL); } else { #ifndef LKCOMPETITION _stprintf(mes, _T("Version %s.%s (%s)"), _T(LKVERSION), _T(LKRELEASE), _T(__DATE__)); #else _stprintf(mes, _T("V%s.%s (%s) COMPETITION"), _T(LKVERSION), _T(LKRELEASE), _T(__DATE__)); #endif RawWrite(Surface, mes, pos, 1, RGBDARKWHITE, WTMODE_NORMAL); #ifdef KOBO if(IsKoboOTGKernel()) { RawWrite(Surface, _T("- USB host kernel -"), pos+1, 1, RGBDARKWHITE, WTMODE_NORMAL); } #endif } } if (RUN_MODE != RUN_WELCOME) { // FillRect(hDC,&ScreenSizeR, LKBrush_Black); // REMOVE TCHAR mes[100]; #ifndef LKCOMPETITION _stprintf(mes, _T("%s v%s.%s - %s"), _T(LKFORK), _T(LKVERSION), _T(LKRELEASE), MsgToken(2054)); #else _stprintf(mes, _T("%sC v%s.%s - %s"), _T(LKFORK), _T(LKVERSION), _T(LKRELEASE), MsgToken(2054)); #endif #ifdef DITHER RawWrite(Surface, mes, 1, 1, RGBLIGHTGREY, WTMODE_OUTLINED); #else RawWrite(Surface, mes, 1, 1, RGBLIGHTGREY, WTMODE_NORMAL); #endif size_t freeram = CheckFreeRam() / 1024; TCHAR buffer[MAX_PATH]; LocalPath(buffer); size_t freestorage = FindFreeSpace(buffer); _stprintf(mes, _T("free ram %.1uM storage %.1uM"), (unsigned int) freeram / 1024, (unsigned int) freestorage / 1024); #ifdef DITHER RawWrite(Surface, mes, 3, 0, RGBLIGHTGREY, WTMODE_OUTLINED); #else RawWrite(Surface, mes, 3, 0, RGBLIGHTGREY, WTMODE_NORMAL); #endif if (ScreenSize != ss320x240 && ScreenLandscape) RawWrite(Surface, _T("_______________________"), 2, 2, RGBLIGHTGREY, WTMODE_NORMAL); if (FullResetAsked) { _stprintf(mes, _T("%s"), MsgToken(1757)); // LK8000 PROFILES RESET RawWrite(Surface, mes, 5, 2, RGBICEWHITE, WTMODE_OUTLINED); _stprintf(mes, _T("%s"), MsgToken(1759)); // SELECTED IN SYSTEM RawWrite(Surface, mes, 6, 2, RGBICEWHITE, WTMODE_OUTLINED); } else { _stprintf(mes, _T("%s"), PilotName_Config); RawWrite(Surface, mes, 4, 2, RGBICEWHITE, WTMODE_OUTLINED); _stprintf(mes, _T("%s"), AircraftRego_Config); RawWrite(Surface, mes, 5, 2, RGBAMBER, WTMODE_OUTLINED); _stprintf(mes, _T("%s"), AircraftType_Config); RawWrite(Surface, mes, 6, 2, RGBAMBER, WTMODE_OUTLINED); LKASSERT(szPolarFile[0]); extern void LK_tsplitpath(const TCHAR* path, TCHAR* drv, TCHAR* dir, TCHAR* name, TCHAR * ext); LK_tsplitpath(szPolarFile, (TCHAR*) NULL, (TCHAR*) NULL, srcfile, (TCHAR*) NULL); _stprintf(mes, _T("%s %s"), MsgToken(528), srcfile); // polar file RawWrite(Surface, mes, 7, 2, RGBAMBER, WTMODE_OUTLINED); LKASSERT(startProfileFile[0]); LK_tsplitpath(startProfileFile, (TCHAR*) NULL, (TCHAR*) NULL, srcfile, (TCHAR*) NULL); _stprintf(mes, _T("%s: %s"), MsgToken(1746), srcfile); RawWrite(Surface, mes, 11, 1, RGBICEWHITE, WTMODE_NORMAL); } // RawWrite(hDC,_T("_______________________"),8,2, RGB_LIGHTGREY,WTMODE_NORMAL); // REMOVE FOR THE 3.0 return; } }
// Rescale automatically dialogs, using negative values to force rescaling // Notice: SHOULD BE CALLED ONLY IF rWidth is negative, in order to avoid useless SetWindowPos int RescaleWidth(const int rWidth) { // Always rescale negative widths if (rWidth <-1) { // Special case is when width is also the scale unit, which demonstrate we have a bug to fix here! #if USEIBOX if (rWidth == (int)(-246*InfoBoxLayout::dscale)){ #else if (rWidth == (int)(-246*ScreenDScale)){ #endif return LKwdlgConfig; } double i=(246.0 / abs(rWidth)); if (i==0) { FailStore(_T("INTERNAL ERROR RESCALEWIDTH rWidth=%d"),rWidth); DoStatusMessage(_T("RESCALE ERR-001")); return rWidth; } #if USEIBOX int ri=(int)( (LKwdlgConfig/i) *InfoBoxLayout::dscale ); #else int ri=(int)( (LKwdlgConfig/i) *ScreenDScale ); #endif // StartupStore(_T("... RescaleWidth(): rescale %d to %d\n"),rWidth, ri); if (ri>ScreenSizeX) return(ScreenSizeX); return (ri); } // else use the incoming rWidth but it is clearly an error DoStatusMessage(_T("RESCALE WARN-001")); return rWidth; } void ChangeWindCalcSpeed(const int newspeed) { WindCalcSpeed += (double)newspeed/SPEEDMODIFY; } // runmode 0: exec inside LocalPath home of LK8000 // runmode 1: exec inside bool LKRun(const TCHAR *prog, const int runmode, const DWORD dwaitime) { if (_tcslen(prog) <5) { StartupStore(_T("... LKRun failure: invalid exec path <%s>%s"),prog,NEWLINE); return false; } TCHAR path[MAX_PATH]; if (runmode<0 || runmode>1) { StartupStore(_T("... LKRun failure: invalid runmode=%d %s"),runmode,NEWLINE); return false; } // mode 0: localpath , forced execution, with warnings if something goes wrong // mode 1: optional execution, no warnings if nothing found if (runmode<2) { LocalPath(path,prog); if (runmode==0) StartupStore(_T(". LKRun: exec <%s> background=%u%s"),path,dwaitime,NEWLINE); PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si,sizeof(STARTUPINFO)); si.cb=sizeof(STARTUPINFO); si.wShowWindow= SW_SHOWNORMAL; si.dwFlags = STARTF_USESHOWWINDOW; // if (!::CreateProcess(_T("C:\\WINDOWS\\notepad.exe"),_T(""), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if (!::CreateProcess(path,_T(""), NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { if (runmode==0) StartupStore(_T("... LKRun exec FAILED%s"),NEWLINE); return false; } ::WaitForSingleObject(pi.hProcess, dwaitime); StartupStore(_T(". LKRun exec terminated%s"),NEWLINE); return true; } return false; } void GotoWaypoint(const int wpnum) { if (!ValidWayPoint(wpnum)) { DoStatusMessage(_T("ERR-639 INVALID GOTO WPT")); return; } if (ValidTaskPoint(ActiveWayPoint) && ValidTaskPoint(1)) { TCHAR wpname[NAME_SIZE+1]; _tcscpy(wpname,WayPointList[wpnum].Name); wpname[10] = '\0'; if (MessageBoxX(hWndMapWindow, // LKTOKEN _@M158_ = "CONFIRM GOTO, ABORTING TASK?" gettext(TEXT("_@M158_")), // LKTOKEN _@M40_ = "A task is running!" gettext(TEXT("_@M40_")), MB_YESNO|MB_ICONQUESTION) == IDYES) { LockTaskData(); FlyDirectTo(wpnum); OvertargetMode=OVT_TASK; UnlockTaskData(); } } else { LockTaskData(); FlyDirectTo(wpnum); OvertargetMode=OVT_TASK; UnlockTaskData(); } } void ToggleBaroAltitude() { if (!GPS_INFO.BaroAltitudeAvailable) { // LKTOKEN _@M121_ = "BARO ALTITUDE NOT AVAILABLE" DoStatusMessage(gettext(TEXT("_@M121_"))); return; } EnableNavBaroAltitude=!EnableNavBaroAltitude; if (EnableNavBaroAltitude) // LKTOKEN _@M756_ = "USING BARO ALTITUDE" DoStatusMessage(gettext(TEXT("_@M756_"))); else // LKTOKEN _@M757_ = "USING GPS ALTITUDE" DoStatusMessage(gettext(TEXT("_@M757_"))); } TCHAR * GetSizeSuffix(void) { static TCHAR suffixname[12]; _stprintf(suffixname,_T("%03dx%03d"),ScreenSizeX,ScreenSizeY); return(suffixname); } void LKRunStartEnd(bool start) { if (start) { LKRun(_T("PREROTATE1.EXE"),1,5000); LKRun(_T("PREROTATE2.EXE"),1,5000); LKRun(_T("PREROTATE3.EXE"),1,5000); LKRun(_T("PRELOAD_00.EXE"),1,0); LKRun(_T("PRELOAD_05.EXE"),1,5000); LKRun(_T("PRELOAD_30.EXE"),1,30000); LKRun(_T("PRELOAD_60.EXE"),1,60000); LKRun(_T("PRELOAD_99.EXE"),1,INFINITE); } else { LKRun(_T("ENDLOAD_00.EXE"),1,0); LKRun(_T("ENDLOAD_05.EXE"),1,5000); LKRun(_T("ENDLOAD_30.EXE"),1,30000); LKRun(_T("ENDLOAD_60.EXE"),1,60000); LKRun(_T("ENDROTATE1.EXE"),1,5000); LKRun(_T("ENDROTATE2.EXE"),1,5000); LKRun(_T("ENDROTATE3.EXE"),1,5000); LKRun(_T("ENDLOAD_99.EXE"),1,INFINITE); } } // Reads line from UTF-8 encoded text file. // File must be open in binary read mode. bool ReadULine(ZZIP_FILE* fp, TCHAR *unicode, int maxChars) { unsigned char buf[READLINE_LENGTH * 2]; long startPos = zzip_tell(fp); if (startPos < 0) { StartupStore(_T(". ftell() error = %d%s"), errno, NEWLINE); return(false); } size_t nbRead = zzip_fread(buf, 1, sizeof(buf) - 1, fp); if (nbRead == 0) return(false); buf[nbRead] = '\0'; // find new line (CR/LF/CRLF) in the string and terminate string at that position size_t i; for (i = 0; i < nbRead; i++) { if (buf[i] == '\n') { buf[i++] = '\0'; if (buf[i] == '\r') i++; break; } if (buf[i] == '\r') { buf[i++] = '\0'; if (buf[i] == '\n') i++; break; } } // next reading will continue after new line zzip_seek(fp, startPos + i, SEEK_SET); // skip leading BOM char* begin = (char*) buf; if (buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) begin += 3; return(utf2unicode(begin, unicode, maxChars) >= 0); }
void LoggerImpl::StartLogger(const NMEA_INFO &gps_info, const SETTINGS_COMPUTER &settings, const TCHAR *astrAssetNumber) { HANDLE hFile; int i; TCHAR path[MAX_PATH]; TCHAR cAsset[3]; for (i=0; i < 3; i++) { // chars must be legal in file names cAsset[i] = IsAlphaNum(strAssetNumber[i]) ? strAssetNumber[i] : _T('A'); } // VENTA3 use logs subdirectory when not in main memory (true for FIVV and PNA) #if defined(GNAV) || defined(FIVV) || defined(PNA) LocalPath(path,TEXT("logs")); #else LocalPath(path); #endif if (task.isTaskModified()) { task.SaveDefaultTask(); } #ifdef WINDOWSPC _stprintf(szLoggerFileName, TEXT("/tmp/tmp.IGC")); #else _stprintf(szLoggerFileName, TEXT("\\tmp.IGC")); #endif DeleteFile(szLoggerFileName); LoggerGInit(); for(i=1;i<99;i++) { // 2003-12-31-XXX-987-01.IGC // long filename form of IGC file. // XXX represents manufacturer code if (!settings.LoggerShortName) { // Long file name _stprintf(szFLoggerFileName, TEXT("%s\\%04d-%02d-%02d-XCS-%c%c%c-%02d.IGC"), path, gps_info.Year, gps_info.Month, gps_info.Day, cAsset[0], cAsset[1], cAsset[2], i); _stprintf(szFLoggerFileNameRoot, TEXT("%s\\%04d-%02d-%02d-XCS-%c%c%c-%02d.IGC"), TEXT(""), // this creates it in root if MoveFile() fails gps_info.Year, gps_info.Month, gps_info.Day, cAsset[0], cAsset[1], cAsset[2], i); } else { // Short file name TCHAR cyear, cmonth, cday, cflight; cyear = NumToIGCChar((int)gps_info.Year % 10); cmonth = NumToIGCChar(gps_info.Month); cday = NumToIGCChar(gps_info.Day); cflight = NumToIGCChar(i); _stprintf(szFLoggerFileName, TEXT("%s\\%c%c%cX%c%c%c%c.IGC"), path, cyear, cmonth, cday, cAsset[0], cAsset[1], cAsset[2], cflight); _stprintf(szFLoggerFileNameRoot, TEXT("%s\\%c%c%cX%c%c%c%c.IGC"), TEXT(""), // this creates it in root if MoveFile() fails cyear, cmonth, cday, cAsset[0], cAsset[1], cAsset[2], cflight); } // end if hFile = CreateFile(szFLoggerFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if(hFile!=INVALID_HANDLE_VALUE ) { // file already exists CloseHandle(hFile); DeleteFile(szFLoggerFileName); break; } } // end while TCHAR szMessage[MAX_PATH] = TEXT("\0"); _tcsncpy(szMessage,TEXT("Logger Started: "),MAX_PATH); _tcsncat(szMessage,szFLoggerFileName,MAX_PATH); _tcsncat(szMessage,TEXT("\r\n"),MAX_PATH); StartupStore(szMessage); return; }
// This will NOT be called from PC versions short InstallSystem() { TCHAR srcdir[MAX_PATH]; TCHAR dstdir[MAX_PATH]; TCHAR maindir[MAX_PATH]; TCHAR fontdir[MAX_PATH]; TCHAR srcfile[MAX_PATH]; TCHAR dstfile[MAX_PATH]; TCHAR tbuf[MAX_PATH*3]; #if (0) DWORD attrib; #endif bool failure=false; #if TESTBENCH StartupStore(_T(". Welcome to InstallSystem v1.2%s"),NEWLINE); #endif LocalPath(srcdir,TEXT(LKD_SYSTEM)); dstdir[0]='\0'; // search for the main system directory on the real device // Remember that SHGetSpecialFolder works differently on CE platforms, and you cannot check for result. // We need to verify if directory does really exist. // SHGetSpecialFolderPath(hWndMainWindow, dstdir, CSIDL_WINDOWS, false); if ( _tcslen(dstdir) <6) { _stprintf(tbuf,_T("------ InstallSystem PROBLEM: cannot locate the Windows folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); StartupStore(_T("------ InstallSystem attempting to use default \"\\Windows\" but no warranty!%s"),NEWLINE); _stprintf(dstdir,TEXT("\\Windows")); // 091118 } else { StartupStore(_T(". InstallSystem: Windows path reported from device is: <%s>%s"),dstdir,NEWLINE); } _tcscpy(maindir,dstdir); // We now test for a single file existing inside the directory, called _DIRECTORYNAME // because GetFileAttributes can be very slow or hang if checking a directory. In any case testing a file is // much more faster. _stprintf(srcfile,TEXT("%s\\_SYSTEM"),srcdir); if ( !lk::filesystem::exist(srcfile) ) { StartupStore(_T("------ InstallSystem ERROR could not find valid system directory <%s>%s"),srcdir,NEWLINE); // 091104 StartupStore(_T("------ Missing checkfile <%s>%s"),srcfile,NEWLINE); failure=true; } else { #if TESTBENCH StartupStore(_T(". InstallSystem source directory <%s> is available%s"),srcdir,NEWLINE); #endif } if ( failure ) { StartupStore(_T("------ WARNING: NO font will be installed on device (and thus wrong text size displayed)%s"),NEWLINE); return 5; // 091109 } else { #if defined(PNA) && defined(UNDER_CE) if (GlobalModelType == MODELTYPE_PNA_HP31X) { // 091109 StartupStore(_T(". InstallSystem checking desktop links for HP31X%s"),NEWLINE); _stprintf(dstdir,TEXT("\\Windows\\Desktop")); if ( !lk::filesystem::isDirectory(dstdir) ) { // FIX StartupStore(_T("------ Desktop directory <%s> NOT found! Is this REALLY an HP31X?%s"),dstdir,NEWLINE); } else { _stprintf(srcfile,TEXT("%s\\LK8_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\LK8000.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to LK8000 already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } #if 0 _stprintf(srcfile,TEXT("%s\\LK8SIM_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\SIM.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to SIM LK8000 already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } #endif _stprintf(srcfile,TEXT("%s\\BT_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\BlueTooth.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to BlueTooth already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } _stprintf(srcfile,TEXT("%s\\NAV_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\CarNav.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to Car Navigator already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } _stprintf(srcfile,TEXT("%s\\TLOCK_HP310.lnk"),srcdir); _stprintf(dstfile,TEXT("%s\\TouchLock.lnk"),dstdir); if ( lk::filesystem::exist(dstfile) ) { StartupStore(_T(". Link to TouchLock already found on the desktop, ok.%s"),NEWLINE); } else { StartupStore(_T(". Installing <%s>%s"),srcfile,NEWLINE); if (!lk::filesystem::copyFile(srcfile,dstfile,true)) { StartupStore(_T("------ Could not install in <%s>. Strange.%s"),dstfile,NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T(". Installed <%s> link.%s"),dstfile,NEWLINE); } } } #endif } // we are shure that \Windows does exist already. fontdir[0] = _T('\0'); dstdir[0] = _T('\0'); #ifdef PNA if ( GetFontPath(fontdir) == FALSE ) { StartupStore(_T(". Special RegKey for fonts not found on this PNA, using standard folder.%s"), NEWLINE); // SHGetSpecialFolderPath(hWndMainWindow, dstdir, CSIDL_FONTS, false); if ( _tcslen(dstdir) <5 ) { _stprintf(tbuf,_T("------ PROBLEM: cannot locate the Fonts folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); _stprintf(tbuf,_T("------ Attempting to use directory <%s> as a fallback%s"),maindir,NEWLINE); StartupStore(tbuf); _tcscpy(dstdir,maindir); } } else { StartupStore(_T(". RegKey Font directory is <%s>%s"),fontdir,NEWLINE); lk::filesystem::createDirectory(fontdir); _tcscpy(dstdir,fontdir); } #else UNUSED(fontdir); // this is not working correctly on PNA, it is reporting Windows Fonts even with another value in regkey SHGetSpecialFolderPath(hWndMainWindow, dstdir, CSIDL_FONTS, false); if ( _tcslen(dstdir) <5 ) { _stprintf(tbuf,_T("------ PROBLEM: cannot locate the Fonts folder, got string:<%s>%s"),dstdir,NEWLINE); StartupStore(tbuf); _stprintf(tbuf,_T("------ Attempting to use directory <%s> as a fallback%s"),maindir,NEWLINE); StartupStore(tbuf); _tcscpy(dstdir,maindir); } #endif _stprintf(tbuf,_T(". InstallSystem: Copy/Check Fonts from <%s> to <%s>%s"), srcdir, dstdir,NEWLINE); StartupStore(tbuf); // on PNAs sometimes FolderPath is reported correctly, but the directory is not existing! // this is not needed really on PNA, but doesnt hurt lk::filesystem::createDirectory(dstdir); // 100820 // we cannot check directory existance without the risk of hanging for many seconds // we can only rely on singe real file existance, not on directories #if TESTBENCH StartupStore(_T(". Checking TAHOMA font%s"),NEWLINE); #endif _stprintf(srcfile,TEXT("%s\\TAHOMA.TTF"),srcdir); _stprintf(dstfile,TEXT("%s\\TAHOMA.TTF"),dstdir); if ( lk::filesystem::exist(dstfile) ) { #if TESTBENCH StartupStore(_T(". Font TAHOMA.TTF is already installed%s"),NEWLINE); #endif } else { if ( !lk::filesystem::copyFile(srcfile,dstfile,false) ) { StartupStore(_T("------ Could not copy TAHOMA.TTF on device, not good.%s"),NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T("... Font TAHOMA.TTF installed on device%s"),NEWLINE); } // not needed, cannot overwrite tahoma while in use! Tahoma bold not used for some reason in this case. // Problem solved, look at FontPath !! #if TESTBENCH StartupStore(_T(". Checking TAHOMABD font%s"),NEWLINE); #endif _stprintf(srcfile,TEXT("%s\\TAHOMABD.TTF"),srcdir); _stprintf(dstfile,TEXT("%s\\TAHOMABD.TTF"),dstdir); if ( lk::filesystem::exist(dstfile) ) { #if TESTBENCH StartupStore(_T(". Font TAHOMABD.TTF is already installed%s"),NEWLINE); #endif } else { if ( !lk::filesystem::copyFile(srcfile,dstfile,false)) { StartupStore(_T("------ Could not copy TAHOMABD.TTF on device, not good.%s"),NEWLINE); StartupStore(_T("------ Error code was: %ld%s"),GetLastError(),NEWLINE); } else StartupStore(_T("... Font TAHOMABD.TTF installed on device%s"),NEWLINE); } #if TESTBENCH StartupStore(_T(". InstallSystem completed OK%s"),NEWLINE); #endif return 0; }
void dlgWaypointDetailsShowModal(SingleWindow &parent, const Waypoint &_waypoint, bool allow_navigation) { waypoint = &_waypoint; wf = LoadDialog(CallBackTable, parent, Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") : _T("IDR_XML_WAYPOINTDETAILS")); assert(wf != NULL); LastUsedWaypoints::Add(_waypoint); UpdateCaption(waypoint->name.c_str(), waypoint->file_num); wf->SetKeyDownNotify(FormKeyDown); wInfo = (DockWindow *)wf->FindByName(_T("info")); assert(wInfo != NULL); wInfo->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(), _waypoint)); wCommand = (DockWindow *)wf->FindByName(_T("commands")); assert(wCommand != NULL); wCommand->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(), wf, _waypoint, protected_task_manager)); wCommand->Hide(); wDetails = wf->FindByName(_T("frmDetails")); assert(wDetails != NULL); ListControl *wFilesList = (ListControl *)wf->FindByName(_T("Files")); assert(wFilesList != NULL); EditWindow *wDetailsText = (EditWindow *)wf->FindByName(_T("Details")); assert(wDetailsText != NULL); wDetailsText->SetText(waypoint->details.c_str()); #ifdef ANDROID int num_files = std::distance(waypoint->files_external.begin(), waypoint->files_external.end()); if (num_files > 0) { wFilesList->SetPaintItemCallback(OnFileListItemPaint); wFilesList->SetCursorCallback(OnFileListEnter); wFilesList->SetActivateCallback(OnFileListEnter); unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5); wFilesList->Resize(wFilesList->GetWidth(), list_height); wFilesList->SetLength(num_files); PixelRect rc = wDetailsText->GetPosition(); rc.top += list_height; wDetailsText->Move(rc); } else #endif wFilesList->Hide(); wImage = (PaintWindow *)wf->FindByName(_T("frmImage")); assert(wImage != NULL); wMagnify = (WndButton *)wf->FindByName(_T("cmdMagnify")); assert(wMagnify != NULL); wShrink = (WndButton *)wf->FindByName(_T("cmdShrink")); assert(wShrink != NULL); if (!allow_navigation) { WndButton* butnav = (WndButton *)wf->FindByName(_T("cmdPrev")); assert(butnav != NULL); butnav->Hide(); butnav = (WndButton *)wf->FindByName(_T("cmdNext")); assert(butnav != NULL); butnav->Hide(); butnav = (WndButton *)wf->FindByName(_T("cmdGoto")); assert(butnav != NULL); butnav->Hide(); } for (auto it = waypoint->files_embed.begin(), it_end = waypoint->files_embed.end(); it != it_end && !images.full(); it++) { TCHAR path[MAX_PATH]; LocalPath(path, it->c_str()); if (!images.append().LoadFile(path)) images.shrink(images.size() - 1); } page = 0; NextPage(0); // JMW just to turn proper pages on/off wf->ShowModal(); delete wf; for (auto image = images.begin(); image < images.end(); image++) image->Reset(); images.clear(); }
bool CheckRootDir() { TCHAR rootdir[MAX_PATH]; LocalPath(rootdir,_T("")); return lk::filesystem::isDirectory(rootdir); }
short dlgStartupShowModal(void){ WndProperty* wp; #if TESTBENCH StartupStore(TEXT(". Startup dialog, RUN_MODE=%d %s"),RUN_MODE,NEWLINE); #endif char filename[MAX_PATH]; strcpy(filename,""); // FLY SIM PROFILE EXIT if (RUN_MODE==RUN_WELCOME) { if (!ScreenLandscape) { LocalPathS(filename, TEXT("dlgFlySim_L.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_FLYSIM_L")); } else { LocalPathS(filename, TEXT("dlgFlySim.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_FLYSIM")); } if (!wf) { return 0; } } // PROFILE AIRCRAFT CLOSE if (RUN_MODE==RUN_DUALPROF) { if (!ScreenLandscape) { LocalPathS(filename, TEXT("dlgDualProfile_L.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_DUALPROFILE_L")); } else { LocalPathS(filename, TEXT("dlgDualProfile.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_DUALPROFILE")); } if (!wf) return 0; } // CHOOSE PROFILE if (RUN_MODE==RUN_PROFILE || RUN_MODE==RUN_AIRCRAFT || RUN_MODE==RUN_PILOT) { if (!ScreenLandscape) { LocalPathS(filename, TEXT("dlgStartup_L.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_STARTUP_L")); } else { LocalPathS(filename, TEXT("dlgStartup.xml")); wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_STARTUP")); } if (!wf) return 0; } wSplash = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmSplash")); wSplash->SetWidth(ScreenSizeX); int PROFWIDTH=0, PROFACCEPTWIDTH=0, PROFHEIGHT=0, PROFSEPARATOR=0; if (RUN_MODE==RUN_WELCOME) { ((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetOnClickNotify(OnFLYClicked); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetOnClickNotify(OnSIMClicked); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetOnClickNotify(OnDUALPROFILEClicked); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetOnClickNotify(OnEXITClicked); if (ScreenLandscape) { PROFWIDTH=(ScreenSizeX-IBLSCALE(320))/3; switch(ScreenSize) { case ss800x480: case ss400x240: ((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetWidth(IBLSCALE(110)); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(110)); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(208)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(92)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5); break; case ss480x272: ((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetWidth(IBLSCALE(117)); ((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(117)); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(201)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(99)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetTop(IBLSCALE(197)); break; case ss640x480: case ss320x240: ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(88)); break; default: ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3); break; } } else { PROFWIDTH=IBLSCALE(236); PROFACCEPTWIDTH=NIBLSCALE(45); PROFHEIGHT=NIBLSCALE(25); PROFSEPARATOR=NIBLSCALE(2); } } if (RUN_MODE==RUN_DUALPROF) { ((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetOnClickNotify(OnAIRCRAFTClicked); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetOnClickNotify(OnPROFILEClicked); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetOnClickNotify(OnPILOTClicked); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetOnClickNotify(OnCloseClicked); //((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetOnClickNotify(OnFLYClicked); //((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetOnClickNotify(OnSIMClicked); //((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetOnClickNotify(OnDUALPROFILEClicked); //((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetOnClickNotify(OnEXITClicked); if (ScreenLandscape) { PROFWIDTH=(ScreenSizeX-IBLSCALE(320))/3; switch(ScreenSize) { case ss800x480: case ss400x240: ((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetWidth(IBLSCALE(110)); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(110)); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(208)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(92)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5); break; case ss480x272: ((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetWidth(IBLSCALE(117)); ((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(117)); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(201)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(99)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetTop(IBLSCALE(197)); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetHeight(IBLSCALE(38)); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetTop(IBLSCALE(197)); break; case ss640x480: case ss320x240: ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(88)); break; default: ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2); ((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5); ((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3); break; } } else { PROFWIDTH=IBLSCALE(236); PROFACCEPTWIDTH=NIBLSCALE(45); PROFHEIGHT=NIBLSCALE(25); PROFSEPARATOR=NIBLSCALE(2); } } if (RUN_MODE==RUN_PROFILE || RUN_MODE==RUN_AIRCRAFT || RUN_MODE==RUN_PILOT) { ((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetOnClickNotify(OnCloseClicked); if (ScreenLandscape) { PROFWIDTH=IBLSCALE(256); PROFACCEPTWIDTH=NIBLSCALE(60); PROFHEIGHT=NIBLSCALE(30); PROFSEPARATOR=NIBLSCALE(4); ((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetWidth(PROFACCEPTWIDTH); ((WndButton *)wf->FindByName(TEXT("cmdClose"))) -> SetLeft((((ScreenSizeX-PROFWIDTH-PROFSEPARATOR-PROFACCEPTWIDTH)/2)+PROFSEPARATOR+PROFWIDTH)-NIBLSCALE(2)); ((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetHeight(PROFHEIGHT-NIBLSCALE(4)); } else { PROFWIDTH=IBLSCALE(236); PROFACCEPTWIDTH=NIBLSCALE(45); PROFHEIGHT=NIBLSCALE(25); PROFSEPARATOR=NIBLSCALE(2); ((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetWidth(ScreenSizeX-NIBLSCALE(6)); ((WndButton *)wf->FindByName(TEXT("cmdClose"))) -> SetLeft(NIBLSCALE(2)); } } TCHAR temp[MAX_PATH]; wf->SetHeight(ScreenSizeY); wf->SetWidth(ScreenSizeX); wp = ((WndProperty *)wf->FindByName(TEXT("prpProfile"))); if (wp) { DataFieldFileReader* dfe; dfe = (DataFieldFileReader*)wp->GetDataField(); if (RUN_MODE==RUN_PROFILE) { _stprintf(temp,_T("*%S"),LKS_PRF); dfe->ScanDirectoryTop(_T(LKD_CONF),temp); dfe->addFile(gettext(_T("_@M1741_")),_T("PROFILE_RESET")); dfe->Lookup(startProfileFile); } if (RUN_MODE==RUN_AIRCRAFT) { _stprintf(temp,_T("*%S"),LKS_AIRCRAFT); dfe->ScanDirectoryTop(_T(LKD_CONF),temp); dfe->Lookup(startAircraftFile); } if (RUN_MODE==RUN_PILOT) { _stprintf(temp,_T("*%S"),LKS_PILOT); dfe->ScanDirectoryTop(_T(LKD_CONF),temp); dfe->Lookup(startPilotFile); } wp->SetHeight(PROFHEIGHT); wp->SetWidth(PROFWIDTH); if (ScreenLandscape) wp->SetLeft(((ScreenSizeX-PROFWIDTH-PROFSEPARATOR-PROFACCEPTWIDTH)/2)-NIBLSCALE(2)); else wp->SetLeft(0); wp->RefreshDisplay(); } if (!CheckRootDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; LocalPath(mydir,_T("")); _stprintf(mes,_T("%s"),mydir); MessageBoxX(hWndMainWindow, _T("NO LK8000 DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 000"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("NO LK8000 DIRECTORY"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckDataDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; LocalPath(mydir,_T(LKD_SYSTEM)); _stprintf(mes,_T("%s"),mydir); MessageBoxX(hWndMainWindow, _T("NO SYSTEM DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 001"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("NO SYSTEM DIRECTORY"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckLanguageDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK LANGUAGE DIRECTORY FAILED!%s"),NEWLINE); LocalPath(mydir,_T(LKD_LANGUAGE)); _stprintf(mes,_T("%s"),mydir); MessageBoxX(hWndMainWindow, _T("LANGUAGE DIRECTORY CHECK FAIL\nCheck Language Install"), _T("FATAL ERROR 002"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("NO LANGUAGE DIRECTORY"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckLanguageEngMsg()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK LANGUAGE ENG_MSG FAILED!%s"),NEWLINE); LocalPath(mydir,_T(LKD_LANGUAGE)); _stprintf(mes,_T("%s/ENG_MSG.TXT"),mydir); MessageBoxX(hWndMainWindow, _T("ENG_MSG.TXT MISSING in LANGUAGE\nCheck Language Install"), _T("FATAL ERROR 012"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckSystemDefaultMenu()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK SYSTEM DEFAULT_MENU.TXT FAILED!%s"),NEWLINE); LocalPath(mydir,_T(LKD_SYSTEM)); _stprintf(mes,_T("%s/DEFAULT_MENU.TXT"),mydir); MessageBoxX(hWndMainWindow, _T("DEFAULT_MENU.TXT MISSING in SYSTEM\nCheck System Install"), _T("FATAL ERROR 022"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckSystemBitmaps()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK SYSTEM _BITMAPSH FAILED!%s"),NEWLINE); LocalPath(mydir,_T(LKD_BITMAPS)); _stprintf(mes,_T("%s/_BITMAPSH"),mydir); MessageBoxX(hWndMainWindow, _T("_BITMAPSH MISSING in SYSTEM Bitmaps\nCheck System Install"), _T("FATAL ERROR 032"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } if (!CheckPolarsDir()) { TCHAR mydir[MAX_PATH]; TCHAR mes[MAX_PATH]; StartupStore(_T("... CHECK POLARS DIRECTORY FAILED!%s"),NEWLINE); LocalPath(mydir,_T(LKD_POLARS)); _stprintf(mes,_T("%s"),mydir); MessageBoxX(hWndMainWindow, _T("NO POLARS DIRECTORY\nCheck Install"), _T("FATAL ERROR 003"), MB_OK|MB_ICONQUESTION); MessageBoxX(hWndMainWindow, mes, _T("NO POLARS DIRECTORY"), MB_OK|MB_ICONQUESTION, true); RUN_MODE=RUN_EXIT; Shutdown(); goto _exit; } // Standby for a system request to close the application during this phase. wf->SetTimerNotify(OnTimerNotify); #if 0 srand(GetTickCount()); #endif wf->ShowModal(); if (RUN_MODE==RUN_SHUTDOWN) goto _exit; wp = (WndProperty*)wf->FindByName(TEXT("prpProfile")); if (wp) { DataFieldFileReader* dfe; dfe = (DataFieldFileReader*)wp->GetDataField(); if (RUN_MODE==RUN_PROFILE) { if (_tcslen(dfe->GetPathFile())>0) { if (_tcscmp(dfe->GetPathFile(),startProfileFile) ) { // if they are not the same _tcscpy(startProfileFile,dfe->GetPathFile()); if (_tcscmp(startProfileFile,_T("PROFILE_RESET"))==0) { #if TESTBENCH StartupStore(_T("... Selected FULL RESET virtual profile\n")); #endif if (MessageBoxX(NULL, gettext(TEXT("_@M1758_")), gettext(TEXT("_@M1757_")), MB_OK|MB_ICONQUESTION)); fullresetasked=true; } else { #if TESTBENCH StartupStore(_T("... Selected new profile, preloading..\n")); #endif LKProfileLoad(startProfileFile); fullresetasked=false; } } } } if (RUN_MODE==RUN_AIRCRAFT) { if (_tcslen(dfe->GetPathFile())>0) { if (_tcscmp(dfe->GetPathFile(),startAircraftFile) ) { // if they are not the same _tcscpy(startAircraftFile,dfe->GetPathFile()); #if TESTBENCH StartupStore(_T("... Selected new aircraft, preloading..\n")); #endif LKProfileLoad(startAircraftFile); } } } if (RUN_MODE==RUN_PILOT) { if (_tcslen(dfe->GetPathFile())>0) { if (_tcscmp(dfe->GetPathFile(),startPilotFile) ) { // if they are not the same _tcscpy(startPilotFile,dfe->GetPathFile()); #if TESTBENCH StartupStore(_T("... Selected new pilot, preloading..\n")); #endif LKProfileLoad(startPilotFile); } } } RUN_MODE=RUN_DUALPROF; } if (RUN_MODE==RUN_EXIT) { if (EnableSoundModes) LKSound(_T("LK_SLIDE.WAV")); if (MessageBoxX(hWndMainWindow, // LKTOKEN _@M198_ = "Confirm Exit?" gettext(TEXT("_@M198_")), TEXT("LK8000"), MB_YESNO|MB_ICONQUESTION) == IDYES) { Shutdown(); } else RUN_MODE=RUN_WELCOME; } _exit: if (wf!=NULL) { delete wf; wf = NULL; } if (RUN_MODE==RUN_FLY || RUN_MODE==RUN_SIM) { if (EnableSoundModes) LKSound(_T("LK_SLIDE.WAV")); return 0; // do not repeat dialog } if (RUN_MODE==RUN_EXIT || RUN_MODE==RUN_SHUTDOWN) return -1; // terminate else return 1; // repeat dialog }
void dlgWaypointDetailsShowModal(const Waypoint &_waypoint, bool allow_navigation) { waypoint = &_waypoint; form = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(), Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") : _T("IDR_XML_WAYPOINTDETAILS")); assert(form != nullptr); LastUsedWaypoints::Add(_waypoint); UpdateCaption(); form->SetKeyDownFunction(FormKeyDown); info_widget = (DockWindow *)form->FindByName(_T("info")); assert(info_widget != nullptr); info_widget->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(), _waypoint)); commands_widget = (DockWindow *)form->FindByName(_T("commands")); assert(commands_widget != nullptr); commands_widget->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(), form, _waypoint, protected_task_manager)); commands_widget->Hide(); details_panel = form->FindByName(_T("frmDetails")); assert(details_panel != nullptr); ListControl *wFilesList = (ListControl *)form->FindByName(_T("Files")); assert(wFilesList != nullptr); LargeTextWindow *wDetailsText = (LargeTextWindow *) form->FindByName(_T("Details")); assert(wDetailsText != nullptr); wDetailsText->SetText(waypoint->details.c_str()); #ifdef ANDROID WaypointExternalFileListHandler handler; int num_files = std::distance(waypoint->files_external.begin(), waypoint->files_external.end()); if (num_files > 0) { wFilesList->SetItemRenderer(&handler); wFilesList->SetCursorHandler(&handler); unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5); wFilesList->Resize(wFilesList->GetWidth(), list_height); wFilesList->SetLength(num_files); PixelRect rc = wDetailsText->GetPosition(); rc.top += list_height; wDetailsText->Move(rc); } else #endif wFilesList->Hide(); image_window = (PaintWindow *)form->FindByName(_T("frmImage")); assert(image_window != nullptr); magnify_button = (WndButton *)form->FindByName(_T("cmdMagnify")); assert(magnify_button != nullptr); shrink_button = (WndButton *)form->FindByName(_T("cmdShrink")); assert(shrink_button != nullptr); if (!allow_navigation) { for (const TCHAR *button_name : { _T("cmdPrev"), _T("cmdNext"), _T("cmdGoto") }) { Window *button = form->FindByName(button_name); assert(button != nullptr); button->Hide(); } } for (auto it = waypoint->files_embed.begin(), it_end = waypoint->files_embed.end(); it != it_end && !images.full(); it++) { TCHAR path[MAX_PATH]; LocalPath(path, it->c_str()); if (!images.append().LoadFile(path)) images.shrink(images.size() - 1); } last_page = 2 + images.size(); page = 0; UpdatePage(); form->ShowModal(); delete form; for (auto image = images.begin(); image < images.end(); image++) image->Reset(); images.clear(); }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool XCSoarInterface::Startup() { VerboseOperationEnvironment operation; // Set the application title to "XCSoar" TCHAR szTitle[] = _T("XCSoar"); //If "XCSoar" is already running, stop this instance if (MainWindow::find(szTitle)) return false; LogStartUp(_T("Display dpi=%u,%u"), Display::GetXDPI(), Display::GetYDPI()); // Creates the main window LogStartUp(_T("Create main window")); TopWindowStyle style; if (CommandLine::full_screen) style.FullScreen(); main_window.Set(szTitle, SystemWindowSize(), style); if (!main_window.IsDefined()) return false; main_window.Initialise(); #ifdef SIMULATOR_AVAILABLE // prompt for simulator if not set by command line argument "-simulator" or "-fly" if (!sim_set_in_cmd_line_flag) { DialogLook white_look; white_look.Initialise(Fonts::map_bold, Fonts::map, Fonts::map_label, Fonts::map_bold, Fonts::map_bold); white_look.SetBackgroundColor(COLOR_WHITE); SetXMLDialogLook(white_look); SimulatorPromptResult result = dlgSimulatorPromptShowModal(); switch (result) { case SPR_QUIT: return false; case SPR_FLY: global_simulator_flag = false; break; case SPR_SIMULATOR: global_simulator_flag = true; break; } } #endif SetXMLDialogLook(main_window.GetLook().dialog); SetSystemSettings().SetDefaults(); SetComputerSettings().SetDefaults(); SetUISettings().SetDefaults(); SetUIState().Clear(); if (!LoadProfile()) return false; operation.SetText(_("Initialising")); /* create XCSoarData on the first start */ CreateDataPath(); Display::LoadOrientation(operation); main_window.InitialiseConfigured(); TCHAR path[MAX_PATH]; LocalPath(path, _T("cache")); file_cache = new FileCache(path); ReadLanguageFile(); status_messages.LoadFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard = new DeviceBlackboard(); // Initialize Markers marks = new Markers(); protected_marks = new ProtectedMarkers(*marks); #ifdef HAVE_AYGSHELL_DLL const AYGShellDLL &ayg = main_window.ayg_shell_dll; ayg.SHSetAppKeyWndAssoc(VK_APP1, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP2, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP3, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP4, main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems ayg.SHSetAppKeyWndAssoc(VK_APP5, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP6, main_window); #endif // Initialize main blackboard data task_manager = new TaskManager(way_points); task_manager->SetTaskEvents(task_events); task_manager->Reset(); protected_task_manager = new ProtectedTaskManager(*task_manager, XCSoarInterface::GetComputerSettings().task); // Read the terrain file operation.SetText(_("Loading Terrain File...")); LogStartUp(_T("OpenTerrain")); terrain = RasterTerrain::OpenTerrain(file_cache, operation); glide_computer = new GlideComputer(way_points, airspace_database, *protected_task_manager, task_events); glide_computer->ReadComputerSettings(GetComputerSettings()); glide_computer->SetTerrain(terrain); glide_computer->SetLogger(&logger); glide_computer->Initialise(); replay = new Replay(&logger, *protected_task_manager); // Load the EGM96 geoid data EGM96::Load(); GlidePolar &gp = SetComputerSettings().polar.glide_polar_task; gp = GlidePolar(fixed_zero); gp.SetMC(GetComputerSettings().task.safety_mc); gp.SetBugs(GetComputerSettings().polar.degradation_factor); PlaneGlue::FromProfile(SetComputerSettings().plane); PlaneGlue::Synchronize(GetComputerSettings().plane, SetComputerSettings(), gp); task_manager->SetGlidePolar(gp); // Read the topography file(s) topography = new TopographyStore(); LoadConfiguredTopography(*topography, operation); // Read the waypoint files WaypointGlue::LoadWaypoints(way_points, terrain, operation); // Read and parse the airfield info file WaypointDetails::ReadFileFromProfile(way_points, operation); // Set the home waypoint WaypointGlue::SetHome(way_points, terrain, SetComputerSettings(), false); // ReSynchronise the blackboards here since SetHome touches them device_blackboard->Merge(); ReadBlackboardBasic(device_blackboard->Basic()); // Scan for weather forecast LogStartUp(_T("RASP load")); RASP.ScanAll(Basic().location, operation); // Reads the airspace files ReadAirspace(airspace_database, terrain, GetComputerSettings().pressure, operation); { const AircraftState aircraft_state = ToAircraftState(device_blackboard->Basic(), device_blackboard->Calculated()); ProtectedAirspaceWarningManager::ExclusiveLease lease(glide_computer->GetAirspaceWarnings()); lease->Reset(aircraft_state); lease->SetConfig(CommonInterface::GetComputerSettings().airspace.warnings); } #ifdef HAVE_NET noaa_store = new NOAAStore(); noaa_store->LoadFromProfile(); #endif #ifndef DISABLEAUDIOVARIO /* VarioSound_Init(); VarioSound_EnableSound(EnableSoundVario); VarioSound_SetVdead(SoundDeadband); VarioSound_SetV(0); VarioSound_SetSoundVolume(SoundVolume); */ #endif // Start the device thread(s) operation.SetText(_("Starting devices")); devStartup(); /* -- Reset polar in case devices need the data LogStartUp(_T("GlidePolar::UpdatePolar")); GlidePolar::UpdatePolar(true, GetComputerSettings()); This should be done inside devStartup if it is really required */ operation.SetText(_("Initialising display")); GlueMapWindow *map_window = main_window.GetMap(); if (map_window != NULL) { map_window->SetWaypoints(&way_points); map_window->SetTask(protected_task_manager); map_window->SetRoutePlanner(&glide_computer->GetProtectedRoutePlanner()); map_window->SetGlideComputer(glide_computer); map_window->SetAirspaces(&airspace_database); map_window->SetTopography(topography); map_window->SetTerrain(terrain); map_window->SetWeather(&RASP); map_window->SetMarks(protected_marks); map_window->SetLogger(&logger); } // Finally ready to go.. all structures must be present before this. // Create the drawing thread #ifndef ENABLE_OPENGL LogStartUp(_T("CreateDrawingThread")); draw_thread = new DrawThread(*map_window); draw_thread->Start(true); #endif // Show the infoboxes LogStartUp(_T("ShowInfoBoxes")); InfoBoxManager::Show(); // Create the calculation thread LogStartUp(_T("CreateCalculationThread")); CreateCalculationThread(); // Find unique ID of this PDA ReadAssetNumber(); glide_computer_events.Reset(); GetLiveBlackboard().AddListener(glide_computer_events); if (CommonInterface::GetComputerSettings().logger.enable_flight_logger) { flight_logger = new GlueFlightLogger(GetLiveBlackboard()); LocalPath(path, _T("flights.log")); flight_logger->SetPath(path); } LogStartUp(_T("ProgramStarted")); // Give focus to the map main_window.SetDefaultFocus(); Pages::Initialise(GetUISettings().pages); // Start calculation thread merge_thread->Start(); calculation_thread->Start(); #ifdef HAVE_TRACKING tracking = new TrackingGlue(); tracking->SetSettings(GetComputerSettings().tracking); #endif globalRunningEvent.Signal(); AfterStartup(); operation.Hide(); main_window.ResumeThreads(); return true; }