BVB Source Codes

CRYENGINE Show IPlayerProfiles.h Source code

Return Download CRYENGINE: download IPlayerProfiles.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __IPLAYERPROFILES_H__
  4. #define __IPLAYERPROFILES_H__
  5.  
  6. #if _MSC_VER > 1000
  7.         #pragma once
  8. #endif
  9.  
  10. #include <CryLobby/ICryStats.h>
  11. #include <CryFlowGraph/IFlowSystem.h>
  12.  
  13. struct IPlayerProfile;
  14. struct IActionMap;
  15. struct ISaveGame;
  16. struct ILoadGame;
  17.  
  18. struct ISaveGameThumbnail
  19. {
  20.         virtual ~ISaveGameThumbnail(){}
  21.         // a thumbnail is a image in BGR or BGRA format
  22.         // uint8* p; p[0] = B; p[1] = G; p[2] = R; p[3] = A;
  23.  
  24.         virtual const char*  GetSaveGameName() = 0;
  25.         // image access
  26.         virtual void         GetImageInfo(int& width, int& height, int& depth) = 0;
  27.         virtual int          GetWidth() = 0;
  28.         virtual int          GetHeight() = 0;
  29.         virtual int          GetDepth() = 0;
  30.         virtual const uint8* GetImageData() = 0;
  31.  
  32.         // smart ptr
  33.         virtual void AddRef() = 0;
  34.         virtual void Release() = 0;
  35. };
  36. typedef _smart_ptr<ISaveGameThumbnail> ISaveGameThumbailPtr;
  37.  
  38. #define SAVEGAME_LEVEL_NAME_UNDEFINED "<undefined>"
  39.  
  40. struct ISaveGameEnumerator
  41. {
  42.         virtual ~ISaveGameEnumerator(){}
  43.         struct SGameMetaData
  44.         {
  45.                 const char* levelName;
  46.                 const char* gameRules;
  47.                 int         fileVersion;
  48.                 const char* buildVersion;
  49.                 time_t      saveTime;
  50.                 time_t      loadTime;
  51.                 XmlNodeRef  xmlMetaDataNode;
  52.         };
  53.  
  54.         struct SGameDescription
  55.         {
  56.                 const char*   name;
  57.                 const char*   humanName;
  58.                 const char*   description;
  59.                 SGameMetaData metaData;
  60.         };
  61.  
  62.         virtual int  GetCount() = 0;
  63.         virtual bool GetDescription(int index, SGameDescription& desc) = 0;
  64.  
  65.         // Get thumbnail (by index or save game name)
  66.         virtual ISaveGameThumbailPtr GetThumbnail(int index) = 0;
  67.         virtual ISaveGameThumbailPtr GetThumbnail(const char* saveGameName) = 0;
  68.  
  69.         // smart ptr
  70.         virtual void AddRef() = 0;
  71.         virtual void Release() = 0;
  72. };
  73. typedef _smart_ptr<ISaveGameEnumerator> ISaveGameEnumeratorPtr;
  74.  
  75. struct IAttributeEnumerator
  76. {
  77.         virtual ~IAttributeEnumerator(){}
  78.         struct SAttributeDescription
  79.         {
  80.                 const char* name;
  81.         };
  82.  
  83.         virtual bool Next(SAttributeDescription& desc) = 0;
  84.  
  85.         // smart ptr
  86.         virtual void AddRef() = 0;
  87.         virtual void Release() = 0;
  88. };
  89. typedef _smart_ptr<IAttributeEnumerator> IAttributeEnumeratorPtr;
  90.  
  91. enum EProfileReasons // bitfield
  92. {
  93.         ePR_Game    = 0x01,       // saving/loading a game/checkpoint
  94.         ePR_Options = 0x02,       // saving/loading profile options only
  95.         ePR_All     = 0xff        // all flags
  96. };
  97.  
  98. class IPlayerProfileListener
  99. {
  100. public:
  101.         virtual ~IPlayerProfileListener(){}
  102.         virtual void SaveToProfile(IPlayerProfile* pProfile, bool online, unsigned int /*EProfileReasons*/ reason) = 0;
  103.         virtual void LoadFromProfile(IPlayerProfile* pProfile, bool online, unsigned int /*EProfileReasons*/ reason) = 0;
  104. };
  105.  
  106. struct IResolveAttributeBlockListener
  107. {
  108.         virtual ~IResolveAttributeBlockListener() {}
  109.         virtual void OnPostResolve() = 0;
  110.         virtual void OnFailure() = 0;
  111. };
  112.  
  113. class IOnlineAttributesListener
  114. {
  115. public:
  116.         enum EEvent
  117.         {
  118.                 eOAE_Invalid  = -1,
  119.                 eOAE_Register = 0,
  120.                 eOAE_Load,
  121.                 eOAE_Max,
  122.         };
  123.  
  124.         enum EState
  125.         {
  126.                 eOAS_None,
  127.                 eOAS_Processing,
  128.                 eOAS_Failed,
  129.                 eOAS_Success,
  130.         };
  131.         virtual ~IOnlineAttributesListener(){}
  132.         virtual void OnlineAttributeState(EEvent event, EState newState) = 0;
  133. };
  134.  
  135. #define INVALID_CONTROLLER_INDEX 0xFFFFFFFF
  136.  
  137. struct IPlayerProfileManager
  138. {
  139.         struct SProfileDescription
  140.         {
  141.                 const char* name;
  142.                 time_t      lastLoginTime;
  143.                 SProfileDescription()
  144.                         : name(nullptr)
  145.                         , lastLoginTime(0)
  146.                 {
  147.                 }
  148.         };
  149.  
  150.         struct SUserInfo
  151.         {
  152.                 const char* userId;
  153.         };
  154.         virtual ~IPlayerProfileManager(){}
  155.         virtual bool Initialize() = 0;
  156.         virtual bool Shutdown() = 0;
  157.  
  158.         virtual void GetMemoryStatistics(ICrySizer*) = 0;
  159.  
  160.         // win32:    currently logged on user
  161.  
  162.         // login the user
  163.         virtual int  GetUserCount() = 0;
  164.         virtual bool GetUserInfo(int index, IPlayerProfileManager::SUserInfo& outInfo) = 0;
  165.         virtual bool LoginUser(const char* userId, bool& bOutFirstTime) = 0;
  166.         virtual bool LogoutUser(const char* userId) = 0;
  167.  
  168.         virtual int  GetProfileCount(const char* userId) = 0;
  169.         virtual bool GetProfileInfo(const char* userId, int index, IPlayerProfileManager::SProfileDescription& outInfo) = 0;
  170.         virtual void SetProfileLastLoginTime(const char* userId, int index, time_t lastLoginTime) = 0;
  171.  
  172.         enum EProfileOperationResult
  173.         {
  174.                 ePOR_Success         = 0,
  175.                 ePOR_NotInitialized  = 1,
  176.                 ePOR_NameInUse       = 2,
  177.                 ePOR_UserNotLoggedIn = 3,
  178.                 ePOR_NoSuchProfile   = 4,
  179.                 ePOR_ProfileInUse    = 5,
  180.                 ePOR_NoActiveProfile = 6,
  181.                 ePOR_DefaultProfile  = 7,
  182.                 ePOR_LoadingProfile  = 8,
  183.                 ePOR_Unknown         = 255,
  184.         };
  185.  
  186.         // create a new profile for a user
  187.         virtual bool CreateProfile(const char* userId, const char* profileName, bool bOverrideIfPresent, EProfileOperationResult& result) = 0;
  188.  
  189.         // delete a profile of an user
  190.         virtual bool DeleteProfile(const char* userId, const char* profileName, EProfileOperationResult& result) = 0;
  191.  
  192.         // rename the current profile of the user
  193.         virtual bool RenameProfile(const char* userId, const char* newName, EProfileOperationResult& result) = 0;
  194.  
  195.         // save a profile
  196.         virtual bool SaveProfile(const char* userId, EProfileOperationResult& result, unsigned int reason) = 0;
  197.  
  198.         // save an inactive profile
  199.         virtual bool SaveInactiveProfile(const char* userId, const char* profileName, EProfileOperationResult& result, unsigned int reason) = 0;
  200.  
  201.         // is profile being loaded?
  202.         virtual bool IsLoadingProfile() const = 0;
  203.  
  204.         // is profile being saved?
  205.         virtual bool IsSavingProfile() const = 0;
  206.  
  207.         // load and activate a profile, returns the IPlayerProfile if successful
  208.         virtual IPlayerProfile* ActivateProfile(const char* userId, const char* profileName) = 0;
  209.  
  210.         // get the current profile of the user
  211.         virtual IPlayerProfile* GetCurrentProfile(const char* userId) = 0;
  212.  
  213.         // get the current user
  214.         virtual const char* GetCurrentUser() = 0;
  215.  
  216.         // get the current user index
  217.         virtual int GetCurrentUserIndex() = 0;
  218.  
  219.         // set the controller index
  220.         virtual void SetExclusiveControllerDeviceIndex(unsigned int exclusiveDeviceIndex) = 0;
  221.  
  222.         // get the controller index
  223.         virtual unsigned int GetExclusiveControllerDeviceIndex() const = 0;
  224.  
  225.         // reset the current profile
  226.         // reset actionmaps and attributes, don't delete save games!
  227.         virtual bool ResetProfile(const char* userId) = 0;
  228.  
  229.         // reload profile by calling each IPlayerProfileListener::LoadFromProfile
  230.         virtual void ReloadProfile(IPlayerProfile* pProfile, unsigned int reason) = 0;
  231.  
  232.         // get the (always present) default profile (factory default)
  233.         virtual IPlayerProfile* GetDefaultProfile() = 0;
  234.  
  235.         // load a profile for previewing only. there is exactly one preview profile for a user
  236.         // subsequent calls will invalidate former profiles. profileName can be "" or NULL which will
  237.         // delete the preview profile from memory
  238.         virtual const IPlayerProfile* PreviewProfile(const char* userId, const char* profileName) = 0;
  239.  
  240.         // Set a shared savegame folder for all profiles
  241.         // this means all savegames get prefixed with the profilename and '_'
  242.         // by default: SaveGame folder is shared "%USER%/SaveGames/"
  243.         virtual void SetSharedSaveGameFolder(const char* sharedSaveGameFolder) = 0;
  244.  
  245.         // Get the shared savegame folder
  246.         virtual const char* GetSharedSaveGameFolder() = 0;
  247.  
  248.         // Register a listener to receive calls for online profile events
  249.         virtual void AddListener(IPlayerProfileListener* pListener, bool updateNow) = 0;
  250.  
  251.         // Stop a listener from recieving events once registered
  252.         virtual void RemoveListener(IPlayerProfileListener* pListener) = 0;
  253.  
  254.         // Register a listener to receive calls for online profile events
  255.         virtual void AddOnlineAttributesListener(IOnlineAttributesListener* pListener) = 0;
  256.  
  257.         // Stop a listener from recieving events once registered
  258.         virtual void RemoveOnlineAttributesListener(IOnlineAttributesListener* pListener) = 0;
  259.  
  260.         //enable online attribute registation/loading/saving
  261.         virtual void EnableOnlineAttributes(bool enable) = 0;
  262.  
  263.         // if saving and loading online has been enabled
  264.         virtual bool HasEnabledOnlineAttributes() const = 0;
  265.  
  266.         // if saving and loading online is allowed
  267.         virtual bool CanProcessOnlineAttributes() const = 0;
  268.  
  269.         //enable online attribute processing - disables saving and loading whilst not in a valid state e.g. in a mp game session that's in progress
  270.         virtual void SetCanProcessOnlineAttributes(bool enable) = 0;
  271.  
  272.         //register online attributes (needs to be done after online services are enabled)
  273.         virtual bool RegisterOnlineAttributes() = 0;
  274.  
  275.         //Get the current state of the online attributes
  276.         virtual void GetOnlineAttributesState(const IOnlineAttributesListener::EEvent event, IOnlineAttributesListener::EState& state) const = 0;
  277.  
  278.         // load profile's online attributes
  279.         virtual void LoadOnlineAttributes(IPlayerProfile* pProfile) = 0;
  280.  
  281.         // save profile's online attributes
  282.         virtual void SaveOnlineAttributes(IPlayerProfile* pProfile) = 0;
  283.  
  284.         // set the online attributes from an outside source
  285.         virtual void SetOnlineAttributes(IPlayerProfile* pProfile, const SCryLobbyUserData* pData, const int32 onlineDataCount) = 0;
  286.  
  287.         // retrieve the current online attributes, returns the number of attributes copied
  288.         // numData is number of elements available to be filled in
  289.         virtual uint32 GetOnlineAttributes(SCryLobbyUserData* pData, uint32 numData) = 0;
  290.  
  291.         // retrieve the default online attributes, returns the number of attributes copied
  292.         // numData is number of elements available to be filled in
  293.         virtual uint32 GetDefaultOnlineAttributes(SCryLobbyUserData* pData, uint32 numData) = 0;
  294.  
  295.         // get the version number of the online attributes
  296.         virtual int GetOnlineAttributesVersion() const = 0;
  297.  
  298.         // get the index of an online attribute via it's name
  299.         virtual int GetOnlineAttributeIndexByName(const char* name) = 0;
  300.  
  301.         // fills the passed in array with the format of the online attributes
  302.         virtual void GetOnlineAttributesDataFormat(SCryLobbyUserData* pData, uint32 numData) = 0;
  303.  
  304.         // return the number of online attributes
  305.         virtual uint32 GetOnlineAttributeCount() = 0;
  306.  
  307.         // clear the state of the online attributes
  308.         virtual void ClearOnlineAttributes() = 0;
  309.  
  310.         // apply checksums to online data
  311.         virtual void ApplyChecksums(SCryLobbyUserData* pData, uint32 numData) = 0;
  312.  
  313.         // check checksums are valid
  314.         virtual bool ValidChecksums(const SCryLobbyUserData* pData, uint32 numData) = 0;
  315.  
  316.         // read attributes from external location and resolve it against current attributes
  317.         virtual bool ResolveAttributeBlock(const char* userId, const char* attrBlockName, IResolveAttributeBlockListener* pListener, int reason) = 0;
  318.  
  319.         struct SResolveAttributeRequest
  320.         {
  321.                 enum EResolveAttributeBlockConstants
  322.                 {
  323.                         eRABC_MaxResolveCountPerRequest = 6
  324.                 };
  325.  
  326.                 const char* attrBlockNames[eRABC_MaxResolveCountPerRequest + 1];    // Null terminated list.
  327.                 const char* containerName;
  328.                 const char* attrPathPrefix;
  329.                 SResolveAttributeRequest() : containerName(NULL), attrPathPrefix(NULL) { attrBlockNames[eRABC_MaxResolveCountPerRequest] = NULL; }
  330.         };
  331.  
  332.         // read attributes from external location and resolve it against current attributes
  333.         virtual bool ResolveAttributeBlock(const char* userId, const SResolveAttributeRequest& attrBlockNameRequest, IResolveAttributeBlockListener* pListener, int reason) = 0;
  334.  
  335.         // write attributes to external location
  336.         //virtual bool WriteAttributeBlock(const char* userId, const char* attrBlockName, int reason) = 0;
  337. };
  338.  
  339. struct ILevelRotationFile
  340. {
  341.         virtual ~ILevelRotationFile(){}
  342.         virtual bool       Save(XmlNodeRef r) = 0;
  343.         virtual XmlNodeRef Load() = 0;
  344.         virtual void       Complete() = 0;
  345. };
  346.  
  347. struct IPlayerProfile
  348. {
  349.         virtual ~IPlayerProfile(){}
  350.         // reset the profile
  351.         virtual bool Reset() = 0;
  352.  
  353.         // is this the default profile? it cannot be modified
  354.         virtual bool IsDefault() const = 0;
  355.  
  356.         // override values with console player profile defaults
  357.         virtual void LoadGamerProfileDefaults() = 0;
  358.  
  359.         // name of the profile
  360.         virtual const char* GetName() = 0;
  361.  
  362.         // Id of the profile user
  363.         virtual const char* GetUserId() = 0;
  364.  
  365.         // retrieve an action map
  366.         virtual IActionMap* GetActionMap(const char* name) = 0;
  367.  
  368.         // set the value of an attribute
  369.         virtual bool SetAttribute(const char* name, const TFlowInputData& value) = 0;
  370.  
  371.         // re-set attribute to default value (basically removes it from this profile)
  372.         virtual bool ResetAttribute(const char* name) = 0;
  373.  
  374.         //delete an attribute from attribute map (regardless if has a default)
  375.         virtual void DeleteAttribute(const char* name) = 0;
  376.  
  377.         // get the value of an attribute. if not specified optionally lookup in default profile
  378.         virtual bool              GetAttribute(const char* name, TFlowInputData& val, bool bUseDefaultFallback = true) const = 0;
  379.  
  380.         template<typename T> bool GetAttribute(const char* name, T& outVal, bool bUseDefaultFallback = true) const
  381.         {
  382.                 TFlowInputData val;
  383.                 if (GetAttribute(name, val, bUseDefaultFallback) == false)
  384.                         return false;
  385.                 return val.GetValueWithConversion(outVal);
  386.         }
  387.  
  388.         template<typename T> bool SetAttribute(const char* name, const T& val)
  389.         {
  390.                 TFlowInputData data(val);
  391.                 return SetAttribute(name, data);
  392.         }
  393.  
  394.         // get name all attributes available
  395.         // all in this profile and inherited from default profile
  396.         virtual IAttributeEnumeratorPtr CreateAttributeEnumerator() = 0;
  397.  
  398.         // save game stuff
  399.         virtual ISaveGameEnumeratorPtr CreateSaveGameEnumerator() = 0;
  400.         virtual ISaveGame*             CreateSaveGame() = 0;
  401.         virtual ILoadGame*             CreateLoadGame() = 0;
  402.         virtual bool                   DeleteSaveGame(const char* name) = 0;
  403.  
  404.         virtual ILevelRotationFile*    GetLevelRotationFile(const char* name) = 0;
  405. };
  406.  
  407. #endif
  408.  
downloadIPlayerProfiles.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