Exemplo n.º 1
0
void
MissionSelector::loadMission(string fileName)
{
  if(fileName == "") return;

  Mission* oldMission = rMain()->getMission();
  
  Orbit* orbitScreen = static_cast<Orbit*>(rMain()->getScreenManager().getState(Main::ORBIT_SCREEN));
  orbitScreen->enterReadyState();
  
  DataFile* dataFile = new DataFile(stringToWString(fileName));

  if(dataFile->getRootItem() != NULL) {
    Mission* mission = dataFile->getRootItem()->castToClass<Mission>();
    if(mission != NULL) {
      rMain()->setMission(mission);      
  
      if(oldMission != NULL) {
        if (oldMission == ConfigManager::getPlayer()->getHomeBase()) {
          ConfigManager::getSingleton().savePlayer();
        }
        else {
          delete oldMission->getDataFile();
        }
      }
    }
  }
}
Exemplo n.º 2
0
void
MissionSelector::startMission(unsigned num)
{
  Entry missionEntry;
  if(mCurrentCampaign == NULL) {
    // FIXME: we should fall back to station school in case a first timer plays
    missionEntry = mMissions[0];
  }
  else {
    if(num < 0 || num >= static_cast<int>(mCurrentMissions.size())) return;
    mMissionNum = num;
    missionEntry = mCurrentMissions[num];
  }
  
  Mission* oldMission = rMain()->getMission();
  
  Orbit* orbitScreen = static_cast<Orbit*>(rMain()->getScreenManager().getState(Main::ORBIT_SCREEN));
  orbitScreen->enterReadyState();
  
  DataFile* dataFile = new DataFile();
  Mission* mission = new Mission(dataFile);
  dataFile->setRootItem(mission);
  rMain()->setMission(mission);
  mission->initScriptFile(missionEntry.script);
  
  if(oldMission != NULL) {
    if (oldMission == ConfigManager::getPlayer()->getHomeBase()) {
      ConfigManager::getSingleton().savePlayer();
    }
    else {
      delete oldMission->getDataFile();
    }
  }
}