void CProfileOptions::LoadFromProfile(IPlayerProfile* pProfile, bool online, unsigned int reason) { if(reason & ePR_Options) { CRY_ASSERT(pProfile != NULL); if (pProfile == NULL) return; m_bLoadingProfile = true; std::vector<COption*> options_to_init = m_allOptions; // Update the stored player profile pointer to stay in sync std::vector<COption*>::iterator it = options_to_init.begin(); std::vector<COption*>::iterator end = options_to_init.end(); for(; it!=end; ++it) { (*it)->SetPlayerProfile(pProfile); //Resets to default (*it)->InitializeFromProfile(); } m_bLoadingProfile = false; if (!IsInitialProfileLoaded()) { SetInitialProfileLoaded(true); } // Need to support overriding cvars from game.cfg // After profile switch, need game.cfg rewritten since don't want original game.cfg values from overwriting // if quit game and come back WriteGameCfg(); } }
void CProfileOptions::FlushPendingOptionValues() { if(m_pendingOptions.empty()) return; WriteGameCfg(); std::vector<SPendingOption>::const_iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); bool bResetOverscan = false; bool bIsMultiGPUEnabled = false; if(gEnv->pRenderer) gEnv->pRenderer->EF_Query(EFQ_MultiGPUEnabled, bIsMultiGPUEnabled); if (bIsMultiGPUEnabled) { bool bRequiresMGPUCfgReload = false; for(; it!=end; ++it) { const SPendingOption& option = (*it); const char* szCommandStr = option.command.c_str(); if ( (strcmp(szCommandStr, "Resolution") != 0) && (strcmp(szCommandStr, "Fullscreen") != 0) && (strcmp(szCommandStr, "VSync") != 0) && (strcmp(szCommandStr, "SysSpec") != 0)) // mgpu.cfg is automatically reloaded when cvar is changed { bRequiresMGPUCfgReload = true; } SetOptionValue(szCommandStr, option.param.c_str()); } if (bRequiresMGPUCfgReload) { GetISystem()->LoadConfiguration("mgpu.cfg"); } } else { for(; it!=end; ++it) { const SPendingOption& option = (*it); const char* szCommandStr = option.command.c_str(); if (strcmp(szCommandStr, "Stereo") == 0) { bResetOverscan = true; } SetOptionValue(option.command.c_str(), option.param.c_str()); } } stl::free_container(m_pendingOptions); if (bResetOverscan) { ResetOverscanBorders (); } }
void COptionsManager::SaveProfile() { if(!m_pPlayerProfileManager) return; IPlayerProfileManager::EProfileOperationResult result; m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result); WriteGameCfg(); }
void COptionsManager::InitProfileOptions(bool switchProfiles) { if(!m_pPlayerProfileManager) return; if(g_pGameCVars->g_useProfile==0) return; if(g_pGameCVars->g_startFirstTime==1) { ICVar *pCVar = gEnv->pConsole->GetCVar("g_startFirstTime"); if(pCVar && pCVar->GetIVal()==1) { pCVar->Set(0); m_firstStart = true; } switchProfiles=true; } const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return; IAttributeEnumeratorPtr attribEnum = pProfile->CreateAttributeEnumerator(); IAttributeEnumerator::SAttributeDescription attrib; m_profileOptions.clear(); while(attribEnum->Next(attrib)) { bool bWriteToCfg = false; const char* attribCVar = ""; const bool bIsOption = IsOption(attrib.name, attribCVar, bWriteToCfg); if (bIsOption) { SOptionEntry entry (attrib.name, bWriteToCfg); m_profileOptions[attribCVar] = entry; if(!bWriteToCfg || switchProfiles) { string value; if(!strcmp(attribCVar, "pb_client")) { GetProfileValue(attrib.name, value); if(atoi(value)==0) { m_pbEnabled = false; gEnv->pConsole->ExecuteString("net_pb_cl_enable false"); } else { m_pbEnabled = true; gEnv->pConsole->ExecuteString("net_pb_cl_enable true"); } continue; } else if(!strcmp(attribCVar, "fsaa_mode")) { GetProfileValue(attrib.name, value); SetAntiAliasingMode(value.c_str()); } else if(!strcmp(attribCVar, "g_difficultyLevel")) { GetProfileValue(attrib.name, value); SetDifficulty(value); } ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar); if(pCVar && GetProfileValue(attrib.name, value)) { if(stricmp(pCVar->GetString(), value.c_str())) { //CryLogAlways("Inited, loaded and changed: %s = %s (was %s)", attrib.name, value, pCVar->GetString()); pCVar->Set(value.c_str()); } else { //CryLogAlways("Inited, loaded, but not changed: %s = %s", attrib.name, value); } if(!stricmp(attrib.name,"Option.hud_colorLine")) { SetCrysisProfileColor(value.c_str()); } } } } } WriteGameCfg(); }