void CommandWindow::CursorEvent(OguiButtonEvent *eve) { if (eve->triggerButton->GetId() == COMMANDW_MAINMENU) { // TODO (Logger::getInstance())->debug("MAIN MENU TODO, PLEASE DO ME! :)"); } if (eve->triggerButton->GetId() == COMMANDW_STORAGE) { // TODO hide(); game->gameUI->openStorageWindow(player); } if (eve->triggerButton->GetId() == COMMANDW_QUIT) { quitPressed = true; } if (eve->triggerButton->GetId() == COMMANDW_COMBAT) { // TODO: proper game request! // TODO: won't work properly if for example one complete armor, but // it has an unpurchased weapon or something... startMission(); } if (eve->triggerButton->GetId() == COMMANDW_ARMOR) { // TODO: NETGAME, replace this with proper request! // (...not needed maybe - does not affect game state?) hide(); game->gameUI->openArmorConstructWindow(player); } }
void MissionSelector::actionPerformed(Widget* source) { if(source == mCloseButton) { hide(); } else if(source == mStartButton) { hide(); int num = mMissionList->getSelected(); startMission(num); } else if(source == mHomeBaseButton) { hide(); rMain()->setMission(ConfigManager::getPlayer()->getHomeBase()); } }
// load up the data for a level bool levLoadData(const char* name, char *pSaveName, GAME_TYPE saveType) { LEVEL_DATASET *psNewLevel, *psBaseData, *psChangeLevel; SDWORD i; bool bCamChangeSaveGame; debug(LOG_WZ, "Loading level %s (%s, type %d)", name, pSaveName, (int)saveType); if (saveType == GTYPE_SAVE_START || saveType == GTYPE_SAVE_MIDMISSION) { if (!levReleaseAll()) { debug(LOG_ERROR, "Failed to unload old data"); return false; } } levelLoadType = saveType; // find the level dataset psNewLevel = levFindDataSet(name); if (psNewLevel == NULL) { debug(LOG_WZ, "Dataset %s not found - trying to load as WRF", name); return levLoadSingleWRF(name); } debug(LOG_WZ, "** Data set found is %s type %d", psNewLevel->pName, (int)psNewLevel->type); /* Keep a copy of the present level name */ sstrcpy(currentLevelName, name); bCamChangeSaveGame = false; if (pSaveName && saveType == GTYPE_SAVE_START) { if (psNewLevel->psChange != NULL) { bCamChangeSaveGame = true; debug(LOG_WZ, "** CAMCHANGE FOUND"); } } // select the change dataset if there is one psChangeLevel = NULL; if (((psNewLevel->psChange != NULL) && (psCurrLevel != NULL)) || bCamChangeSaveGame) { //store the level name debug(LOG_WZ, "Found CAMCHANGE dataset"); psChangeLevel = psNewLevel; psNewLevel = psNewLevel->psChange; } // ensure the correct dataset is loaded if (psNewLevel->type == LDS_CAMPAIGN) { debug(LOG_ERROR, "Cannot load a campaign dataset (%s)", psNewLevel->pName); return false; } else { if (psCurrLevel != NULL) { if ((psCurrLevel->psBaseData != psNewLevel->psBaseData) || (psCurrLevel->type < LDS_NONE && psNewLevel->type >= LDS_NONE) || (psCurrLevel->type >= LDS_NONE && psNewLevel->type < LDS_NONE)) { // there is a dataset loaded but it isn't the correct one debug(LOG_WZ, "Incorrect base dataset loaded (%p != %p, %d - %d)", psCurrLevel->psBaseData, psNewLevel->psBaseData, (int)psCurrLevel->type, (int)psNewLevel->type); if (!levReleaseAll()) // this sets psCurrLevel to NULL { return false; } } else { debug(LOG_WZ, "Correct base dataset already loaded."); } } // setup the correct dataset to load if necessary if (psCurrLevel == NULL) { if (psNewLevel->psBaseData != NULL) { debug(LOG_WZ, "Setting base dataset to load: %s", psNewLevel->psBaseData->pName); } psBaseData = psNewLevel->psBaseData; } else { debug(LOG_WZ, "No base dataset to load"); psBaseData = NULL; } } setCurrentMap(psNewLevel->pName, psNewLevel->players); if (!rebuildSearchPath(psNewLevel->dataDir, true)) { return false; } // reset the old mission data if necessary if (psCurrLevel != NULL) { debug(LOG_WZ, "Reseting old mission data"); if (!levReleaseMissionData()) { return false; } } // need to free the current map and droids etc for a save game if ((psBaseData == NULL) && (pSaveName != NULL)) { if (!saveGameReset()) { return false; } } // initialise if necessary if (psNewLevel->type == LDS_COMPLETE || //psNewLevel->type >= LDS_MULTI_TYPE_START || psBaseData != NULL) { debug(LOG_WZ, "Calling stageOneInitialise!"); if (!stageOneInitialise()) { return false; } } // load up a base dataset if necessary if (psBaseData != NULL) { debug(LOG_WZ, "Loading base dataset %s", psBaseData->pName); for(i=0; i<LEVEL_MAXFILES; i++) { if (psBaseData->apDataFiles[i]) { // load the data debug(LOG_WZ, "Loading [directory: %s] %s ...", PHYSFS_getRealDir(psBaseData->apDataFiles[i]), psBaseData->apDataFiles[i]); if (!resLoad(psBaseData->apDataFiles[i], i)) { return false; } } } } if (psNewLevel->type == LDS_CAMCHANGE) { if (!campaignReset()) { return false; } } if (psNewLevel->game == -1) //no .gam file to load - BETWEEN missions (for Editor games only) { ASSERT( psNewLevel->type == LDS_BETWEEN, "levLoadData: only BETWEEN missions do not need a .gam file" ); debug(LOG_WZ, "No .gam file for level: BETWEEN mission"); if (pSaveName != NULL) { if (psBaseData != NULL) { if (!stageTwoInitialise()) { return false; } } //set the mission type before the saveGame data is loaded if (saveType == GTYPE_SAVE_MIDMISSION) { debug(LOG_WZ, "Init mission stuff"); if (!startMissionSave(psNewLevel->type)) { return false; } debug(LOG_NEVER, "dataSetSaveFlag"); dataSetSaveFlag(); } debug(LOG_NEVER, "Loading savegame: %s", pSaveName); if (!loadGame(pSaveName, false, true,true)) { return false; } } if ((pSaveName == NULL) || (saveType == GTYPE_SAVE_START)) { debug(LOG_NEVER, "Start mission - no .gam"); if (!startMission((LEVEL_TYPE)psNewLevel->type, NULL)) { return false; } } } //we need to load up the save game data here for a camchange if (bCamChangeSaveGame) { if (pSaveName != NULL) { if (psBaseData != NULL) { if (!stageTwoInitialise()) { return false; } } debug(LOG_NEVER, "loading savegame: %s", pSaveName); if (!loadGame(pSaveName, false, true,true)) { return false; } if (!campaignReset()) { return false; } } } // load the new data debug(LOG_NEVER, "Loading mission dataset: %s", psNewLevel->pName); for(i=0; i < LEVEL_MAXFILES; i++) { if (psNewLevel->game == i) { // do some more initialising if necessary if (psNewLevel->type == LDS_COMPLETE || psNewLevel->type >= LDS_MULTI_TYPE_START || (psBaseData != NULL && !bCamChangeSaveGame)) { if (!stageTwoInitialise()) { return false; } } // load a savegame if there is one - but not if already done so if (pSaveName != NULL && !bCamChangeSaveGame) { //set the mission type before the saveGame data is loaded if (saveType == GTYPE_SAVE_MIDMISSION) { debug(LOG_WZ, "Init mission stuff"); if (!startMissionSave(psNewLevel->type)) { return false; } debug(LOG_NEVER, "dataSetSaveFlag"); dataSetSaveFlag(); } debug(LOG_NEVER, "Loading save game %s", pSaveName); if (!loadGame(pSaveName, false, true,true)) { return false; } } if ((pSaveName == NULL) || (saveType == GTYPE_SAVE_START)) { // load the game debug(LOG_WZ, "Loading scenario file %s", psNewLevel->apDataFiles[i]); switch (psNewLevel->type) { case LDS_COMPLETE: case LDS_CAMSTART: debug(LOG_WZ, "LDS_COMPLETE / LDS_CAMSTART"); if (!startMission(LDS_CAMSTART, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_BETWEEN: debug(LOG_WZ, "LDS_BETWEEN"); if (!startMission(LDS_BETWEEN, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_MKEEP: debug(LOG_WZ, "LDS_MKEEP"); if (!startMission(LDS_MKEEP, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_CAMCHANGE: debug(LOG_WZ, "LDS_CAMCHANGE"); if (!startMission(LDS_CAMCHANGE, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_EXPAND: debug(LOG_WZ, "LDS_EXPAND"); if (!startMission(LDS_EXPAND, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_EXPAND_LIMBO: debug(LOG_WZ, "LDS_LIMBO"); if (!startMission(LDS_EXPAND_LIMBO, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_MCLEAR: debug(LOG_WZ, "LDS_MCLEAR"); if (!startMission(LDS_MCLEAR, psNewLevel->apDataFiles[i])) { return false; } break; case LDS_MKEEP_LIMBO: debug(LOG_WZ, "LDS_MKEEP_LIMBO"); if (!startMission(LDS_MKEEP_LIMBO, psNewLevel->apDataFiles[i])) { return false; } break; default: ASSERT( psNewLevel->type >= LDS_MULTI_TYPE_START, "levLoadData: Unexpected mission type" ); debug(LOG_WZ, "default (MULTIPLAYER)"); if (!startMission(LDS_CAMSTART, psNewLevel->apDataFiles[i])) { return false; } break; } } } else if (psNewLevel->apDataFiles[i]) { // load the data debug(LOG_WZ, "Loading %s", psNewLevel->apDataFiles[i]); if (!resLoad(psNewLevel->apDataFiles[i], i + CURRENT_DATAID)) { return false; } } } if (pSaveName != NULL) { //load MidMission Extras if (!loadMissionExtras(pSaveName, psNewLevel->type)) { return false; } } if (bMultiPlayer) { loadMultiScripts(); } if (pSaveName != NULL && saveType == GTYPE_SAVE_MIDMISSION) { //load script stuff // load the event system state here for a save game debug(LOG_SAVE, "Loading script system state"); if (!loadScriptState(pSaveName)) { return false; } } if (!stageThreeInitialise()) { return false; } dataClearSaveFlag(); //this enables us to to start cam2/cam3 without going via a save game and get the extra droids //in from the script-controlled Transporters if (!pSaveName && psNewLevel->type == LDS_CAMSTART) { eventFireCallbackTrigger((TRIGGER_TYPE)CALL_NO_REINFORCEMENTS_LEFT); } //restore the level name for comparisons on next mission load up if (psChangeLevel == NULL) { psCurrLevel = psNewLevel; } else { psCurrLevel = psChangeLevel; } { // Copy this info to be used by the crash handler for the dump file char buf[256]; ssprintf(buf, "Current Level/map is %s", psCurrLevel->pName); addDumpInfo(buf); } return true; }
void Operation::proceedTurn() { startMission(_nextMission); //startujemy misje, nextMission roœnie o jeden scout(); //przeprowadzamy zwiad }
void MissionSelector::replayMission() { startMission(mMissionNum); }
void MissionSelector::startNextMission() { startMission(0); }