void CProfileOptions::ResetToDefault() { ClearPendingOptionValues(); // Just to be safe std::vector<COption*>::iterator it = m_allOptions.begin(); std::vector<COption*>::const_iterator end = m_allOptions.end(); for(; it!=end; ++it) { COption* pOption = (*it); if (!pOption->IsWriteToConfig()) { pOption->ResetDefault(); } } }
void CProfileOptions::CCVarSink::OnElementFound(ICVar *pCVar) { if (pCVar == 0) return; const char* name = pCVar->GetName(); const char* val = pCVar->GetString(); COption* pOption = m_pOptions->GetOptionByCVar(name); if(!pOption) return; if(!pOption->IsWriteToConfig()) return; const char* optionName = pOption->GetName().c_str(); const char* writeValue = pOption->Get().c_str(); const std::vector<SPendingOption>& pendingOptions = m_pOptions->GetPendingOptions(); std::vector<SPendingOption>::const_iterator it = pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = pendingOptions.end(); for(; it!=end; ++it) { const SPendingOption& option = (*it); if(!option.writeToConfig) continue; if(option.command.compareNoCase(optionName)) continue; writeValue = option.param.c_str(); break; } CryFixedStringT<128> format; pOption->GetWriteToConfigString(format, pCVar, writeValue); fputs(format.c_str(), m_pFile); }
void CProfileOptions::AddOrReplacePendingOption(const char* command, const char* param) { std::vector<SPendingOption>::iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); for(; it!=end; ++it) { SPendingOption& option = (*it); if(option.command.compare(command)) continue; if(option.preview) { SetOptionValue(command, param); } if(option.original.compare(param)) { option.param = param; } else { m_pendingOptions.erase(it); } return; } COption* pOption = GetOption(command); if(pOption != NULL) { if(pOption->IsPreview()) { m_pendingOptions.push_back(SPendingOption(command, param, GetOptionValue(command), true, pOption->IsConfirmation(), pOption->IsRequiresRestart(), pOption->IsWriteToConfig())); SetOptionValue(command, param); } else { m_pendingOptions.push_back(SPendingOption(command, param, GetOptionValue(command), false, pOption->IsConfirmation(), pOption->IsRequiresRestart(), pOption->IsWriteToConfig())); } } }