void Test18() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadSaveGame("Save_Games\\rescript1.sav"); SequenceEnv se; char inbuf[256]; goref gr; gr = FindObjID(3102); se.self = gr; printf("Object finder definitions:\n"); for(int i = 0; i < strFinderDef.len; i++) printf(" %i: %s\n", i+1, strFinderDef.getdp(i)); while(1) { printf("\nFinder def. number: "); int x = atoi(fgets(inbuf, 255, stdin))-1; if(x == -1) break; if((uint)x >= strFinderDef.len) printf("OFD number does not exist.\n"); else if(!finderdef[x]) printf("OFD is null.\n"); else { printf("Result:"); CFinder *f = finderdef[x]; GameObject *o; f->begin(&se); while(o = f->getnext()) printf(" %u", o->id); printf("\n"); } } };
void Test3() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); //InitRectDrawing(); //IDirect3DTexture9 *mytex = GetTexture("Interface\\LOADING SCREEN 1.tga"); //IDirect3DPixelShader9 *psh = LoadPixelShader("test.psh"); InitScene(); LoadMap("testmap.bcm"); while(!appexit) { BeginDrawing(); //ddev->SetRenderState(D3DRS_ZENABLE, FALSE); //ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); //ddev->SetPixelShader(psh); //ddev->SetTexture(0, mytex); //DrawRect(0, 0, 640, 480, -1); DrawScene(); EndDrawing(); HandleWindow(); if(keyheld[VK_UP]) camerapos += Vector3(0.0f, 0.0f, walkstep); if(keyheld[VK_DOWN]) camerapos -= Vector3(0.0f, 0.0f, walkstep); if(keyheld[VK_LEFT]) camerapos -= Vector3(walkstep, 0.0f, 0.0f); if(keyheld[VK_RIGHT]) camerapos += Vector3(walkstep, 0.0f, 0.0f); if(keyheld['E']) camerapos += Vector3(0.0f, walkstep, 0.0f); if(keyheld['D']) camerapos -= Vector3(0.0f, walkstep, 0.0f); } }
void Test5() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\small extensions.cpp"); printf("Game set loaded!\n"); printf("Declared items:\n"); for(int i = 0; i < strItems.len; i++) printf(" - %s\n", strItems[i]); printf("Defined values:\n"); for(int i = 0; i < defvalue.len; i++) printf(" - %s = %f\n", strDefValue[i], defvalue[i]); printf("Appearance tags:\n"); for(int i = 0; i < strAppearTag.len; i++) printf(" - %s\n", strAppearTag[i]); printf("ObjDefs:\n"); for(int i = 0; i < strObjDef.len; i++) printf(" - %s (%s)\n", strObjDef[i], CLASS_str[typeObjDef[i]]); printf("Looking at first object:\n"); printf(" - Tooltip: %s\n", objdef[0].tooltip); printf(" - First start item: %f\n", objdef[0].startItems[0]); printf(" - Shadow: %i\n", objdef[0].shadowtype); printf("2nd's subtypes:\n"); for(int i = 0; i < pstObjDef[1]->len; i++) printf(" - %s\n", (pstObjDef[1])->getdp(i)); printf("1st's subtypes (%i):\n", pstObjDef[0]->len); for(int i = 0; i < pstObjDef[0]->len; i++) printf(" - %s\n", (pstObjDef[0])->getdp(i)); printf("These ObjDefs have \"Default\" subtype and \"Default\" appearance:\n"); for(int i = 0; i < strObjDef.len; i++) printf("- %s: %s\n", strObjDef[i], objdef[i].subtypes[0].appear[0].def?"Yes":"No"); // :S getch(); //InitMeshDrawing(); int a = FindObjDef(CLASS_BUILDING, "Manor"); while(!appexit) { BeginDrawing(); BeginMeshDrawing(); SetModelMatrices(); objdef[a].subtypes[0].appear[0].def->draw(); // :S EndDrawing(); HandleWindow(); } }
void Test10() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\multi-player extensions.cpp"); CObjectDefinition *d = AskObjDef("Read starting item values of object definition:"); if(!d) return; for(int i = 0; i < strItems.len; i++) if(d->startItems[i] != 0.0f) printf("%s = %f\n", strItems.getdp(i), d->startItems[i]); }
void Test16() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\multi-player extensions.cpp"); // Investigate the "invisible explosive cart" issue. int ecdef = FindObjDef(CLASS_CHARACTER, "Explosive Cart"); mustbefound(ecdef); printf("#%i\n", ecdef); //__asm int 3 }
void Test12() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\multi-player extensions.cpp"); for(int i = 0; i < strDiplomaticStatus.len; i++) { printf("%i: %s", i, strDiplomaticStatus.getdp(i)); printf((i == defaultDiploStat)?" (default)\n":"\n"); } getch(); }
void XCSoarInterface::PreloadInitialisation(bool ask) { if (ask) { #ifdef PNA CleanRegistry(); // VENTA2-FIX for PNA we can't delete all registries..by now #endif } SetToRegistry(TEXT("XCV"), 1); #ifdef DEBUG_TRANSLATIONS ReadLanguageFile(); #endif // Registry (early) if (ask) { Profile::RestoreRegistry(); Profile::ReadRegistrySettings(); // CreateProgressDialog(gettext(TEXT("Initialising"))); } else { dlgStartupShowModal(); Profile::RestoreRegistry(); Profile::ReadRegistrySettings(); CreateProgressDialog(gettext(TEXT("Initialising"))); } // Interface (before interface) if (!ask) { #ifndef DEBUG_TRANSLATIONS ReadLanguageFile(); #endif status_messages.LoadFile(); InputEvents::readFile(); } }
void Test8() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\multi-player extensions.cpp"); printf("Game set loaded!\n"); printf("Num. objdefs.: %i\n", strObjDef.len); for(int i = 0; i < strObjDef.len; i++) {printf(" - %s, ", strObjDef[i]); //fflush(stdout); printf("%s, %i\n", CLASS_str[objdef[i].type], objdef[i].renderable);} printf("Num. items: %i\n", strItems.len); for(int i = 0; i < strItems.len; i++) printf(" - %s\n", strItems.get(i)); getch(); }
void Test19() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadGameSet("Warrior Kings Game Set\\multi-player extensions.cpp"); printf("--- GAME_EVENT ---\n"); for(int i = 0; i < strGameEvent.len; i++) printf("%s\n", strGameEvent.getdp(i)); printf("--- PACKAGE_RECEIPT_TRIGGER ---\n"); for(int i = 0; i < strPRTrigger.len; i++) printf("%s\n", strPRTrigger.getdp(i)); printf("--- Both ---\n"); for(int i = 0; i < strGameEvent.len; i++) if(strPRTrigger.find(strGameEvent.getdp(i)) != -1) printf("%s\n", strGameEvent.getdp(i)); };
void Test14() { InitWindow(); LoadBCP("data.bcp"); InitFont(); ReadLanguageFile(); char *msg = GetLocText("AI_BIOG_PAUL_THE_SIMPLE"); while(!appexit) { BeginDrawing(); InitRectDrawing(); //DrawRect(2, 2, 64, 64, 0xFF); //for(int i = 0; i < 40; i++) // DrawFont(i*12, i*12, "Hello! \x21\x22\x7d\x7e\xa1\xa2\xa3"); //DrawFont(0, 0, msg); deffont->DrawInRect(scrw, 0, 0, msg, 0xFF00FFFF); EndDrawing(); HandleWindow(); } }
void Test17() { LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); LoadSaveGame("Save_Games\\rescript1.sav"); SequenceEnv se; char inbuf[256]; printf("Equations:\n"); for(int i = 0; i < strEquation.len; i++) printf(" %i: %s\n", i+1, strEquation.getdp(i)); while(1) { printf("\nEquation number: "); int x = atoi(fgets(inbuf, 255, stdin))-1; if(x == -1) break; if((uint)x >= strEquation.len) printf("Eq. number does not exist.\n"); else if(!equation[x]) printf("Equation is null.\n"); else printf("Result: %f\n", equation[x]->get(&se)); } };
/** * "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(); if (CommandLine::resizable) style.Resizable(); main_window.Set(szTitle, SystemWindowSize(), style); if (!main_window.IsDefined()) return false; #ifdef ENABLE_OPENGL LogStartUp(_T("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); 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(); 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_manager = new TaskManager(GetComputerSettings().task, 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(), device_blackboard, 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 AudioVarioGlue::Initialise(); AudioVarioGlue::Configure(GetComputerSettings().sound); // 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); /* show map at home waypoint until GPS fix becomes available */ if (GetComputerSettings().poi.home_location_available) map_window->SetLocation(GetComputerSettings().poi.home_location); } // 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); } if (CommonInterface::GetComputerSettings().logger.enable_nmea_logger) NMEALogger::enabled = true; 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; }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool XCSoarInterface::Startup(HINSTANCE hInstance) { // Set the application title to "XCSoar" TCHAR szTitle[] = _T("XCSoar"); // Store instance handle in our global variable #ifdef WIN32 ResourceLoader::Init(hInstance); #endif //If "XCSoar" is already running, stop this instance if (MainWindow::find(szTitle)) return false; // Register window classes PaintWindow::register_class(hInstance); MainWindow::register_class(hInstance); // Creates the main window LogStartUp(_T("Create main window")); PixelRect WindowSize = SystemWindowSize(); main_window.set(szTitle, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom); if (!main_window.defined()) 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) { 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 if (!LoadProfile()) return false; ProgressGlue::Create(_("Initialising")); LoadDisplayOrientation(); main_window.InitialiseConfigured(); TCHAR path[MAX_PATH]; LocalPath(path, _T("cache")); file_cache = new FileCache(path); Graphics::InitialiseConfigured(SettingsMap()); ReadLanguageFile(); status_messages.LoadFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard.Initialise(); // Initialize Marks marks = new Marks(); // Send the SettingsMap to the DeviceBlackboard SendSettingsMap(); // Show the main and map windows LogStartUp(_T("Create map window")); main_window.show(); main_window.map.show(); #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(task_events, way_points); task_manager->reset(); protected_task_manager = new ProtectedTaskManager(*task_manager, XCSoarInterface::SettingsComputer(), task_events, airspace_database); airspace_warning = new AirspaceWarningManager(airspace_database, *task_manager); airspace_warnings = new ProtectedAirspaceWarningManager(*airspace_warning); // Read the terrain file ProgressGlue::Create(_("Loading Terrain File...")); LogStartUp(_T("OpenTerrain")); terrain = RasterTerrain::OpenTerrain(file_cache); glide_computer = new GlideComputer(way_points, *protected_task_manager, *airspace_warnings, task_events); glide_computer->set_terrain(terrain); glide_computer->SetLogger(&logger); glide_computer->Initialise(); replay = new Replay(*protected_task_manager); // Load the EGM96 geoid data OpenGeoid(); GlidePolar &gp = SetSettingsComputer().glide_polar_task; gp = GlidePolar(fixed_zero); PolarGlue::LoadFromProfile(gp, SetSettingsComputer()); task_manager->set_glide_polar(gp); task_manager->set_contest(SettingsComputer().contest); // Read the topography file(s) topography = new TopographyStore(); LoadConfiguredTopography(*topography); // Read the waypoint files WayPointGlue::LoadWaypoints(way_points, terrain); // Read and parse the airfield info file ReadAirfieldFile(way_points); // Set the home waypoint WayPointGlue::SetHome(way_points, terrain, SetSettingsComputer(), false); // ReSynchronise the blackboards here since SetHome touches them ReadBlackboardBasic(device_blackboard.Basic()); // Scan for weather forecast ProgressGlue::Create(_("Scanning weather forecast")); LogStartUp(_T("RASP load")); RASP.ScanAll(Basic().Location); // Reads the airspace files ReadAirspace(airspace_database, terrain, SettingsComputer().pressure); const AIRCRAFT_STATE aircraft_state = ToAircraftState(device_blackboard.Basic(), device_blackboard.Calculated()); airspace_warning->reset(aircraft_state); airspace_warning->set_config(CommonInterface::SettingsComputer().airspace.warnings); // Read the FLARM details file FlarmDetails::Load(); #ifndef DISABLEAUDIOVARIO /* VarioSound_Init(); VarioSound_EnableSound(EnableSoundVario); VarioSound_SetVdead(SoundDeadband); VarioSound_SetV(0); VarioSound_SetSoundVolume(SoundVolume); */ #endif // Start the device thread(s) ProgressGlue::Create(_("Starting devices")); devStartup(); /* -- Reset polar in case devices need the data LogStartUp(_T("GlidePolar::UpdatePolar")); GlidePolar::UpdatePolar(true, SettingsComputer()); This should be done inside devStartup if it is really required */ ProgressGlue::Create(_("Initialising display")); main_window.map.set_way_points(&way_points); main_window.map.set_task(protected_task_manager); main_window.map.set_airspaces(&airspace_database, airspace_warnings); main_window.map.set_topography(topography); main_window.map.set_terrain(terrain); main_window.map.set_weather(&RASP); main_window.map.set_marks(marks); main_window.map.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(main_window.map, main_window.flarm, main_window.ta); draw_thread->start(); #endif // Show the infoboxes LogStartUp(_T("ShowInfoBoxes")); InfoBoxManager::Show(); // Create the calculation thread LogStartUp(_T("CreateCalculationThread")); CreateCalculationThread(); // Find unique ID of this PDA ReadAssetNumber(); LogStartUp(_T("ProgramStarted")); // Give focus to the map main_window.map.set_focus(); Pages::LoadFromProfile(); // Start calculation thread calculation_thread->start(); globalRunningEvent.trigger(); AfterStartup(); #ifndef ENABLE_OPENGL draw_thread->resume(); #endif return true; }
static void SettingsLeave(const UISettings &old_ui_settings) { if (!globalRunningEvent.Test()) return; SuspendAllThreads(); VerboseOperationEnvironment operation; MainWindow &main_window = XCSoarInterface::main_window; if (LanguageChanged) ReadLanguageFile(); if (MapFileChanged) { /* set these flags, because they may be loaded from the map file */ AirspaceFileChanged = true; AirfieldFileChanged = true; WaypointFileChanged = true; TerrainFileChanged = true; TopographyFileChanged = true; } if (TerrainFileChanged) { operation.SetText(_("Loading Terrain File...")); main_window.SetTerrain(NULL); glide_computer->SetTerrain(NULL); // re-load terrain delete terrain; terrain = RasterTerrain::OpenTerrain(file_cache, operation); main_window.SetTerrain(terrain); glide_computer->SetTerrain(terrain); } if (WaypointFileChanged || AirfieldFileChanged) { // re-load waypoints WaypointGlue::LoadWaypoints(way_points, terrain, operation); WaypointDetails::ReadFileFromProfile(way_points, operation); } if (WaypointFileChanged && protected_task_manager != NULL) { ProtectedTaskManager::ExclusiveLease lease(*protected_task_manager); OrderedTask *task = lease->Clone(XCSoarInterface::GetComputerSettings().task); if (task) { // this must be done in thread lock because it potentially changes the // waypoints database task->CheckDuplicateWaypoints(way_points); /* XXX shall this task be committed if it has been modified? */ delete task; way_points.Optimise(); } } if (WaypointFileChanged || TerrainFileChanged) { // re-set home WaypointGlue::SetHome(way_points, terrain, XCSoarInterface::SetComputerSettings(), device_blackboard, WaypointFileChanged); WaypointGlue::SaveHome(CommonInterface::GetComputerSettings()); } if (TopographyFileChanged) { main_window.SetTopography(NULL); topography->Reset(); LoadConfiguredTopography(*topography, operation); main_window.SetTopography(topography); } if (AirspaceFileChanged) { if (glide_computer != NULL) glide_computer->GetAirspaceWarnings().clear(); if (glide_computer != NULL) glide_computer->ClearAirspaces(); airspace_database.clear(); ReadAirspace(airspace_database, terrain, CommonInterface::GetComputerSettings().pressure, operation); } if (DevicePortChanged) devRestart(); const UISettings &ui_settings = CommonInterface::GetUISettings(); Units::SetConfig(ui_settings.units); const MapSettings &old_settings_map = old_ui_settings.map; const MapSettings &settings_map = ui_settings.map; if (settings_map.snail_type != old_settings_map.snail_type || settings_map.snail_scaling_enabled != old_settings_map.snail_scaling_enabled) main_window.SetLook().map.trail.Initialise(settings_map); if (settings_map.waypoint.landable_style != old_settings_map.waypoint.landable_style) main_window.SetLook().map.waypoint.Initialise(settings_map.waypoint); ResumeAllThreads(); CommonInterface::main_window.ResumeThreads(); // allow map and calculations threads to continue ActionInterface::SendMapSettings(true); operation.Hide(); InfoBoxManager::SetDirty(); main_window.full_redraw(); main_window.SetDefaultFocus(); }
void Test2() { LoadBCP("data.bcp"); ReadLanguageFile(); printf("%s\n", GetLocText("AI_BIOG_BLACKLERE_THE_PEASANT")); }
void Test23() { int px = 0, pz = 0, ps = 64; LoadBCP("data.bcp"); ReadLanguageFile(); InitWindow(); InitFont(); //LoadSaveGame("Save_Games\\Advanced Economy.lvl"); //LoadMap("Maps\\oritest.bcm"); char mn[512]; if(!AskMap(mn, "Select a map you want to view.")) return; LoadMap(mn); DynList<MapTile*> *ttlist = new DynList<MapTile*>[maptexfilenames.len]; for(int z = 0; z < mapheight; z++) for(int x = 0; x < mapwidth; x++) { MapTile *t = &maptiles[z*mapwidth+x]; ttlist[t->mt->tfid].add(t); } while(!appexit) { BeginDrawing(); InitRectDrawing(); //RBatch *batch = renderer->CreateBatch(1024, 1536); RBatch *batch = renderer->CreateBatch(2*8192, 3*8192); renderer->BeginBatchDrawing(); batch->begin(); Matrix mx; CreateZeroMatrix(&mx); mx._11 = 2.0f / scrw; mx._22 = -2.0f / scrh; mx._41 = -1 - (0.5f / (scrw)); mx._42 = 1 + (0.5f / (scrh)); //mx._41 = -1; mx._42 = 1; mx._44 = 1; renderer->SetTransformMatrix(&mx); for(int i = 0; i < maptexfilenames.len; i++) { int tns = 1; for(DynListEntry<MapTile*> *e = ttlist[i].first; e; e = e->next) { MapTile *c = e->value; int dx = (c->x - px) * ps, dy = (c->z - pz) * ps; if(((uint)dx >= scrw) || ((uint)dy >= scrh)) continue; MapTexture *t = c->mt; if(tns) {SetTexture(0, t->t); tns = 0;} batchVertex *bv; ushort *bi; uint fi; batch->next(4, 6, &bv, &bi, &fi); int a = c->rot, f = ((c->zflip&1)?1:0) ^ ((c->xflip&1)?3:0); bv[0].x = dx; bv[0].y = dy; bv[1].x = dx + ps; bv[1].y = dy; bv[2].x = dx + ps; bv[2].y = dy + ps; bv[3].x = dx; bv[3].y = dy + ps; bv[((0^f)+a)&3].u = t->x / 256.f; bv[((0^f)+a)&3].v = t->y / 256.f; bv[((1^f)+a)&3].u = (t->x+t->w) / 256.f; bv[((1^f)+a)&3].v = t->y / 256.f; bv[((2^f)+a)&3].u = (t->x+t->w) / 256.f; bv[((2^f)+a)&3].v = (t->y+t->h) / 256.f; bv[((3^f)+a)&3].u = t->x / 256.f; bv[((3^f)+a)&3].v = (t->y+t->h) / 256.f; for(int j = 0; j < 4; j++) {bv[j].z = 0; bv[j].color = -1; }//bv[j].x -= 0.5f; bv[j].y -= 0.5f;} // L-> this will drop FPS because it rereads the locked buffer! bi[0] = fi+0; bi[1] = fi+1; bi[2] = fi+3; bi[3] = fi+1; bi[4] = fi+3; bi[5] = fi+2; } batch->flush(); } batch->end(); delete batch; if(keypressed[VK_LEFT]) px--; if(keypressed[VK_RIGHT]) px++; if(keypressed[VK_UP]) pz--; if(keypressed[VK_DOWN]) pz++; if(keypressed[VK_MULTIPLY]) ps <<= 1; if(keypressed[VK_DIVIDE]) ps >>= 1; if(ps <= 0) ps = 1; EndDrawing(); HandleWindow(); } }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool Startup() { VerboseOperationEnvironment operation; #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(); style.Resizable(); MainWindow *const main_window = CommonInterface::main_window = new MainWindow(); main_window->Create(SystemWindowSize(), style); if (!main_window->IsDefined()) return false; #ifdef ENABLE_OPENGL LogFormat("OpenGL: " #ifdef ANDROID #ifdef USE_EGL "egl=native " #else "egl=no " #endif #endif #ifdef HAVE_OES_DRAW_TEXTURE "oesdt=%d " #endif #ifdef HAVE_DYNAMIC_MULTI_DRAW_ARRAYS "mda=%d " #endif "npot=%d vbo=%d fbo=%d stencil=%#x", #ifdef HAVE_OES_DRAW_TEXTURE OpenGL::oes_draw_texture, #endif #ifdef HAVE_DYNAMIC_MULTI_DRAW_ARRAYS GLExt::HaveMultiDrawElements(), #endif OpenGL::texture_non_power_of_two, OpenGL::vertex_buffer_object, OpenGL::frame_buffer_object, OpenGL::render_buffer_stencil); #endif CommonInterface::SetUISettings().SetDefaults(); 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) { 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 CommonInterface::SetSystemSettings().SetDefaults(); CommonInterface::SetComputerSettings().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->CheckResize(); main_window->InitialiseConfigured(); { file_cache = new FileCache(LocalPath(_T("cache"))); } ReadLanguageFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard = new DeviceBlackboard(); devices = new MultipleDevices(); device_blackboard->SetDevices(*devices); // 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); #ifdef HAVE_CMDLINE_REPLAY if (CommandLine::replay_path != nullptr) { Error error; if (!replay->Start(Path(CommandLine::replay_path), error)) LogError(error); } #endif GlidePolar &gp = CommonInterface::SetComputerSettings().polar.glide_polar_task; gp = GlidePolar(0); gp.SetMC(computer_settings.task.safety_mc); gp.SetBugs(computer_settings.polar.degradation_factor); PlaneGlue::FromProfile(CommonInterface::SetComputerSettings().plane, Profile::map); 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 = new RaspStore(); rasp->ScanAll(); // 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); } #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 != nullptr) { 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); #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); all_monitors = new AllMonitors(); if (!is_simulator() && computer_settings.logger.enable_flight_logger) { flight_logger = new GlueFlightLogger(live_blackboard); flight_logger->SetPath(LocalPath(_T("flights.log"))); } if (computer_settings.logger.enable_nmea_logger) NMEALogger::enabled = true; LogFormat("ProgramStarted"); // Give focus to the map main_window->SetDefaultFocus(); // Start calculation thread merge_thread->Start(); calculation_thread->Start(); PageActions::Update(); #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; }
static void SettingsLeave(const UISettings &old_ui_settings) { if (!global_running) return; SuspendAllThreads(); VerboseOperationEnvironment operation; MainWindow &main_window = *CommonInterface::main_window; if (LanguageChanged) ReadLanguageFile(); bool TerrainFileChanged = false, TopographyFileChanged = false; if (MapFileChanged) { /* set these flags, because they may be loaded from the map file */ AirspaceFileChanged = true; AirfieldFileChanged = true; WaypointFileChanged = true; TerrainFileChanged = true; TopographyFileChanged = true; } if (TerrainFileChanged) { operation.SetText(_("Loading Terrain File...")); /* just in case the bottom widget uses the old terrain object (e.g. the cross section) */ main_window.SetBottomWidget(nullptr); main_window.SetTerrain(NULL); glide_computer->SetTerrain(NULL); // re-load terrain delete terrain; terrain = RasterTerrain::OpenTerrain(file_cache, operation); main_window.SetTerrain(terrain); glide_computer->SetTerrain(terrain); /* re-create the bottom widget if it was deleted here */ PageActions::Update(); } if (WaypointFileChanged || AirfieldFileChanged) { // re-load waypoints WaypointGlue::LoadWaypoints(way_points, terrain, operation); WaypointDetails::ReadFileFromProfile(way_points, operation); } if (WaypointFileChanged && protected_task_manager != NULL) { ProtectedTaskManager::ExclusiveLease lease(*protected_task_manager); OrderedTask *task = lease->Clone(CommonInterface::GetComputerSettings().task); if (task) { // this must be done in thread lock because it potentially changes the // waypoints database task->CheckDuplicateWaypoints(way_points); /* XXX shall this task be committed if it has been modified? */ delete task; way_points.Optimise(); } } if (WaypointFileChanged || TerrainFileChanged) { // re-set home WaypointGlue::SetHome(way_points, terrain, CommonInterface::SetComputerSettings().poi, CommonInterface::SetComputerSettings().team_code, device_blackboard, WaypointFileChanged); WaypointGlue::SaveHome(Profile::map, CommonInterface::GetComputerSettings().poi, CommonInterface::GetComputerSettings().team_code); } if (TopographyFileChanged) { main_window.SetTopography(NULL); topography->Reset(); LoadConfiguredTopography(*topography, operation); main_window.SetTopography(topography); } if (AirspaceFileChanged) { if (glide_computer != NULL) glide_computer->GetAirspaceWarnings().Clear(); if (glide_computer != NULL) glide_computer->ClearAirspaces(); airspace_database.Clear(); ReadAirspace(airspace_database, terrain, CommonInterface::GetComputerSettings().pressure, operation); } if (DevicePortChanged) devRestart(); const UISettings &ui_settings = CommonInterface::GetUISettings(); Units::SetConfig(ui_settings.format.units); SetUserCoordinateFormat(ui_settings.format.coordinate_format); const MapSettings &old_settings_map = old_ui_settings.map; const MapSettings &settings_map = ui_settings.map; if (settings_map.trail.type != old_settings_map.trail.type || settings_map.trail.scaling_enabled != old_settings_map.trail.scaling_enabled) main_window.SetLook().map.trail.Initialise(settings_map.trail); if (settings_map.waypoint.landable_style != old_settings_map.waypoint.landable_style) main_window.SetLook().map.waypoint.Reinitialise(settings_map.waypoint); ResumeAllThreads(); main_window.ResumeThreads(); // allow map and calculations threads to continue ActionInterface::SendMapSettings(true); AudioVarioGlue::Configure(CommonInterface::GetUISettings().sound.vario); operation.Hide(); InfoBoxManager::SetDirty(); main_window.FlushRendererCaches(); main_window.FullRedraw(); main_window.SetDefaultFocus(); }