Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ProfileManager.h

Go to the documentation of this file.
00001 /* ProfileManager - Interface to profiles that exist on the machine or a memory card. */ 00002 00003 #ifndef ProfileManager_H 00004 #define ProfileManager_H 00005 00006 #include "PlayerNumber.h" 00007 #include "GameConstantsAndTypes.h" 00008 #include "Profile.h" 00009 00010 class Song; 00011 class Style; 00012 00013 class ProfileManager 00014 { 00015 public: 00016 ProfileManager(); 00017 ~ProfileManager(); 00018 00019 void Init(); 00020 00021 bool CreateLocalProfile( CString sName ); 00022 bool RenameLocalProfile( CString sProfileID, CString sNewName ); 00023 bool DeleteLocalProfile( CString sProfileID ); 00024 00025 void GetLocalProfileIDs( vector<CString> &asProfileIDsOut ) const; 00026 void GetLocalProfileNames( vector<CString> &asNamesOut ) const; 00027 00028 bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile 00029 bool LoadLocalProfileFromMachine( PlayerNumber pn ); 00030 bool LoadProfileFromMemoryCard( PlayerNumber pn ); 00031 void SaveAllProfiles() const; 00032 bool SaveProfile( PlayerNumber pn ) const; 00033 void UnloadProfile( PlayerNumber pn ); 00034 00035 // 00036 // General data 00037 // 00038 void IncrementToastiesCount( PlayerNumber pn ); 00039 void AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands ); 00040 00041 00042 // 00043 // High scores 00044 // 00045 void LoadMachineProfile(); 00046 void SaveMachineProfile() const; 00047 00048 bool IsUsingProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); } 00049 bool IsUsingProfile( ProfileSlot slot ) const; 00050 const Profile* GetProfile( PlayerNumber pn ) const; 00051 Profile* GetProfile( PlayerNumber pn ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(pn); } 00052 const Profile* GetProfile( ProfileSlot slot ) const; 00053 Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); } 00054 CString GetProfileDir( ProfileSlot slot ) const; 00055 00056 Profile* GetMachineProfile() { return &m_MachineProfile; } 00057 00058 CString GetPlayerName( PlayerNumber pn ) const; 00059 bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const; 00060 bool LastLoadWasTamperedOrCorrupt( PlayerNumber pn ) const; 00061 bool LastLoadWasFromLastGood( PlayerNumber pn ) const; 00062 00063 00064 // 00065 // Song stats 00066 // 00067 int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const; 00068 bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; } 00069 void AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); 00070 void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn ); 00071 HighScore GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc ) const; 00072 00073 // 00074 // Course stats 00075 // 00076 void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); 00077 void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn ); 00078 00079 // 00080 // Category stats 00081 // 00082 void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); 00083 void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn ); 00084 00085 00086 00087 private: 00088 bool LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard ); 00089 00090 // Directory that contains the profile. Either on local machine or 00091 // on a memory card. 00092 CString m_sProfileDir[NUM_PLAYERS]; 00093 00094 bool m_bWasLoadedFromMemoryCard[NUM_PLAYERS]; 00095 bool m_bLastLoadWasTamperedOrCorrupt[NUM_PLAYERS]; // true if Stats.xml was present, but failed to load (probably because of a signature failure) 00096 bool m_bLastLoadWasFromLastGood[NUM_PLAYERS]; 00097 00098 // actual loaded profile data 00099 Profile m_Profile[NUM_PLAYERS]; 00100 00101 Profile m_MachineProfile; 00102 00103 }; 00104 00105 00106 extern ProfileManager* PROFILEMAN; // global and accessable from anywhere in our program 00107 00108 #endif 00109 00110 /* 00111 * (c) 2003-2004 Chris Danford 00112 * All rights reserved. 00113 * 00114 * Permission is hereby granted, free of charge, to any person obtaining a 00115 * copy of this software and associated documentation files (the 00116 * "Software"), to deal in the Software without restriction, including 00117 * without limitation the rights to use, copy, modify, merge, publish, 00118 * distribute, and/or sell copies of the Software, and to permit persons to 00119 * whom the Software is furnished to do so, provided that the above 00120 * copyright notice(s) and this permission notice appear in all copies of 00121 * the Software and that both the above copyright notice(s) and this 00122 * permission notice appear in supporting documentation. 00123 * 00124 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00125 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00126 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00127 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00128 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00129 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00130 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00131 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00132 * PERFORMANCE OF THIS SOFTWARE. 00133 */

Generated on Thu Jan 27 20:57:27 2005 for StepMania by doxygen 1.3.7