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"
|
2004-02-08 18:25:30 +00:00
|
|
|
#include "Profile.h"
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2004-02-09 06:26:13 +00:00
|
|
|
class Song;
|
2004-06-28 07:26:00 +00:00
|
|
|
class Style;
|
2005-02-13 01:16:17 +00:00
|
|
|
struct lua_State;
|
2004-02-09 06:26:13 +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();
|
|
|
|
|
|
2003-12-07 08:19:10 +00:00
|
|
|
bool CreateLocalProfile( CString sName );
|
|
|
|
|
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
|
|
|
|
bool DeleteLocalProfile( CString sProfileID );
|
2003-09-08 07:21:41 +00:00
|
|
|
|
2004-02-22 02:01:40 +00:00
|
|
|
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut ) const;
|
|
|
|
|
void GetLocalProfileNames( vector<CString> &asNamesOut ) 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 );
|
2004-07-20 01:31:23 +00:00
|
|
|
void SaveAllProfiles() const;
|
2004-02-22 02:01:40 +00:00
|
|
|
bool SaveProfile( PlayerNumber pn ) const;
|
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-02-15 09:24:48 +00:00
|
|
|
void AddStepTotals( PlayerNumber pn, int iNumTapsAndHolds, int iNumJumps, int iNumHolds, 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
|
|
|
|
2004-02-22 02:01:40 +00:00
|
|
|
bool IsUsingProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); }
|
2004-04-23 02:01:44 +00:00
|
|
|
bool IsUsingProfile( ProfileSlot slot ) const;
|
2004-02-10 10:06:34 +00:00
|
|
|
const Profile* GetProfile( PlayerNumber pn ) const;
|
|
|
|
|
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); }
|
2004-02-22 02:01:40 +00:00
|
|
|
CString GetProfileDir( ProfileSlot slot ) const;
|
2003-09-08 03:26:58 +00:00
|
|
|
|
2003-12-07 07:09:13 +00:00
|
|
|
Profile* GetMachineProfile() { return &m_MachineProfile; }
|
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; }
|
2004-04-22 22:01:38 +00:00
|
|
|
void AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
2004-04-18 18:42:42 +00:00
|
|
|
void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn );
|
2004-06-28 07:26:00 +00:00
|
|
|
HighScore GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc ) const;
|
2003-12-07 07:09:13 +00:00
|
|
|
|
2004-02-09 06:26:13 +00:00
|
|
|
//
|
|
|
|
|
// Course stats
|
|
|
|
|
//
|
2004-05-23 09:17:10 +00:00
|
|
|
void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
|
|
|
|
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
|
|
|
|
|
//
|
2004-05-24 03:32:56 +00:00
|
|
|
void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut );
|
|
|
|
|
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-04-24 19:18:46 +00:00
|
|
|
Profile::LoadResult LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard );
|
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];
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// actual loaded profile data
|
|
|
|
|
Profile m_Profile[NUM_PLAYERS];
|
2003-12-07 07:09:13 +00:00
|
|
|
|
|
|
|
|
Profile m_MachineProfile;
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|