2005-02-13 03:40:37 +00:00
|
|
|
/* ProfileManager - Interface to machine and memory card profiles. */
|
2004-06-08 01:24:17 +00:00
|
|
|
|
2003-09-08 03:26:58 +00:00
|
|
|
#ifndef ProfileManager_H
|
|
|
|
|
#define ProfileManager_H
|
|
|
|
|
|
|
|
|
|
#include "PlayerNumber.h"
|
2003-12-07 07:09:13 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2005-07-01 04:46:32 +00:00
|
|
|
#include "Difficulty.h"
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2005-07-01 04:46:32 +00:00
|
|
|
class Profile;
|
2004-02-09 06:26:13 +00:00
|
|
|
class Song;
|
2005-07-01 04:46:32 +00:00
|
|
|
class Steps;
|
2004-06-28 07:26:00 +00:00
|
|
|
class Style;
|
2005-07-01 04:46:32 +00:00
|
|
|
class Course;
|
|
|
|
|
class Trail;
|
2005-07-01 05:06:00 +00:00
|
|
|
struct HighScore;
|
2005-02-13 01:16:17 +00:00
|
|
|
struct lua_State;
|
2004-02-09 06:26:13 +00:00
|
|
|
|
2005-07-14 08:45:21 +00:00
|
|
|
const int MAX_NUM_LOCAL_PROFILES = 8;
|
2005-07-13 20:27:05 +00:00
|
|
|
|
2003-09-08 03:26:58 +00:00
|
|
|
class ProfileManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ProfileManager();
|
|
|
|
|
~ProfileManager();
|
|
|
|
|
|
2004-05-25 05:52:57 +00:00
|
|
|
void Init();
|
|
|
|
|
|
2005-07-12 20:19:52 +00:00
|
|
|
// local profiles
|
2005-07-13 19:15:31 +00:00
|
|
|
void RefreshLocalProfilesFromDisk();
|
|
|
|
|
Profile &GetLocalProfile( const CString &sProfileID );
|
2005-07-12 20:19:52 +00:00
|
|
|
|
2005-07-16 05:28:34 +00:00
|
|
|
bool CreateLocalProfile( CString sName, CString &sProfileIDOut );
|
2003-12-07 08:19:10 +00:00
|
|
|
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
|
|
|
|
bool DeleteLocalProfile( CString sProfileID );
|
2005-07-12 20:19:52 +00:00
|
|
|
void GetLocalProfileIDs( vector<CString> &vsProfileIDsOut ) const;
|
|
|
|
|
void GetLocalProfileDisplayNames( vector<CString> &vsProfileDisplayNamesOut ) const;
|
2003-09-08 07:21:41 +00:00
|
|
|
|
|
|
|
|
|
2004-08-09 05:01:24 +00:00
|
|
|
bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
|
|
|
|
|
bool LoadLocalProfileFromMachine( PlayerNumber pn );
|
|
|
|
|
bool LoadProfileFromMemoryCard( PlayerNumber pn );
|
2005-04-24 23:06:15 +00:00
|
|
|
bool FastLoadProfileNameFromMemoryCard( CString sRootDir, CString &sName ) const;
|
2004-07-20 01:31:23 +00:00
|
|
|
void SaveAllProfiles() const;
|
2004-02-22 02:01:40 +00:00
|
|
|
bool SaveProfile( PlayerNumber pn ) const;
|
2005-08-05 04:20:46 +00:00
|
|
|
bool SaveLocalProfile( CString sProfileID );
|
2003-09-08 03:26:58 +00:00
|
|
|
void UnloadProfile( PlayerNumber pn );
|
2004-02-22 08:16:49 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// General data
|
|
|
|
|
//
|
|
|
|
|
void IncrementToastiesCount( PlayerNumber pn );
|
2005-04-25 11:42:19 +00:00
|
|
|
void AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumRolls, int iNumMines, int iNumHands, float fCaloriesBurned );
|
2004-02-22 08:16:49 +00:00
|
|
|
|
2003-09-08 03:26:58 +00:00
|
|
|
|
2004-02-16 05:35:06 +00:00
|
|
|
//
|
|
|
|
|
// High scores
|
|
|
|
|
//
|
|
|
|
|
void LoadMachineProfile();
|
2004-07-20 01:31:23 +00:00
|
|
|
void SaveMachineProfile() const;
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2005-05-09 08:44:01 +00:00
|
|
|
bool IsPersistentProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); }
|
|
|
|
|
bool IsPersistentProfile( ProfileSlot slot ) const;
|
2005-05-01 06:42:30 +00:00
|
|
|
|
|
|
|
|
// return a profile even if !IsUsingProfile
|
|
|
|
|
const Profile* GetProfile( PlayerNumber pn ) const;
|
2004-02-10 10:06:34 +00:00
|
|
|
Profile* GetProfile( PlayerNumber pn ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(pn); }
|
|
|
|
|
const Profile* GetProfile( ProfileSlot slot ) const;
|
|
|
|
|
Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); }
|
2005-05-01 06:42:30 +00:00
|
|
|
|
2004-02-22 02:01:40 +00:00
|
|
|
CString GetProfileDir( ProfileSlot slot ) const;
|
2005-04-24 19:39:54 +00:00
|
|
|
CString GetProfileDirImportedFrom( ProfileSlot slot ) const;
|
2003-09-08 03:26:58 +00:00
|
|
|
|
2005-07-01 04:46:32 +00:00
|
|
|
Profile* GetMachineProfile() { return m_pMachineProfile; }
|
2003-11-01 19:36:52 +00:00
|
|
|
|
2004-02-22 02:01:40 +00:00
|
|
|
CString GetPlayerName( PlayerNumber pn ) const;
|
|
|
|
|
bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn ) const;
|
2004-10-06 08:39:38 +00:00
|
|
|
bool LastLoadWasTamperedOrCorrupt( PlayerNumber pn ) const;
|
2004-10-07 19:57:51 +00:00
|
|
|
bool LastLoadWasFromLastGood( PlayerNumber pn ) const;
|
2003-09-08 03:26:58 +00:00
|
|
|
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2004-02-09 06:26:13 +00:00
|
|
|
//
|
|
|
|
|
// Song stats
|
|
|
|
|
//
|
2004-02-10 10:06:34 +00:00
|
|
|
int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const;
|
|
|
|
|
bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; }
|
2005-07-01 05:06:00 +00:00
|
|
|
void AddStepsScore( const Song* pSong, const Steps* pSteps , PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
2004-04-18 18:42:42 +00:00
|
|
|
void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn );
|
2005-07-01 05:06:00 +00:00
|
|
|
void GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc, HighScore &hsOut ) const;
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2004-02-09 06:26:13 +00:00
|
|
|
//
|
|
|
|
|
// Course stats
|
|
|
|
|
//
|
2005-07-01 05:06:00 +00:00
|
|
|
void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
2004-05-23 09:17:10 +00:00
|
|
|
void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn );
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2004-02-09 06:26:13 +00:00
|
|
|
//
|
|
|
|
|
// Category stats
|
|
|
|
|
//
|
2005-07-01 05:06:00 +00:00
|
|
|
void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
2004-05-24 03:32:56 +00:00
|
|
|
void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn );
|
2003-12-07 07:09:13 +00:00
|
|
|
|
|
|
|
|
|
2005-02-13 01:16:17 +00:00
|
|
|
// Lua
|
2005-02-13 04:14:33 +00:00
|
|
|
void PushSelf( lua_State *L );
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2003-09-08 03:26:58 +00:00
|
|
|
private:
|
2005-07-01 05:06:00 +00:00
|
|
|
// returns Profile::LoadResult, but we don't want to depend on Profile
|
|
|
|
|
int LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard );
|
2005-04-24 23:23:32 +00:00
|
|
|
void GetMemoryCardProfileDirectoriesToTry( vector<CString> &asDirsToTry ) const;
|
2003-11-01 22:04:43 +00:00
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
// Directory that contains the profile. Either on local machine or
|
|
|
|
|
// on a memory card.
|
2003-09-08 03:26:58 +00:00
|
|
|
CString m_sProfileDir[NUM_PLAYERS];
|
|
|
|
|
|
2005-04-24 19:39:54 +00:00
|
|
|
// MemoryCardProfileImportSubdirs name, if the profile was imported.
|
|
|
|
|
CString m_sProfileDirImportedFrom[NUM_PLAYERS];
|
|
|
|
|
|
2004-01-03 03:42:40 +00:00
|
|
|
bool m_bWasLoadedFromMemoryCard[NUM_PLAYERS];
|
2004-10-06 08:39:38 +00:00
|
|
|
bool m_bLastLoadWasTamperedOrCorrupt[NUM_PLAYERS]; // true if Stats.xml was present, but failed to load (probably because of a signature failure)
|
2005-03-26 22:18:28 +00:00
|
|
|
bool m_bLastLoadWasFromLastGood[NUM_PLAYERS]; // if true, then m_bLastLoadWasTamperedOrCorrupt is also true
|
2003-11-01 19:36:52 +00:00
|
|
|
|
2005-07-13 19:15:31 +00:00
|
|
|
Profile *m_pMemoryCardProfile[NUM_PLAYERS]; // holds Profile for the currently inserted card
|
2005-07-01 04:46:32 +00:00
|
|
|
Profile *m_pMachineProfile;
|
2003-09-08 03:26:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern ProfileManager* PROFILEMAN; // global and accessable from anywhere in our program
|
|
|
|
|
|
|
|
|
|
#endif
|
2004-06-08 01:24:17 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|