BVB Source Codes

CRYENGINE Show PlayerProfileImplNoSave.h Source code

Return Download CRYENGINE: download PlayerProfileImplNoSave.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   PlayerProfileImplConsole.cpp
  5. //  Created:     21/12/2009 by Alex Weighell.
  6. //  Description: Player profile implementation for console demo releases.
  7. //               Doesn't save player profile data!
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12.  
  13. #ifndef __PLAYERPROFILENOSAVE_H__
  14. #define __PLAYERPROFILENOSAVE_H__
  15.  
  16. #if _MSC_VER > 1000
  17.         #pragma once
  18. #endif
  19.  
  20. #include "PlayerProfileImplConsole.h"
  21. #include "PlayerProfile.h"
  22. #include <CryCore/Platform/IPlatformOS.h>
  23.  
  24. class CPlayerProfileImplNoSave : public CPlayerProfileImplConsole
  25. {
  26. public:
  27.         // CPlayerProfileManager::IPlatformImpl
  28.         virtual bool LoginUser(SUserEntry* pEntry);
  29.         virtual bool SaveProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name);
  30.         virtual bool LoadProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name);
  31.         virtual bool DeleteProfile(SUserEntry* pEntry, const char* name);
  32.         virtual bool DeleteSaveGame(SUserEntry* pEntry, const char* name);
  33.         // ~CPlayerProfileManager::IPlatformImpl
  34.  
  35.         // ICommonProfileImpl
  36.         // ~ICommonProfileImpl
  37.  
  38. protected:
  39.         virtual ~CPlayerProfileImplNoSave() {}
  40.  
  41. private:
  42.         CPlayerProfileManager* m_pMgr;
  43. };
  44.  
  45. //------------------------------------------------------------------------
  46. bool CPlayerProfileImplNoSave::SaveProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name)
  47. {
  48.         // This would cause a delete from disk - but we have READ ONLY media in this case
  49.         if (m_pMgr->HasEnabledOnlineAttributes() && m_pMgr->CanProcessOnlineAttributes() && !pProfile->IsDefault())
  50.         {
  51.                 m_pMgr->SaveOnlineAttributes(pProfile);
  52.         }
  53.         return true;
  54. }
  55.  
  56. //------------------------------------------------------------------------
  57. bool CPlayerProfileImplNoSave::LoadProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name)
  58. {
  59.         // load the profile from a specific location. Only load the default profile since there is no saving!
  60.         using namespace PlayerProfileImpl;
  61.  
  62.         if (0 == strcmp(name, "default"))
  63.         {
  64.                 // XML for now
  65.                 string path;
  66.                 InternalMakeFSPath(pEntry, name, path);
  67.  
  68.                 XmlNodeRef rootNode = GetISystem()->CreateXmlNode(PROFILE_ROOT_TAG);
  69.                 CSerializerXML serializer(rootNode, true);
  70.                 XmlNodeRef attrNode = LoadXMLFile(path + "attributes.xml");
  71.                 XmlNodeRef actionNode = LoadXMLFile(path + "actionmaps.xml");
  72.                 //      serializer.AddSection(attrNode);
  73.                 //      serializer.AddSection(actionNode);
  74.                 serializer.SetSection(CPlayerProfileManager::ePPS_Attribute, attrNode);
  75.                 serializer.SetSection(CPlayerProfileManager::ePPS_Actionmap, actionNode);
  76.  
  77.                 bool ok = pProfile->SerializeXML(&serializer);
  78.                 return ok;
  79.         }
  80.         return true;
  81. }
  82.  
  83. //------------------------------------------------------------------------
  84. bool CPlayerProfileImplNoSave::LoginUser(SUserEntry* pEntry)
  85. {
  86.         // lookup stored profiles of the user (pEntry->userId) and fill in the pEntry->profileDesc
  87.         // vector
  88.         pEntry->profileDesc.clear();
  89.  
  90.         IPlatformOS* os = gEnv->pSystem->GetPlatformOS();
  91.  
  92.         bool signedIn = os->UserIsSignedIn(pEntry->userIndex);
  93.         CryLogAlways("LoginUser::UserIsSignedIn %d\n", signedIn);
  94.  
  95.         if (!signedIn)
  96.         {
  97. #if !defined(_RELEASE)
  98.                 if (!CCryActionCVars::Get().g_userNeverAutoSignsIn)
  99. #endif
  100.                 {
  101.                         signedIn = os->UserDoSignIn(1, g_pGame->GetExclusiveControllerDeviceIndex()); // disable this on a cvar to remove the signin box during autotests
  102.                         CryLogAlways("LoginUser::UserDoSignIn %d\n", signedIn);
  103.                 }
  104.         }
  105.         if (signedIn)
  106.         {
  107.                 IPlatformOS::TUserName profileName;
  108.  
  109.                 if (os->UserGetName(pEntry->userIndex, profileName))
  110.                 {
  111.                         pEntry->profileDesc.push_back(SLocalProfileInfo(profileName.c_str()));
  112.                 }
  113.                 else
  114.                 {
  115.                         printf("OS FAILED to get signed in User name\n");
  116.                 }
  117.         }
  118.         else
  119.         {
  120.                 printf("OS No User signed in\n");
  121.         }
  122.  
  123.         return signedIn;
  124. }
  125.  
  126. //------------------------------------------------------------------------
  127. bool CPlayerProfileImplNoSave::DeleteProfile(SUserEntry* pEntry, const char* name)
  128. {
  129.         // This would cause a delete from disk - but we have READ ONLY media in this case
  130.         return true;
  131. }
  132.  
  133. //------------------------------------------------------------------------
  134. bool CPlayerProfileImplNoSave::DeleteSaveGame(SUserEntry* pEntry, const char* name)
  135. {
  136.         // This would cause a delete from disk - but we have READ ONLY media in this case
  137.         return true;
  138. }
  139.  
  140. #endif
  141.  
downloadPlayerProfileImplNoSave.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top