本文整理汇总了C++中IPlayerProfile类的典型用法代码示例。如果您正苦于以下问题:C++ IPlayerProfile类的具体用法?C++ IPlayerProfile怎么用?C++ IPlayerProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IPlayerProfile类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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: SelectProfile
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: GetProfileValue
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: SaveValueToProfile
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: SaveCVarToProfile
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: GetProfileName
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: ProcessEvent
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: if
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: ValidateName
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: GetMappedProfileName
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: OnStep
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");
}
//.........这里部分代码省略.........
示例12: InitProfileOptions
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: UpdateSingleplayerDifficulties
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: UpdateSaveGames
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,
//.........这里部分代码省略.........