00001 00025 #ifndef _CPROFILEMANAGER_H_ 00026 #define _CPROFILEMANAGER_H_ 00027 00028 #define FILE_PROFILES "data/profiles/profiles.dat" 00029 00030 #include "main.h" 00031 #include "Profile.h" 00032 #include "Singleton.h" 00033 #include "Collection.h" 00034 00035 class CProfileManager: public CSingleton<CProfileManager> { 00036 00037 public: 00038 00043 struct SPlayerInfo { 00044 00048 string m_name; 00049 00053 int m_id; 00054 00058 int m_level; 00059 00063 int m_score; 00064 00068 SPlayerInfo() : 00069 m_id(0), m_level(0), m_score(0) { 00070 } 00071 ; 00072 00073 }; 00074 00078 CProfileManager(); 00079 00083 virtual ~CProfileManager(); 00084 00088 void loadProfiles(); 00089 00093 void saveProfiles(); 00094 00101 int count() { 00102 return m_players.size(); 00103 } 00104 ; 00105 00111 void resetPlayerGame(); 00112 00117 bool isSetProfile() { 00118 return m_currentProfile >= 0 ? true : false; 00119 } 00120 ; 00121 00125 void init(); 00126 00131 bool setActiveProfile(int id); 00132 00138 int createNewPlayer(string name); 00139 00140 string getActiveProfileName(); 00141 int getActiveProfileLevel(); 00142 int getActiveProfileScore(); 00143 00144 void addActiveProfileScore(int score); 00145 00146 void setActiveProfileLevelUp(); 00147 00148 SPlayerInfo* getPlayerProfile(int index) { 00149 return m_players.get(index); 00150 } 00151 00152 protected: 00153 int m_currentProfile; 00154 CCollection<SPlayerInfo> m_players; 00155 }; 00156 00157 #endif /* PROFILEMANAGER_H_ */