// Back to race hook *************************************************** static void rmBackToRaceHookActivate(void * /* dummy */) { // Temporary hack for the Paused race case, in order // the race does not get ended (as is is currently stopped) // TODO: Activate the Stop Race menu directly, as for the Help menu (F1), // and no more through changing the race engine state to STOP // But beware of the other hooks ... LmRaceEngine().inData()->_reState = RE_STATE_RACE; // Back to the race screen in next display loop. LegacyMenu::self().activateGameScreen(); // Launch the "slow resume race" manager if non-blind mode. if (LmRaceEngine().outData()->_displayMode == RM_DISP_MODE_NORMAL) rmProgressiveTimeModifier.start(); }
void * RmScreenInit() { // Release screen if was initialized. RmScreenShutdown(); // Create screen, load menu XML descriptor and create static controls. rmScreenHandle = GfuiScreenCreate(black, 0, rmScreenActivate, 0, 0, 0); void *menuXMLDescHdle = GfuiMenuLoad("raceglscreen.xml"); GfuiMenuCreateStaticControls(rmScreenHandle, menuXMLDescHdle); // Create Message, BigMessage and Pause labels. rmMsgId = GfuiMenuCreateLabelControl(rmScreenHandle, menuXMLDescHdle, "message"); rmBigMsgId = GfuiMenuCreateLabelControl(rmScreenHandle, menuXMLDescHdle, "bigmessage"); rmPauseId = GfuiMenuCreateLabelControl(rmScreenHandle, menuXMLDescHdle, "pause"); // Close menu XML descriptor. GfParmReleaseHandle(menuXMLDescHdle); // Register keyboard shortcuts. rmAddKeys(); // We are starting "unpaused". GfuiVisibilitySet(rmScreenHandle, rmPauseId, GFUI_INVISIBLE); rmRacePaused = false; #ifdef STARTPAUSED rmPreRacePause = false; #endif // Re-initialize the progressive time modifier, // in case the race was exited while it was running. rmProgressiveTimeModifier.reset(); // Initialize the movie capture system. rmInitMovieCapture(); return rmScreenHandle; }
static void rmRacePause(void * /* vboard */) { #ifdef STARTPAUSED // Pause is disabled during Pre Race Pause // as the simulation is already Paused if (!rmPreRacePause) { if (rmRacePaused) { if (LegacyMenu::self().soundEngine()) LegacyMenu::self().soundEngine()->mute(false); #else if (rmRacePaused) { if (LegacyMenu::self().soundEngine()) LegacyMenu::self().soundEngine()->mute(false); #endif LmRaceEngine().start(); // Hide the "Pause" label. GfuiVisibilitySet(rmScreenHandle, rmPauseId, GFUI_INVISIBLE); // Show again the hidden message label. GfuiVisibilitySet(rmScreenHandle, rmMsgId, GFUI_VISIBLE); // Launch the "slow resume race" manager if non-blind mode. if (LmRaceEngine().outData()->_displayMode == RM_DISP_MODE_NORMAL) rmProgressiveTimeModifier.start(); } else { if (LegacyMenu::self().soundEngine()) LegacyMenu::self().soundEngine()->mute(true); LmRaceEngine().stop(); // Show the "Pause" label. GfuiVisibilitySet(rmScreenHandle, rmPauseId, GFUI_VISIBLE); // Hide the message label (no need to bother the user with the time mult. factor // when it is changing, whihc occurs when the user hits P when a slow start // is in-process). GfuiVisibilitySet(rmScreenHandle, rmMsgId, GFUI_INVISIBLE); } // Toggle the race-paused flag. rmRacePaused = !rmRacePaused; // The menu changed. rmbMenuChanged = true; #ifdef STARTPAUSED } #endif } static void rmSkipPreStart(void * /* dummy */) { // TODO: move this to a new LmRaceEngine().skipRacePreStart() ... tRmInfo* reInfo = LmRaceEngine().inData(); if (reInfo->s->currentTime < -1.0) { reInfo->s->currentTime = -1.0; reInfo->_reLastRobTime = -1.0; } }
static void rmRedisplay() { // Process any pending (human) pit request. const bool bPitRequested = RmCheckPitRequest(); #ifdef UseFPSLimiter // Auto FPS limitation if specified and if not capturing frames. if (FPSLimMaxRate > 0 && !rmMovieCapture.active) { // If too early to refresh graphics, do nothing more than wait a little. const double dCurrentTime = GfTimeClock(); if (dCurrentTime < FPSLimLastTime + 1.0 / FPSLimMaxRate) { // Wait a little, to let the CPU take breath. // Note : Theorical resolution is 1ms, but actual one is from far more // (10-15ms under Windows, even worse under Linux ?) // which explains a lower than expected actual FPS mean. GfSleep(0.001); // Only giving back control to the scheduler gives good results // as for the actual mean FPS, but keeps the CPU 100 % (not very cool). //GfSleep(0.0); // Request an update in the next event loop though. GfuiApp().eventLoop().postRedisplay(); return; } // Otherwise, last update time is now : go on with graphics update. FPSLimLastTime = dCurrentTime; } #endif // Exec the "slow resume race" manager, if needed. #ifdef STARTPAUSED if (!rmPreRacePause) { rmProgressiveTimeModifier.execute(); } #else rmProgressiveTimeModifier.execute(); #endif // Redraw the graphics part of the GUI if requested. const bool bUpdateGraphics = LmRaceEngine().outData()->_displayMode == RM_DISP_MODE_NORMAL && !bPitRequested && LegacyMenu::self().graphicsEngine(); if (bUpdateGraphics) { //GfSchedBeginEvent("raceupdate", "graphics"); LegacyMenu::self().redrawGraphicsView(LmRaceEngine().outData()->s); //GfSchedEndEvent("raceupdate", "graphics"); } // Synchronize the menu with the race messages if any changed. rmUpdateRaceMessages(); // Redraw the menu part of the GUI // (always necessary if the graphics were redrawn first). if (bUpdateGraphics || rmbMenuChanged) GfuiRedraw(); // Really do the display work. if (bUpdateGraphics || rmbMenuChanged) GfuiSwapBuffers(); // The menu changes has now been taken into account. rmbMenuChanged = false; //只要改成任何时候都输出每一帧的RGB信息到PNG,即可输出PNG格式的图片 Add by gaoyu 2015-7-15 // Capture the newly displayed frame if movie capture mode. if (rmMovieCapture.active) rmCaptureScreen();//会自动获取屏幕像素,并保存为png文件 Add by gaoyu 2015-7-15 //rmCaptureScreen(); // Request an redisplay in the next event loop. GfuiApp().eventLoop().postRedisplay(); }