Files
itgmania212121/stepmania/src/ProfileManager.h
T

156 lines
5.9 KiB
C++
Raw Normal View History

2005-02-13 03:40:37 +00:00
/* ProfileManager - Interface to machine and memory card profiles. */
2004-06-08 01:24:17 +00:00
#ifndef ProfileManager_H
#define ProfileManager_H
#include "PlayerNumber.h"
#include "GameConstantsAndTypes.h"
#include "Difficulty.h"
2003-09-08 07:21:41 +00:00
class Profile;
2004-02-09 06:26:13 +00:00
class Song;
class Steps;
2004-06-28 07:26:00 +00:00
class Style;
class Course;
class Trail;
2005-07-01 05:06:00 +00:00
struct HighScore;
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
class ProfileManager
{
public:
ProfileManager();
~ProfileManager();
2004-05-25 05:52:57 +00:00
void Init();
// local profiles
void RefreshLocalProfilesFromDisk();
Profile &GetLocalProfile( const CString &sProfileID );
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 );
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 );
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 );
void UnloadProfile( PlayerNumber pn );
//
// 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-16 05:35:06 +00:00
//
// High scores
//
void LoadMachineProfile();
2004-07-20 01:31:23 +00:00
void SaveMachineProfile() const;
bool IsPersistentProfile( PlayerNumber pn ) const { return !m_sProfileDir[pn].empty(); }
bool IsPersistentProfile( ProfileSlot slot ) const;
// 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); }
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;
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;
bool LastLoadWasTamperedOrCorrupt( PlayerNumber pn ) const;
bool LastLoadWasFromLastGood( PlayerNumber pn ) const;
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 );
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;
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 );
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 );
void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn );
// Lua
void PushSelf( lua_State *L );
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 );
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.
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];
bool m_bLastLoadWasTamperedOrCorrupt[NUM_PLAYERS]; // true if Stats.xml was present, but failed to load (probably because of a signature failure)
bool m_bLastLoadWasFromLastGood[NUM_PLAYERS]; // if true, then m_bLastLoadWasTamperedOrCorrupt is also true
2003-11-01 19:36:52 +00:00
Profile *m_pMemoryCardProfile[NUM_PLAYERS]; // holds Profile for the currently inserted card
Profile *m_pMachineProfile;
};
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.
*/