BVB Source Codes

CRYENGINE Show PlayerProfileImplFS.h Source code

Return Download CRYENGINE: download PlayerProfileImplFS.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __PLAYERPROFILEIMPLFS_H__
  4. #define __PLAYERPROFILEIMPLFS_H__
  5.  
  6. #if _MSC_VER > 1000
  7.         #pragma once
  8. #endif
  9.  
  10. #include "PlayerProfileManager.h"
  11.  
  12. struct ICommonProfileImpl
  13. {
  14.         virtual ~ICommonProfileImpl(){}
  15.         virtual void                   InternalMakeFSPath(CPlayerProfileManager::SUserEntry* pEntry, const char* profileName, string& outPath) = 0;
  16.         virtual void                   InternalMakeFSSaveGamePath(CPlayerProfileManager::SUserEntry* pEntry, const char* profileName, string& outPath, bool bNeedFolder) = 0;
  17.         virtual CPlayerProfileManager* GetManager() = 0;
  18. };
  19.  
  20. #if 0
  21. template<class T>
  22. class CCommonSaveGameHelper
  23. {
  24. public:
  25.         CCommonSaveGameHelper(T* pImpl) : m_pImpl(pImpl) {}
  26.         bool       GetSaveGames(CPlayerProfileManager::SUserEntry* pEntry, CPlayerProfileManager::TSaveGameInfoVec& outVec, const char* altProfileName);
  27.         ISaveGame* CreateSaveGame(CPlayerProfileManager::SUserEntry* pEntry);
  28.         ILoadGame* CreateLoadGame(CPlayerProfileManager::SUserEntry* pEntry);
  29.  
  30. protected:
  31.         bool FetchMetaData(XmlNodeRef& root, CPlayerProfileManager::SSaveGameMetaData& metaData);
  32.         T* m_pImpl;
  33. };
  34. #endif
  35.  
  36. class CPlayerProfileImplFS : public CPlayerProfileManager::IPlatformImpl, public ICommonProfileImpl
  37. {
  38. public:
  39.         CPlayerProfileImplFS();
  40.  
  41.         // CPlayerProfileManager::IPlatformImpl
  42.         virtual bool       Initialize(CPlayerProfileManager* pMgr);
  43.         virtual void       Release() { delete this; }
  44.         virtual bool       LoginUser(SUserEntry* pEntry);
  45.         virtual bool       LogoutUser(SUserEntry* pEntry);
  46.         virtual bool       SaveProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name, bool initialSave = false, int /*reason*/ = ePR_All);
  47.         virtual bool       LoadProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name);
  48.         virtual bool       DeleteProfile(SUserEntry* pEntry, const char* name);
  49.         virtual bool       RenameProfile(SUserEntry* pEntry, const char* newName);
  50.         virtual bool       GetSaveGames(SUserEntry* pEntry, CPlayerProfileManager::TSaveGameInfoVec& outVec, const char* altProfileName);
  51.         virtual ISaveGame* CreateSaveGame(SUserEntry* pEntry);
  52.         virtual ILoadGame* CreateLoadGame(SUserEntry* pEntry);
  53.         virtual bool       DeleteSaveGame(SUserEntry* pEntry, const char* name);
  54.         virtual bool       GetSaveGameThumbnail(SUserEntry* pEntry, const char* saveGameName, SThumbnail& thumbnail);
  55.         // ~CPlayerProfileManager::IPlatformImpl
  56.  
  57.         // ICommonProfileImpl
  58.         void                           InternalMakeFSPath(SUserEntry* pEntry, const char* profileName, string& outPath);
  59.         void                           InternalMakeFSSaveGamePath(SUserEntry* pEntry, const char* profileName, string& outPath, bool bNeedFolder);
  60.         virtual CPlayerProfileManager* GetManager() { return m_pMgr; }
  61.         // ~ICommonProfileImpl
  62.  
  63. protected:
  64.         virtual ~CPlayerProfileImplFS();
  65.  
  66. private:
  67.         CPlayerProfileManager* m_pMgr;
  68. };
  69.  
  70. class CPlayerProfileImplFSDir : public CPlayerProfileManager::IPlatformImpl, public ICommonProfileImpl
  71. {
  72. public:
  73.         CPlayerProfileImplFSDir();
  74.  
  75.         // CPlayerProfileManager::IPlatformImpl
  76.         virtual bool                Initialize(CPlayerProfileManager* pMgr);
  77.         virtual void                Release() { delete this; }
  78.         virtual bool                LoginUser(SUserEntry* pEntry);
  79.         virtual bool                LogoutUser(SUserEntry* pEntry);
  80.         virtual bool                SaveProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name, bool initialSave = false, int /*reason*/ = ePR_All);
  81.         virtual bool                LoadProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name);
  82.         virtual bool                DeleteProfile(SUserEntry* pEntry, const char* name);
  83.         virtual bool                RenameProfile(SUserEntry* pEntry, const char* newName);
  84.         virtual bool                GetSaveGames(SUserEntry* pEntry, CPlayerProfileManager::TSaveGameInfoVec& outVec, const char* altProfileName);
  85.         virtual ISaveGame*          CreateSaveGame(SUserEntry* pEntry);
  86.         virtual ILoadGame*          CreateLoadGame(SUserEntry* pEntry);
  87.         virtual bool                DeleteSaveGame(SUserEntry* pEntry, const char* name);
  88.         virtual ILevelRotationFile* GetLevelRotationFile(SUserEntry* pEntry, const char* name);
  89.         virtual bool                GetSaveGameThumbnail(SUserEntry* pEntry, const char* saveGameName, SThumbnail& thumbnail);
  90.         virtual void                GetMemoryStatistics(ICrySizer* s);
  91.         // ~CPlayerProfileManager::IPlatformImpl
  92.  
  93.         // ICommonProfileImpl
  94.         virtual void                   InternalMakeFSPath(SUserEntry* pEntry, const char* profileName, string& outPath);
  95.         virtual void                   InternalMakeFSSaveGamePath(SUserEntry* pEntry, const char* profileName, string& outPath, bool bNeedFolder);
  96.         virtual CPlayerProfileManager* GetManager() { return m_pMgr; }
  97.         // ~ICommonProfileImpl
  98.  
  99. protected:
  100.         virtual ~CPlayerProfileImplFSDir();
  101.  
  102. private:
  103.         CPlayerProfileManager* m_pMgr;
  104. };
  105.  
  106. class CCommonSaveGameHelper
  107. {
  108. public:
  109.         CCommonSaveGameHelper(ICommonProfileImpl* pImpl) : m_pImpl(pImpl) {}
  110.         bool                GetSaveGames(CPlayerProfileManager::SUserEntry* pEntry, CPlayerProfileManager::TSaveGameInfoVec& outVec, const char* altProfileName);
  111.         ISaveGame*          CreateSaveGame(CPlayerProfileManager::SUserEntry* pEntry);
  112.         ILoadGame*          CreateLoadGame(CPlayerProfileManager::SUserEntry* pEntry);
  113.         bool                DeleteSaveGame(CPlayerProfileManager::SUserEntry* pEntry, const char* name);
  114.         bool                GetSaveGameThumbnail(CPlayerProfileManager::SUserEntry* pEntry, const char* saveGameName, CPlayerProfileManager::SThumbnail& thumbnail);
  115.         bool                MoveSaveGames(CPlayerProfileManager::SUserEntry* pEntry, const char* oldProfileName, const char* newProfileName);
  116.         ILevelRotationFile* GetLevelRotationFile(CPlayerProfileManager::SUserEntry* pEntry, const char* name);
  117.  
  118. protected:
  119.         bool FetchMetaData(XmlNodeRef& root, CPlayerProfileManager::SSaveGameMetaData& metaData);
  120.         ICommonProfileImpl* m_pImpl;
  121. };
  122.  
  123. namespace PlayerProfileImpl
  124. {
  125. extern const char* PROFILE_ROOT_TAG;
  126. extern const char* PROFILE_NAME_TAG;
  127. extern const char* PROFILE_LAST_PLAYED;
  128.  
  129. // a simple serializer. manages sections (XmlNodes)
  130. // is used during load and save
  131. // CSerializerXML no longer supports sections being within the root node. In future it could be modified to but for now because of BinaryXML loading on consoles the ProfileImplFSDir is preferred.
  132. class CSerializerXML : public CPlayerProfileManager::IProfileXMLSerializer
  133. {
  134. public:
  135.         CSerializerXML(XmlNodeRef& root, bool bLoading);
  136.  
  137.         // CPlayerProfileManager::ISerializer
  138.         inline bool IsLoading() { return m_bLoading; }
  139.  
  140.         XmlNodeRef  CreateNewSection(CPlayerProfileManager::EPlayerProfileSection section, const char* name);
  141.         void        SetSection(CPlayerProfileManager::EPlayerProfileSection section, XmlNodeRef& node);
  142.         XmlNodeRef  GetSection(CPlayerProfileManager::EPlayerProfileSection section);
  143.  
  144. protected:
  145.         bool       m_bLoading;
  146.         XmlNodeRef m_root;
  147.         XmlNodeRef m_sections[CPlayerProfileManager::ePPS_Num];
  148. };
  149.  
  150. // some helpers
  151. bool       SaveXMLFile(const string& filename, const XmlNodeRef& rootNode);
  152. XmlNodeRef LoadXMLFile(const string& filename);
  153. bool       IsValidFilename(const char* filename);
  154.  
  155. } // namespace PlayerProfileImpl
  156.  
  157. #endif
  158.  
downloadPlayerProfileImplFS.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