/*! * The mainloop. * Fetches events, executes appropriate code */ void mainLoop(void) { frameUpdate(); // General housekeeping // Screenshot key is now available globally if (keyPressed(KEY_F10)) { kf_ScreenDump(); inputLoseFocus(); // remove it from input stream } if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } // Feed a bit of randomness into libcrypto. unsigned buf[] = {mouseX(), mouseY(), realTime, graphicsTime, gameTime, (unsigned) rand(), 4}; // http://xkcd.com/221/ RAND_add(buf, sizeof(buf), 1); }
// //////////////////////////////////////////////////////////////////////////// bool closeLoadSave(void) { bLoadSaveUp = false; if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION) || (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH)) { if (!bMultiPlayer || (NetPlay.bComms == 0)) { gameTimeStart(); setGamePauseStatus( false ); setGameUpdatePause(false); setScriptPause(false); setScrollPause(false); setConsolePause(false); } intAddReticule(); intShowPowerBar(); } delete psRequestScreen; psRequestScreen = NULL; // need to "eat" up the return key so it don't pass back to game. inputLoseFocus(); return true; }
/*! * The mainloop. * Fetches events, executes appropriate code */ void mainLoop(void) { frameUpdate(); // General housekeeping // Screenshot key is now available globally if (keyPressed(KEY_F10)) { kf_ScreenDump(); inputLoseFocus(); // remove it from input stream } if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } }
void mainLoop(void) { pie_ScreenFlip(CLEAR_BLACK); frameUpdate(); // General housekeeping if (keyPressed(KEY_ESC)) { inputLoseFocus(); // remove it from input stream exit(1); // FIXME, insert SDL_QUIT event instead } }
void WzMainWindow::focusOutEvent(QFocusEvent *event) { debug(LOG_INPUT, "Main window lost focus."); inputLoseFocus(); }
// //////////////////////////////////////////////////////////////////////////// // process clicks made by user. void intProcessMultiMenu(UDWORD id) { UBYTE i; //close if (id == MULTIMENU_CLOSE) { intCloseMultiMenu(); } //alliance button if(id >=MULTIMENU_ALLIANCE_BASE && id<MULTIMENU_ALLIANCE_BASE+MAX_PLAYERS) { i =(UBYTE)( id - MULTIMENU_ALLIANCE_BASE); switch(alliances[selectedPlayer][i]) { case ALLIANCE_BROKEN: requestAlliance((UBYTE)selectedPlayer,i,true,true); // request an alliance break; case ALLIANCE_INVITATION: formAlliance((UBYTE)selectedPlayer,i,true,true,true); // form an alliance break; case ALLIANCE_REQUESTED: breakAlliance((UBYTE)selectedPlayer,i,true,true); // break an alliance break; case ALLIANCE_FORMED: breakAlliance((UBYTE)selectedPlayer,i,true,true); // break an alliance break; default: break; } } //channel opens. if(id >=MULTIMENU_CHANNEL && id<MULTIMENU_CHANNEL+MAX_PLAYERS) { i = id - MULTIMENU_CHANNEL; openchannels[i] = !openchannels[i]; if(mouseDown(MOUSE_RMB) && NetPlay.isHost) // both buttons.... { char buf[250]; // Allow the host to kick the AI only in a MP game, or if they activated cheats in a skirmish game if ((NetPlay.bComms || Cheated) && (NetPlay.players[i].allocated || (NetPlay.players[i].allocated == false && NetPlay.players[i].ai != AI_OPEN))) { inputLoseFocus(); ssprintf(buf, _("The host has kicked %s from the game!"), getPlayerName((unsigned int) i)); sendTextMessage(buf, true); ssprintf(buf, _("kicked %s : %s from the game, and added them to the banned list!"), getPlayerName((unsigned int) i), NetPlay.players[i].IPtextAddress); NETlogEntry(buf, SYNC_FLAG, (unsigned int) i); kickPlayer((unsigned int) i, "you are unwanted by the host.", ERROR_KICKED); return; } } } //radar gifts if(id >= MULTIMENU_GIFT_RAD && id< MULTIMENU_GIFT_RAD +MAX_PLAYERS) { sendGift(RADAR_GIFT, id - MULTIMENU_GIFT_RAD); } // research gift if(id >= MULTIMENU_GIFT_RES && id<MULTIMENU_GIFT_RES +MAX_PLAYERS) { sendGift(RESEARCH_GIFT, id - MULTIMENU_GIFT_RES); } //droid gift if(id >= MULTIMENU_GIFT_DRO && id< MULTIMENU_GIFT_DRO +MAX_PLAYERS) { sendGift(DROID_GIFT, id - MULTIMENU_GIFT_DRO); } //power gift if(id >= MULTIMENU_GIFT_POW && id< MULTIMENU_GIFT_POW +MAX_PLAYERS) { sendGift(POWER_GIFT, id - MULTIMENU_GIFT_POW); } }