PlayerProfile.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __PLAYERPROFILE_H__
  21. #define __PLAYERPROFILE_H__
  22. #define MAX_PROFILE_SIZE ( 1024 * 1000 ) // High number for the key bindings
  23. /*
  24. ================================================
  25. profileStatValue_t
  26. ================================================
  27. */
  28. union profileStatValue_t {
  29. int i;
  30. float f;
  31. };
  32. /*
  33. ================================================
  34. idPlayerProfile
  35. The general rule for using cvars for settings is that if you want the player's profile settings to affect the startup
  36. of the game before there is a player associated with the game, use cvars. Example: video & volume settings.
  37. ================================================
  38. */
  39. class idPlayerProfile {
  40. friend class idLocalUser;
  41. friend class idProfileMgr;
  42. public:
  43. // Only have room to squeeze ~450 in doom3 right now
  44. static const int MAX_PLAYER_PROFILE_STATS = 200;
  45. enum state_t {
  46. IDLE = 0,
  47. SAVING,
  48. LOADING,
  49. SAVE_REQUESTED,
  50. LOAD_REQUESTED,
  51. ERR
  52. };
  53. protected:
  54. idPlayerProfile(); // don't instantiate. we static_cast the child all over the place
  55. public:
  56. virtual ~idPlayerProfile();
  57. static idPlayerProfile * CreatePlayerProfile( int deviceIndex );
  58. void SetDefaults();
  59. bool Serialize( idSerializer & ser );
  60. const int GetDeviceNumForProfile() const { return deviceNum; }
  61. void SetDeviceNumForProfile( int num ) { deviceNum = num; }
  62. void SaveSettings( bool forceDirty );
  63. void LoadSettings();
  64. state_t GetState() const { return state; }
  65. state_t GetRequestedState() const { return requestedState; }
  66. bool IsDirty() { return dirty; }
  67. bool GetAchievement( const int id ) const;
  68. void SetAchievement( const int id );
  69. void ClearAchievement( const int id );
  70. int GetDlcReleaseVersion() const { return dlcReleaseVersion; }
  71. void SetDlcReleaseVersion( int version ) { dlcReleaseVersion = version; }
  72. int GetLevel() const { return 0; }
  73. //------------------------
  74. // Config
  75. //------------------------
  76. int GetConfig() const { return configSet; }
  77. void SetConfig( int config, bool save );
  78. void RestoreDefault();
  79. void SetLeftyFlip( bool lf );
  80. bool GetLeftyFlip() const { return leftyFlip; }
  81. private:
  82. void StatSetInt( int s, int v );
  83. void StatSetFloat( int s, float v );
  84. int StatGetInt( int s ) const;
  85. float StatGetFloat( int s ) const;
  86. void SetState( state_t value ) { state = value; }
  87. void SetRequestedState( state_t value ) { requestedState = value; }
  88. void MarkDirty( bool isDirty ) { dirty = isDirty; }
  89. void ExecConfig( bool save = false, bool forceDefault = false );
  90. protected:
  91. // Do not save:
  92. state_t state;
  93. state_t requestedState;
  94. int deviceNum;
  95. // Save:
  96. uint64 achievementBits;
  97. uint64 achievementBits2;
  98. int dlcReleaseVersion;
  99. int configSet;
  100. bool customConfig;
  101. bool leftyFlip;
  102. bool dirty; // dirty bit to indicate whether or not we need to save
  103. idStaticList< profileStatValue_t, MAX_PLAYER_PROFILE_STATS > stats;
  104. };
  105. #endif