コード例 #1
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
bool COptionsManager::GetProfileValue(const char* key, string &value)
{
	if(!m_pPlayerProfileManager)
	{
		if(gEnv->pSystem->IsEditor())
		{
			if(strcmp(key, "ColorLine") == 0)
			{
				value = m_defaultColorLine;
			}
			else if(strcmp(key, "ColorOver") == 0)
			{
				value = m_defaultColorOver;
			}
			else if(strcmp(key, "ColorText") == 0)
			{
				value = m_defaultColorText;
			}
			else
			{
				value.clear();
			}
			return true;
		}
		return false;
	}

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile) return false;

	return pProfile->GetAttribute(key, value);
}
コード例 #2
0
void CFlashMenuObject::SelectProfile(const char *profileName, bool silent, bool keepOldSettings)
{
	if(m_pPlayerProfileManager)
	{
		const char *userName = m_pPlayerProfileManager->GetCurrentUser();
		IPlayerProfile *oldProfile = m_pPlayerProfileManager->GetCurrentProfile(userName);
		if(oldProfile)
			SwitchProfiles(oldProfile->GetName(), profileName);
		else
			SwitchProfiles(NULL, profileName);
    g_pGame->GetIGameFramework()->GetILevelSystem()->LoadRotation();
		UpdateProfiles();
		if(keepOldSettings)
			g_pGame->GetOptions()->UpdateToProfile();
		g_pGame->GetOptions()->InitProfileOptions(true);
		g_pGame->GetOptions()->UpdateFlashOptions();
		g_pGame->GetOptions()->WriteGameCfg();
		UpdateMenuColor();
		if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
		{
			if(!silent)
			{
				m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.gotoProfileMenu");
				ShowMenuMessage("@ui_menu_PROFILELOADED");
			}
		}
	}
}
コード例 #3
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
bool COptionsManager::GetProfileValue(const char* key, float &value)
{
	if(!m_pPlayerProfileManager) return false;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile) return false;

	return pProfile->GetAttribute(key, value);
}
コード例 #4
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
void COptionsManager::SaveValueToProfile(const char* key, float value)
{
	if(!m_pPlayerProfileManager)
		return;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;

	pProfile->SetAttribute(key, value);
	SaveProfile();
}
コード例 #5
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
void COptionsManager::SaveCVarToProfile(const char* key, const string& value)
{
	if(!m_pPlayerProfileManager)
		return;
	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;

	pProfile->SetAttribute(key, value);
	IPlayerProfileManager::EProfileOperationResult result;
	m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result);
}
コード例 #6
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
const char* COptionsManager::GetProfileName()
{
	if(!m_pPlayerProfileManager)
		return "Nomad";
	const char* user = m_pPlayerProfileManager->GetCurrentUser();
	if(!user)
		return "Nomad";
	IPlayerProfile* profile = m_pPlayerProfileManager->GetCurrentProfile(user);
	if(!profile)
		return "Nomad";
	if(!stricmp(profile->GetName(),"default"))
		return "Nomad";
	return profile->GetName();

}
コード例 #7
0
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch(event)
		{
		case eFE_Activate:
			{
				if (IsPortActive(pActInfo, eIP_Get))
				{
					IPlayerProfile* pProfile = NULL;
					if (IPlayerProfileManager *pProfileMan = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager())
					{
						const char* user = pProfileMan->GetCurrentUser();
						pProfile = pProfileMan->GetCurrentProfile(user);
						TFlowInputData data;
						if (!pProfile || pProfile->GetAttribute(GetPortString(pActInfo, eIP_Name), data))
						{
							ActivateOutput(pActInfo, eOP_Value, data);
						}
						else
						{
							ActivateOutput(pActInfo, eOP_Error, 1);
						}
					}
				}

				if (IsPortActive(pActInfo, eIP_Set))
				{
					IPlayerProfile* pProfile = NULL;
					if (IPlayerProfileManager *pProfileMan = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager())
					{
						const char *user = pProfileMan->GetCurrentUser();
						pProfile = pProfileMan->GetCurrentProfile( user );
						if(!pProfile || !pProfile->SetAttribute(GetPortString(pActInfo, eIP_Name), GetPortAny(pActInfo, eIP_Set)))
						{
							ActivateOutput(pActInfo, eOP_Error, 1);
						}
					}
				}
			}
			break;
		}
	}
コード例 #8
0
void CFlashMenuObject::StartSingleplayerGame(const char *strDifficulty)
{
	int iDifficulty = 0;
	if(!strcmp(strDifficulty,"Easy"))
	{
		iDifficulty = 1;
	}
	else if(!strcmp(strDifficulty,"Normal"))
	{
		iDifficulty = 2;
	}
	else if(!strcmp(strDifficulty,"Realistic"))
	{
		iDifficulty = 3;
	}
	else if(!strcmp(strDifficulty,"Delta"))
	{
		iDifficulty = 4;
	}

	// load configuration from disk
	if (iDifficulty != 0)
		LoadDifficultyConfig(iDifficulty);

	if(m_pPlayerProfileManager)
	{
		IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
		if(pProfile)
		{
			pProfile->SetAttribute("Singleplayer.LastSelectedDifficulty",(TFlowInputData)iDifficulty);
			IPlayerProfileManager::EProfileOperationResult result;
			m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result);
		}
	}
	StopVideo();
	m_bDestroyStartMenuPending = true;
	m_stateEntryMovies = eEMS_GameStart;
	if(m_pMusicSystem)
		m_pMusicSystem->EndTheme(EThemeFade_StopAtOnce, 0, true);
	PlaySound(ESound_MenuAmbience,false);
}
コード例 #9
0
void CFlashMenuObject::DeleteSaveGame(const char *fileName)
{

	const char *reason = ValidateName(fileName);
	if(reason)
	{
		ShowMenuMessage(reason);
		return;
	}
	else
	{
		if(!m_pPlayerProfileManager)
			return;

		IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
		if(!pProfile)
			return;
		pProfile->DeleteSaveGame(fileName);
		UpdateSaveGames();
	}
}
コード例 #10
0
void CFlashMenuObject::UpdateProfiles()
{
	IPlayerProfileManager *pProfileMan = g_pGame->GetOptions()->GetProfileManager();
	if(!pProfileMan)
		return;

	m_pPlayerProfileManager = pProfileMan;

	IPlayerProfileManager::EProfileOperationResult result;
	m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result);

	if(m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
	{
		m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.resetProfiles");

		const char *userName = m_pPlayerProfileManager->GetCurrentUser();

		for(int i = 0; i < m_pPlayerProfileManager->GetProfileCount(userName); ++i )
		{
			IPlayerProfileManager::SProfileDescription profDesc;
			pProfileMan->GetProfileInfo(userName, i, profDesc);
			const IPlayerProfile *pProfile = m_pPlayerProfileManager->PreviewProfile(userName, profDesc.name);
			string buffer;
			if(pProfile && pProfile->GetAttribute("Singleplayer.LastSavedGame", buffer))
			{
				int pos = buffer.rfind('/');
				if(pos)
					buffer = buffer.substr(pos+1, buffer.length());
			}
			SFlashVarValue args[3] = {profDesc.name, buffer.c_str(), GetMappedProfileName(profDesc.name) };
			m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.Profile.addProfileToList", args, 3);
		}
		m_pPlayerProfileManager->PreviewProfile(userName, NULL);

		IPlayerProfile *pProfile = pProfileMan->GetCurrentProfile(userName);
		if(pProfile)
			m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("setActiveProfile", GetMappedProfileName(pProfile->GetName()));
	}
}
コード例 #11
0
ファイル: CET_ActionMap.cpp プロジェクト: aronarts/FireNET
	EContextEstablishTaskResult OnStep(SContextEstablishState& state)
	{
    IActionMapManager *pActionMapMan = CCryAction::GetCryAction()->GetIActionMapManager();
    CRY_ASSERT(pActionMapMan);
    
    IActionMap* pDefaultActionMap = NULL;
		IActionMap* pDebugActionMap = NULL;
		IActionMap* pPlayerActionMap = NULL;
		IActionMap* pPlayerGamemodeActionMap = NULL;

		const char* disableGamemodeActionMapName = "player_mp";
		const char* gamemodeActionMapName = "player_sp";

		if(gEnv->bMultiplayer)
		{
			disableGamemodeActionMapName = "player_sp";
			gamemodeActionMapName = "player_mp";
		}

		if (true)
		{
			IPlayerProfileManager* pPPMgr = CCryAction::GetCryAction()->GetIPlayerProfileManager();
			if (pPPMgr)
			{
				int userCount = pPPMgr->GetUserCount();

				IPlayerProfile* pProfile = NULL;
				const char* userId = "UNKNOWN";
				if (userCount == 0)
				{
					if (gEnv->pSystem->IsDevMode())
					{
#ifndef _RELEASE
						//In devmode and not release get the default user if no users are signed in e.g. autotesting, map on the command line
						pProfile = pPPMgr->GetDefaultProfile();
						if (pProfile)
						{
							userId = pProfile->GetUserId();
						}
#endif // #ifndef _RELEASE
					}
					else
					{
						CryFatalError("[PlayerProfiles] CGameContext::StartGame: No users logged in");
						return eCETR_Failed;
					}
				}

				if (userCount > 0)
				{
					IPlayerProfileManager::SUserInfo info;
					pPPMgr->GetUserInfo(0, info);
					pProfile = pPPMgr->GetCurrentProfile(info.userId);
					userId = info.userId;
				}
				if (pProfile)
				{
					pDefaultActionMap = pProfile->GetActionMap("default");
					pDebugActionMap = pProfile->GetActionMap("debug");
					pPlayerActionMap = pProfile->GetActionMap("player");
		
					if (pDefaultActionMap == 0 && pPlayerActionMap == 0)
					{
						CryFatalError("[PlayerProfiles] CGameContext::StartGame: User '%s' has no actionmap 'default'!", userId);
						return eCETR_Failed;
					}
				}
				else
				{
					CryFatalError("[PlayerProfiles] CGameContext::StartGame: User '%s' has no active profile!", userId);
					return eCETR_Failed;
				}
			}
			else
			{
				CryFatalError("[PlayerProfiles] CGameContext::StartGame: No player profile manager!");				
				return eCETR_Failed;
			}
		}

		if (pDefaultActionMap == 0 )
		{
			// use action map without any profile stuff
			pActionMapMan->EnableActionMap( "default", true );
			pDefaultActionMap = pActionMapMan->GetActionMap("default");
			CRY_ASSERT_MESSAGE(pDefaultActionMap, "'default' action map not found!");	
		}

		if (pDebugActionMap == 0 )
		{
			// use action map without any profile stuff
			pActionMapMan->EnableActionMap( "debug", true );
			pDebugActionMap = pActionMapMan->GetActionMap("debug");
		}

		if (pPlayerActionMap == 0)
		{
			pActionMapMan->EnableActionMap( "player", true );
			pPlayerActionMap = pActionMapMan->GetActionMap("player");
		}
		
		if (!pDefaultActionMap)
			return eCETR_Failed;

		EntityId actorId = GetListener();
		if (!actorId)
			return eCETR_Wait;

		if(pDefaultActionMap)
		{
			pDefaultActionMap->SetActionListener( actorId );
		}

		if(pDebugActionMap)
		{
			pDebugActionMap->SetActionListener( actorId );
		}

		if(pPlayerActionMap)
		{
			pPlayerActionMap->SetActionListener( actorId );
		}

		pActionMapMan->EnableActionMap(disableGamemodeActionMapName, false);
		pActionMapMan->EnableActionMap(gamemodeActionMapName, true);
		pPlayerGamemodeActionMap = pActionMapMan->GetActionMap(gamemodeActionMapName);
		
		if(pPlayerGamemodeActionMap)
		{
			pPlayerGamemodeActionMap->SetActionListener(actorId);
		}

		// TODO: callback to game code for game specific action maps
		{
			IActionMap* crysis2_common = pActionMapMan->GetActionMap("crysis2_common");
			if (crysis2_common != NULL)
				crysis2_common->SetActionListener( actorId );

			IActionMap* crysis2_suitmenu_opened = pActionMapMan->GetActionMap("crysis2_suitmenu_opened");
			if (crysis2_suitmenu_opened != NULL)
				crysis2_suitmenu_opened->SetActionListener( actorId );

			IActionMap* crysis2_suitmenu_closed = pActionMapMan->GetActionMap("crysis2_suitmenu_closed");
			if (crysis2_suitmenu_closed != NULL)
				crysis2_suitmenu_closed->SetActionListener( actorId );

			IActionMap* player_cine = pActionMapMan->GetActionMap("player_cine");
			if (player_cine != NULL)
				player_cine->SetActionListener( actorId );

			IActionMap* booss_duell = pActionMapMan->GetActionMap("boss_duell");
			if (booss_duell != NULL)
				booss_duell->SetActionListener( actorId );
		}

		CCryAction::GetCryAction()->GetIActionMapManager()->Enable(true);

		return eCETR_Ok;
	}
コード例 #12
0
ファイル: OptionsManager.cpp プロジェクト: mrwonko/CrysisVR
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();
	
}
コード例 #13
0
void CFlashMenuObject::UpdateSingleplayerDifficulties()
{
	if(!m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART])
		return;

	if(!m_pPlayerProfileManager)
		return;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;

	string sGeneralPath = "Singleplayer.Difficulty";
	int iDifficulties = 8;
/*	for(int i=0; i<EDifficulty_END; ++i)
	{
		string sPath = sGeneralPath;
		char c[5];
		itoa(i, c, 10);
		sPath.append(c);
		sPath.append(".available");

		TFlowInputData data;
		pProfile->GetAttribute(sPath, data, false);
		bool bDone = false;
		data.GetValueWithConversion(bDone);
		if(bDone)
		{
			iDifficulties += i*2;
		}
	}
*/
	int iDifficultiesDone = 0;
	for(int i=0; i<EDifficulty_END; ++i)
	{
		string sPath = sGeneralPath;
		char c[5];
		itoa(i, c, 10);
		sPath.append(c);
		sPath.append(".done");

		TFlowInputData data;
		pProfile->GetAttribute(sPath, data, false);
		bool bDone = false;
		data.GetValueWithConversion(bDone);
		if(bDone)
		{
			iDifficultiesDone += std::max(i*2,1);
		}
	}

	TFlowInputData data;
	pProfile->GetAttribute("Singleplayer.LastSelectedDifficulty", data, false);
	int iDiff = 2;
	data.GetValueWithConversion(iDiff);

	if(iDiff<=0)
	{
		iDiff = 2;
	}

	m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.SinglePlayer.enableDifficulties", iDifficulties);
	m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.SinglePlayer.enableDifficultiesStats", iDifficultiesDone);
	m_apFlashMenuScreens[MENUSCREEN_FRONTENDSTART]->Invoke("Root.MainMenu.SinglePlayer.selectDifficulty", iDiff);
}
コード例 #14
0
void CFlashMenuObject::UpdateSaveGames()
{
	CFlashMenuScreen* pScreen = m_pCurrentFlashMenuScreen;
	if(!pScreen)
		return;

	//*************************************************************************

	std::vector<SaveGameMetaData> saveGameData;
	
	//*************************************************************************

	pScreen->CheckedInvoke("resetSPGames");

	// TODO: find a better place for this as it needs to be set only once -- CW
	gEnv->pSystem->SetFlashLoadMovieHandler(this);

	if(!m_pPlayerProfileManager)
		return;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;
 
	ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
	ISaveGameEnumeratorPtr pSGE = pProfile->CreateSaveGameEnumerator();
	ISaveGameEnumerator::SGameDescription desc;	

	//get the meta data into the struct
	for (int i=0; i<pSGE->GetCount(); ++i)
	{
		pSGE->GetDescription(i, desc);

		int kills = 0;
		float levelPlayTimeSec = 0.0f;
		float gamePlayTimeSec = 0.0f;
		int difficulty = g_pGameCVars->g_difficultyLevel;
		desc.metaData.xmlMetaDataNode->getAttr("sp_kills", kills);
		desc.metaData.xmlMetaDataNode->getAttr("sp_levelPlayTime", levelPlayTimeSec);
		desc.metaData.xmlMetaDataNode->getAttr("sp_gamePlayTime", gamePlayTimeSec);
		desc.metaData.xmlMetaDataNode->getAttr("sp_difficulty", difficulty);

		SaveGameMetaData data;
		data.name = desc.name;
		data.buildVersion = desc.metaData.buildVersion;
		data.description = desc.description;
		data.fileVersion = desc.metaData.fileVersion;
		data.gamePlayTimeSec = gamePlayTimeSec;
		data.gameRules = desc.metaData.gameRules;
		data.humanName = desc.humanName;
		data.levelName = g_pGame->GetMappedLevelName(desc.metaData.levelName);
		data.levelPlayTimeSec = levelPlayTimeSec;
		data.saveTime = desc.metaData.saveTime;
		data.kills = kills;
		data.difficulty = difficulty;
		saveGameData.push_back(data);
	}

	if(saveGameData.size())
	{
		//sort by the set sorting rules
		std::sort(saveGameData.begin(), saveGameData.end(), SaveGameDataCompare(m_eSaveGameCompareMode));

		//send sorted data to flash
		int start = (m_bSaveGameSortUp)?0:saveGameData.size()-1;
		int end = (m_bSaveGameSortUp)?saveGameData.size():-1;
		int inc = (m_bSaveGameSortUp)?1:-1;
		for(int i = start; i != end; i+=inc)
		{
			SaveGameMetaData data = saveGameData[i];

			wstring levelPlayTimeString;
			pLocMgr->LocalizeDuration((int)data.levelPlayTimeSec, levelPlayTimeString);

			wstring gamePlayTimeSecString;
			pLocMgr->LocalizeDuration((int)data.gamePlayTimeSec, gamePlayTimeSecString);

			wstring dateString;
			pLocMgr->LocalizeDate(data.saveTime, true, true, true, dateString);

			wstring timeString;
			pLocMgr->LocalizeTime(data.saveTime, true, false, timeString);

			dateString+=L" ";
			dateString+=timeString;

			bool levelStart = (ValidateName(data.name))?true:false;

			SFlashVarValue args[12] =
			{
				data.name, 
				data.description, 
				data.humanName, 
				data.levelName, 
				data.gameRules, 
				data.fileVersion, 
				data.buildVersion, 
				levelPlayTimeString.c_str(),
				dateString.c_str(),
				levelStart,
				data.kills,
				data.difficulty
			};		
			pScreen->CheckedInvoke("addGameToList", args, sizeof(args) / sizeof(args[0]));
		}
	}

	pScreen->CheckedInvoke("updateGameList");
}