Ejemplo n.º 1
0
void CProfileOptions::SaveToProfile(IPlayerProfile* pProfile, bool online, unsigned int reason)
{
	if(reason & ePR_Options)
	{
	  if(online && gEnv->bMultiplayer)
	  if (pProfile == NULL)
		  return;
  
	  //Want to save all the options (mostly for online attributes)
	  std::vector<COption*>::iterator it = m_allOptions.begin();
	  std::vector<COption*>::iterator end = m_allOptions.end();
	  for(; it!=end; ++it)
	  {
			COption					*pOption = *it;

			IPlayerProfile	*pPrevPlayerProfile = pOption->GetPlayerProfile();

			pOption->SetPlayerProfile(pProfile);
		  
			pOption->SetToProfile();

			pOption->SetPlayerProfile(pPrevPlayerProfile);
	  }
	}
}
Ejemplo n.º 2
0
void CProfileOptions::AddOption(const char* name, const char* value, const char* cvar /*= NULL*/, const bool preview /*= false*/, const bool confirmation /*= false*/, const bool restart /*= false*/, const bool writeToConfig /*= false*/)
{
	if(!name || !name[0])
		return;

	if(!value)
		return;

	ScopedSwitchToGlobalHeap globalHeap;

	COption* pOption = NULL;
	CryFixedStringT<64> tmpName(name);
	CryFixedStringT<64> compareName("SysSpec");
	if(tmpName.find(compareName.c_str())==0)
	{
		if(compareName.length() == tmpName.length())
		{
			pOption = new CSysSpecAllOption(name, value, cvar);
		}
		else
		{
			pOption = new CSysSpecOption(name, value, cvar);
		}
	}
	else if(IsCVar(cvar))
	{
		pOption = new CCVarOption(name, value, cvar);
	}
	else if(!strcmp(name, "Resolution"))
	{
		pOption = new CScreenResolutionOption(name, value);
	}
	else
	{
		pOption = new COption(name, value);
	}

	pOption->SetPreview(preview);
	pOption->SetConfirmation(confirmation);
	pOption->SetRequiresRestart(restart);
	pOption->SetWriteToConfig(writeToConfig);

	if(pOption)
	{
		if(IPlayerProfileManager* profileManager = g_pGame->GetIGameFramework()->GetIPlayerProfileManager())
		{
			if(IPlayerProfile *profile = profileManager->GetCurrentProfile(profileManager->GetCurrentUser()))
			{
				pOption->SetPlayerProfile(profile);
				pOption->InitializeFromProfile();
			}

			if(!m_bLoadingProfile)
			{
				m_allOptions.push_back(pOption);
			}
			else
			{
				CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING,
						   "Adding \"%s\" option while loading values from profile, option might not be initialized properly. Consider adding to attributes.xml", name);
			}
		}
	}
}