Files
itgmania212121/stepmania/src/ProfileManager.h
T

167 lines
4.5 KiB
C++
Raw Normal View History

#ifndef ProfileManager_H
#define ProfileManager_H
/*
-----------------------------------------------------------------------------
Class: ProfileManager
Desc: Interface to profiles that exist on the machine or a memory card
plugged into the machine.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "PlayerNumber.h"
#include "GameConstantsAndTypes.h"
2003-12-09 10:20:18 +00:00
#include "Style.h"
2003-09-08 07:21:41 +00:00
struct Profile
{
Profile() { Init(); }
void Init()
{
2003-11-01 19:36:52 +00:00
m_sName = "";
2003-09-08 07:21:41 +00:00
m_sLastUsedHighScoreName = "";
2003-11-10 04:32:12 +00:00
m_bUsingProfileDefaultModifiers = false;
m_sDefaultModifiers = "";
m_iTotalPlays = 0;
m_iTotalPlaySeconds = 0;
m_iTotalGameplaySeconds = 0;
2003-12-08 04:39:29 +00:00
m_iCurrentCombo = 0;
2004-01-07 02:56:47 +00:00
m_fWeightPounds = 0;
m_fCaloriesBurned = 0;
2003-12-09 10:20:18 +00:00
int i;
for( i=0; i<NUM_PLAY_MODES; i++ )
m_iNumSongsPlayedByPlayMode[i] = 0;
for( i=0; i<NUM_STYLES; i++ )
m_iNumSongsPlayedByStyle[i] = 0;
for( i=0; i<NUM_DIFFICULTIES; i++ )
m_iNumSongsPlayedByDifficulty[i] = 0;
for( i=0; i<MAX_METER+1; i++ )
m_iNumSongsPlayedByMeter[i] = 0;
2003-09-08 07:21:41 +00:00
}
2004-01-07 02:56:47 +00:00
CString GetDisplayName();
CString GetDisplayCaloriesBurned();
int GetTotalNumSongsPlayed();
2003-09-08 07:21:41 +00:00
bool LoadFromIni( CString sIniPath );
2003-11-01 19:36:52 +00:00
bool SaveToIni( CString sIniPath );
CString m_sName;
2003-09-08 07:21:41 +00:00
CString m_sLastUsedHighScoreName;
2003-11-10 04:32:12 +00:00
bool m_bUsingProfileDefaultModifiers;
CString m_sDefaultModifiers;
int m_iTotalPlays;
int m_iTotalPlaySeconds;
int m_iTotalGameplaySeconds;
2003-12-08 04:39:29 +00:00
int m_iCurrentCombo;
2004-01-07 02:56:47 +00:00
float m_fWeightPounds;
int m_fCaloriesBurned;
2003-12-09 10:20:18 +00:00
int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES];
int m_iNumSongsPlayedByStyle[NUM_STYLES];
int m_iNumSongsPlayedByDifficulty[NUM_DIFFICULTIES];
int m_iNumSongsPlayedByMeter[MAX_METER+1];
2003-09-08 07:21:41 +00:00
};
class ProfileManager
{
public:
ProfileManager();
~ProfileManager();
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
2003-12-07 08:19:10 +00:00
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut );
void GetLocalProfileNames( vector<CString> &asNamesOut );
2003-09-08 07:21:41 +00:00
2004-01-03 03:42:40 +00:00
bool LoadProfileFromMemoryCard( PlayerNumber pn );
bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
2003-11-01 19:36:52 +00:00
bool SaveProfile( PlayerNumber pn );
void UnloadProfile( PlayerNumber pn );
void SaveMachineProfile();
bool IsUsingProfile( PlayerNumber pn ) { return !m_sProfileDir[pn].empty(); }
2003-11-01 19:36:52 +00:00
Profile* GetProfile( PlayerNumber pn );
2004-02-08 01:05:53 +00:00
CString GetProfileDir( ProfileSlot slot );
Profile* GetMachineProfile() { return &m_MachineProfile; }
2003-11-01 19:36:52 +00:00
2003-12-17 09:42:31 +00:00
CString GetPlayerName( PlayerNumber pn );
2004-01-03 03:42:40 +00:00
bool ProfileWasLoadedFromMemoryCard( PlayerNumber pn );
//
// High scores
//
void InitMachineScoresFromDisk();
void SaveMachineScoresToDisk();
struct CategoryData
{
struct HighScore
{
CString sName;
int iScore;
float fPercentDP;
HighScore()
{
iScore = 0;
fPercentDP = 0;
}
bool operator>=( const HighScore& other ) const;
};
vector<HighScore> vHighScores;
void AddHighScore( HighScore hs, int &iIndexOut );
2004-02-08 01:05:53 +00:00
} m_CategoryDatas[NUM_PROFILE_SLOTS][NUM_STEPS_TYPES][NUM_RANKING_CATEGORIES];
2003-12-21 04:19:51 +00:00
void AddHighScore( StepsType nt, RankingCategory rc, PlayerNumber pn, CategoryData::HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut )
{
hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
2003-12-21 04:19:51 +00:00
m_CategoryDatas[pn][nt][rc].AddHighScore( hs, iPersonalIndexOut );
2004-02-08 01:05:53 +00:00
m_CategoryDatas[PROFILE_SLOT_MACHINE][nt][rc].AddHighScore( hs, iMachineIndexOut );
}
void ReadSM300NoteScores();
2004-02-08 01:05:53 +00:00
void ReadSongScoresFromDir( CString sDir, ProfileSlot slot );
void ReadCourseScoresFromDir( CString sDir, ProfileSlot slot );
void ReadCategoryScoresFromDir( CString sDir, ProfileSlot slot );
2004-02-08 01:05:53 +00:00
void SaveSongScoresToDir( CString sDir, ProfileSlot slot );
void SaveCourseScoresToDir( CString sDir, ProfileSlot slot );
void SaveCategoryScoresToDir( CString sDir, ProfileSlot slot );
void SaveStatsWebPageToDir( CString sDir, ProfileSlot slot );
private:
2003-11-01 22:04:43 +00:00
bool LoadDefaultProfileFromMachine( PlayerNumber pn );
bool CreateMemoryCardProfile( PlayerNumber pn );
2003-11-01 22:04:43 +00:00
bool LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard );
bool CreateProfile( CString sProfileDir, CString sName );
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];
2004-01-03 03:42:40 +00:00
bool m_bWasLoadedFromMemoryCard[NUM_PLAYERS];
2003-11-01 19:36:52 +00:00
// actual loaded profile data
Profile m_Profile[NUM_PLAYERS];
Profile m_MachineProfile;
};
extern ProfileManager* PROFILEMAN; // global and accessable from anywhere in our program
#endif