示例#1
0
//------------------------------------------------------------------------
bool CPlayerProfile::Reset()
{
	if (IsDefault())
		return false;

	// for now, try to get the action map from the IActionMapManager
	IActionMapManager* pAM = CCryAction::GetCryAction()->GetIActionMapManager();
	pAM->Reset();
	// well, not very efficient at the moment...
	TAttributeMap::iterator iter = m_attributeMap.begin();
	while (iter != m_attributeMap.end())
	{
		TAttributeMap::iterator next = iter;
		++next;
		ResetAttribute(iter->first);
		iter = next;
	}

	LoadGamerProfileDefaults();
	gEnv->pSystem->AutoDetectSpec(false);

	return true;
}
示例#2
0
//------------------------------------------------------------------------
bool CPlayerProfile::SerializeXML(CPlayerProfileManager::IProfileXMLSerializer* pSerializer)
{
	if (pSerializer->IsLoading())
	{
		// serialize attributes
		XmlNodeRef attributesNode = pSerializer->GetSection(CPlayerProfileManager::ePPS_Attribute);
		if (attributesNode)
		{
			CPlayerProfile* pDefaultProfile = static_cast<CPlayerProfile*> (m_pManager->GetDefaultProfile());
			int requiredVersion = 0;
			if (IsDefault() == false && pDefaultProfile)
				requiredVersion = pDefaultProfile->m_attributesVersion;
			bool ok = LoadAttributes(attributesNode, requiredVersion);
		}
		else
		{
			GameWarning("CPlayerProfile::SerializeXML: No attributes tag '%s' found", ATTRIBUTES_TAG);
			return false;
		}

		// preview profiles never load actionmaps!
		if (m_bIsPreview == false)
		{
			// serialize action maps
			XmlNodeRef actionMaps = pSerializer->GetSection(CPlayerProfileManager::ePPS_Actionmap);
			if (actionMaps)
			{
				// the default profile loaded has no associated actionmaps, but
				// rather assumes that all actionmaps which are currently loaded belong to the default
				// profile
				// if it's not the default profile to be loaded, then we load the ActionMap
				// but we do a version check. if the profile's actionmaps are outdated, it's not loaded
				// but the default action map is used instead
				// on saving the profile it's automatically updated (e.g. the current actionmaps [correct version] 
				// are saved
				IActionMapManager* pAM = CCryAction::GetCryAction()->GetIActionMapManager();
				if (IsDefault() == false && pAM)
				{
					pAM->Reset();

					pAM->LoadRebindDataFromXML(actionMaps); // check version and don't load if outdated
				}
			}
			else
			{
				GameWarning("CPlayerProfile::SerializeXML: No actionmaps tag '%s' found", ACTIONMAPS_TAG);
				return false;
			}
		}
	}
	else
	{
		if (m_bIsPreview == false)
		{
			// serialize attributes
			XmlNodeRef attributesNode = pSerializer->CreateNewSection(CPlayerProfileManager::ePPS_Attribute, CPlayerProfile::ATTRIBUTES_TAG);
			bool ok = SaveAttributes(attributesNode);
			if (!ok)
				return false;
	
			// serialize action maps
			IActionMapManager* pAM = CCryAction::GetCryAction()->GetIActionMapManager();
			XmlNodeRef actionMapsNode = pSerializer->CreateNewSection(CPlayerProfileManager::ePPS_Actionmap, CPlayerProfile::ACTIONMAPS_TAG);
			pAM->SaveRebindDataToXML(actionMapsNode);
			return ok;
		}
	}
	return true;
}