void CRevertibleConfigLoader::RevertCVarChanges() { if (!m_savedCVars.empty()) { CryLog ("Need to undo %" PRISIZE_T " %s...", m_savedCVars.size(), (m_savedCVars.size() == 1) ? "variable" : "variables"); IConsole * pConsole = gEnv->pConsole; CryFixedStringT<128> cmd; //Revert the saved cvars in reverse order to handle duplicate settings of the same cvar (which shouldn't be done but people ignore warnings) for (int n = m_savedCVars.size()-1; n >= 0; --n) { ICVar * var = gEnv->pConsole->GetCVar(m_savedCVars[n].m_name); if (var && var->GetType() == CVAR_STRING && strlen(m_savedCVars[n].m_value) == 0) { var->Set(m_savedCVars[n].m_value); } else { cmd.Format("%s %s", m_savedCVars[n].m_name, m_savedCVars[n].m_value); } pConsole->ExecuteString(cmd.c_str(), true); } m_cvarsTextBlock.EmptyWithoutFreeing(); m_savedCVars.clear(); } }
bool CTweakMetadataCVAR::ChangeValue(bool bIncrement) { // Get delta double fDelta = m_fDelta; if (!bIncrement) fDelta *= -1.0; // Get and check CVAR ICVar *cVar = GetCVar(); if (!cVar) return false; // Deal with appropriate type switch (cVar->GetType()) { case CVAR_INT: cVar->Set( (int) (cVar->GetIVal() + fDelta) ); break; case CVAR_FLOAT: cVar->Set( (float) (cVar->GetFVal() + fDelta) ); break; default:; // Strings are non-obvious // Might also be a non-exisitent variable } return true; }
//----------------------------------------------------------------------------------------------------- bool COptionsManager::HandleFSCommand(const char *szCommand,const char *szArgs) { if(!m_pPlayerProfileManager) return false; const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return false; if(!stricmp(szCommand, "SaveProfile")) { UpdateToProfile(); SaveProfile(); return true; } if(!stricmp(szCommand, "RestoreDefaultProfile")) { if(szArgs && szArgs[0]) ResetDefaults(szArgs); else ResetDefaults(NULL); return true; } if(!stricmp(szCommand, "UpdateCVars")) { UpdateFlashOptions(); return true; } if(!stricmp(szCommand, "hud_showAllObjectives")) { if(szArgs) { SAFE_HUD_FUNC(SetShowAllOnScreenObjectives(atoi(szArgs)?true:false)); } } else if(!stricmp(szCommand,"hud_colorLine")) { SetCrysisProfileColor(szArgs); } else if(gEnv->bMultiplayer && !stricmp(szCommand,"g_psTutorial_Enabled")) { if(atoi(szArgs)==1) { gEnv->pConsole->ExecuteString("g_psTutorial_Reset"); } } std::map<string,SOptionEntry>::iterator it = m_profileOptions.find(szCommand); if(it!=m_profileOptions.end()) { ICVar *pCVAR = gEnv->pConsole->GetCVar(szCommand); if(pCVAR) { if(pCVAR->GetType()==1) //int { int value = atoi(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==2) //float { float value = atof(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==3) //string pCVAR->Set(szArgs); return true; // it's a CVAR, we are done! } } //else //does this map to an options function? even if it is inside m_profileOptions, but not a console variable (e.g. pb_client), we want to see if it's a registered command { TOpFuncMapIt iter = m_opFuncMap.find(szCommand); if(iter!=m_opFuncMap.end()) { (this->*(iter->second))(szArgs); return true; } } return false; }