void CEditorGame::OnSaveLevel() { ILevel* pCurrentLevel = m_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel(); if (pCurrentLevel) { ILevelInfo* pLevelInfo = pCurrentLevel->GetLevelInfo(); string levelPath = PathUtil::GetGameFolder() + "/" + pLevelInfo->GetPath(); InitEntityArchetypeEnums(m_pGTE, levelPath, PathUtil::GetFile(pLevelInfo->GetName())); } }
void CUIGameEvents::OnLoadGame( bool shouldResume ) { if (gEnv->IsEditor()) return; ILevelInfo* pLevel = m_pLevelSystem->GetCurrentLevel(); if (pLevel) { m_pGameFramework->LoadGame(pLevel->GetPath(), true); if ( shouldResume && m_pGameFramework->IsGamePaused() ) m_pGameFramework->PauseGame(false, true); } }
string CDevMode::TagFileName() { ILevelSystem * pLevelSystem = CCryAction::GetCryAction()->GetILevelSystem(); ILevelInfo* pLevel = pLevelSystem->GetCurrentLevel(); if (!pLevel) return ""; string path = pLevel->GetPath(); path = PathUtil::GetGameFolder()+ string("/") + path + "/tags.txt"; return path; }
EContextEstablishTaskResult OnStep(SContextEstablishState& state) { ILevel* pLevel = CCryAction::GetCryAction()->GetILevelSystem()->GetCurrentLevel(); if (!pLevel) { GameWarning("level is null"); return eCETR_Failed; } const char * levelName = CCryAction::GetCryAction()->GetLevelName(); if (!levelName) { GameWarning("levelName is null"); return eCETR_Failed; } ILevelInfo* pLevelInfo = CCryAction::GetCryAction()->GetILevelSystem()->GetLevelInfo(levelName); if (!pLevelInfo) { GameWarning("levelInfo is null"); return eCETR_Failed; } // delete any pending entities before reserving EntityIds in LoadEntities() gEnv->pEntitySystem->DeletePendingEntities(); string missionXml = pLevelInfo->GetDefaultGameType()->xmlFile; string xmlFile = string(pLevelInfo->GetPath()) + "/" + missionXml; XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile(xmlFile.c_str()); if (rootNode) { const char *script = rootNode->getAttr("Script"); if (script && script[0]) gEnv->pScriptSystem->ExecuteFile(script, true, true); XmlNodeRef objectsNode = rootNode->findChild("Objects"); if (objectsNode) gEnv->pEntitySystem->LoadEntities(objectsNode, false); } else return eCETR_Failed; SEntityEvent loadingCompleteEvent(ENTITY_EVENT_LEVEL_LOADED); gEnv->pEntitySystem->SendEventToAll( loadingCompleteEvent ); return eCETR_Ok; }
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { switch (event) { case eFE_Initialize: break; case eFE_Activate: { if(!IsPortActive(pActInfo, EIP_Load)) return; // get the file name string pathAndfileName; const string fileName = GetPortString(pActInfo, EIP_FileName); if (fileName.empty()) return; ILevelInfo* pCurrentLevel = gEnv->pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel(); string path = pCurrentLevel ? pCurrentLevel->GetPath() : ""; pathAndfileName.Format("%s/%s", path.c_str(), fileName.c_str()); // try to load it XmlNodeRef root = GetISystem()->LoadXmlFromFile( pathAndfileName ); if (root == NULL) { CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "FlowGraph: TimeOfDay Loading Node: Could not load tod file %s. Aborting.", pathAndfileName.c_str()); ActivateOutput(pActInfo, EOP_Fail, true); return; } // get the TimeofDay interface ITimeOfDay *pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); if (pTimeOfDay == NULL) { CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "FlowGraph: TimeOfDay Loading Node: Could not obtain ITimeOfDay interface from engine. Aborting."); ActivateOutput(pActInfo, EOP_Fail, true); return; } // try to serialize from that file pTimeOfDay->Serialize( root,true ); pTimeOfDay->Update(true, true); ActivateOutput(pActInfo, EOP_Success, true); } break; } }
void CModInfoManager::Refresh() { #ifndef _WIN32 assert(0 && "Calling Windows-specific code"); return; #endif if (!gEnv || !gEnv->pCryPak) { assert(0); return; } ICryPak* pCryPak = gEnv->pCryPak; m_mods.clear(); // look for MODs { _finddata_t fd; intptr_t h = pCryPak->FindFirst ("Mods\\*", &fd, 0, true); if (h != -1) { CryStackStringT<char, _MAX_PATH*2> path; do { if ((fd.attrib & _A_SUBDIR) == 0) continue; if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0) continue; path = "Mods\\"; path += fd.name; ModInfo mod; if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str()) && mod.modType != eMIT_SPLEVEL) { mod.keyName = fd.name; if (mod.displayName.empty()) mod.displayName = mod.keyName; path.replace('\\', '/'); path.insert(0, '/'); mod.mainImage = (path + "/modpreview.jpg").c_str(); mod.logoImage = (path + "/modteamlogo.jpg").c_str(); m_mods.push_back(mod); } } while(0 == pCryPak->FindNext(h, &fd)); pCryPak->FindClose (h); } } // look for SP-levels { CryStackStringT<char, _MAX_PATH*2> path; path += PathUtil::GetGameFolder(); path += "\\Levels\\*"; _finddata_t fd; intptr_t h = pCryPak->FindFirst (path.c_str(), &fd, 0, true); if (h != -1) { do { if ((fd.attrib & _A_SUBDIR) == 0) continue; if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0) continue; path = PathUtil::GetGameFolder(); path += "\\Levels\\"; path += fd.name; ModInfo mod; if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str())) { mod.modType = eMIT_SPLEVEL; mod.keyName = fd.name; path = "/Levels/"; path += fd.name; mod.mainImage = (path + "/modpreview.jpg").c_str(); mod.logoImage = (path + "/modteamlogo.jpg").c_str(); if (mod.displayName.empty()) mod.displayName = mod.keyName; m_mods.push_back(mod); } } while(0 == pCryPak->FindNext(h, &fd)); pCryPak->FindClose (h); } } // look for MOD levels { m_modLevels.clear(); CryStackStringT<char, _MAX_PATH*2> path; ILevelSystem* pLevelSystem = g_pGame->GetIGameFramework()->GetILevelSystem(); size_t levelCount = pLevelSystem->GetLevelCount(); for (size_t i = 0; i < levelCount; ++i) { ILevelInfo* pInfo = pLevelSystem->GetLevelInfo(i); if (!pInfo) continue; if (pInfo->GetIsModLevel() && (!pInfo->HasGameRules() || pInfo->SupportsGameType("SinglePlayer"))) { ModInfo mod; const char* szLevelInfoDisplayName = pInfo->GetDisplayName(); if (strcmp(szLevelInfoDisplayName, "") != 0) { mod.displayName = szLevelInfoDisplayName; } else // Fallback to directory name { mod.displayName = pInfo->GetName(); } // load info.xml as well path = pInfo->GetPath(); path.replace('/', '\\'); if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str())) { path.replace('\\', '/'); path.insert(0, '/'); mod.mainImage = (path + "/modpreview.jpg").c_str(); mod.logoImage = (path + "/modteamlogo.jpg").c_str(); } mod.keyName = pInfo->GetName(); mod.modType = eMIT_SPLEVEL; m_modLevels.push_back(mod); } } } }