reduce dependencies

This commit is contained in:
Glenn Maynard
2005-07-01 05:06:00 +00:00
parent 04546763e0
commit 3450307b01
3 changed files with 27 additions and 21 deletions
+8 -6
View File
@@ -15,6 +15,7 @@
#include "ProfileManager.h" #include "ProfileManager.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "HighScore.h"
CString GRADE_X_NAME( size_t p ) { return ssprintf("GradeP%dX",int(p+1)); } CString GRADE_X_NAME( size_t p ) { return ssprintf("GradeP%dX",int(p+1)); }
CString GRADE_Y_NAME( size_t p ) { return ssprintf("GradeP%dY",int(p+1)); } CString GRADE_Y_NAME( size_t p ) { return ssprintf("GradeP%dY",int(p+1)); }
@@ -253,13 +254,14 @@ void MusicWheelItem::RefreshGrades()
dc = GAMESTATE->m_pCurSteps[p]->GetDifficulty(); dc = GAMESTATE->m_pCurSteps[p]->GetDifficulty();
else else
dc = GAMESTATE->m_PreferredDifficulty[p]; dc = GAMESTATE->m_PreferredDifficulty[p];
Grade grade;
if( PROFILEMAN->IsPersistentProfile(p) )
grade = PROFILEMAN->GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyle(), (ProfileSlot)p, dc ).grade;
else
grade = PROFILEMAN->GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyle(), PROFILE_SLOT_MACHINE, dc ).grade;
m_GradeDisplay[p].SetGrade( p, grade ); HighScore hs;
if( PROFILEMAN->IsPersistentProfile(p) )
PROFILEMAN->GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyle(), (ProfileSlot)p, dc, hs );
else
PROFILEMAN->GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyle(), PROFILE_SLOT_MACHINE, dc, hs );
m_GradeDisplay[p].SetGrade( p, hs.grade );
} }
} }
+12 -8
View File
@@ -21,6 +21,7 @@
#include "XmlFile.h" #include "XmlFile.h"
#include "StepsUtil.h" #include "StepsUtil.h"
#include "Style.h" #include "Style.h"
#include "HighScore.h"
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
@@ -82,7 +83,7 @@ void ProfileManager::GetLocalProfileNames( vector<CString> &asNamesOut ) const
} }
Profile::LoadResult ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard ) int ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard )
{ {
LOG->Trace( "LoadingProfile P%d, %s, %d", pn+1, sProfileDir.c_str(), bIsMemCard ); LOG->Trace( "LoadingProfile P%d, %s, %d", pn+1, sProfileDir.c_str(), bIsMemCard );
@@ -180,7 +181,7 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
* but we also want to import scores in the case where the player created * but we also want to import scores in the case where the player created
* a directory for edits before playing, so keep searching if the directory * a directory for edits before playing, so keep searching if the directory
* exists with exists with no scores. */ * exists with exists with no scores. */
Profile::LoadResult res = LoadProfile( pn, sDir, true ); Profile::LoadResult res = (Profile::LoadResult) LoadProfile( pn, sDir, true );
if( res == Profile::success ) if( res == Profile::success )
{ {
iLoadedFrom = i; iLoadedFrom = i;
@@ -478,8 +479,9 @@ int ProfileManager::GetSongNumTimesPlayed( const Song* pSong, ProfileSlot slot )
return GetProfile(slot)->GetSongNumTimesPlayed( pSong ); return GetProfile(slot)->GetSongNumTimesPlayed( pSong );
} }
void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ) void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut )
{ {
HighScore hs = hs_;
hs.fPercentDP = max( 0, hs.fPercentDP ); // bump up negative scores hs.fPercentDP = max( 0, hs.fPercentDP ); // bump up negative scores
iPersonalIndexOut = -1; iPersonalIndexOut = -1;
@@ -528,7 +530,7 @@ void ProfileManager::IncrementStepsPlayCount( const Song* pSong, const Steps* pS
PROFILEMAN->GetMachineProfile()->IncrementStepsPlayCount( pSong, pSteps ); PROFILEMAN->GetMachineProfile()->IncrementStepsPlayCount( pSong, pSteps );
} }
HighScore ProfileManager::GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc ) const void ProfileManager::GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc, HighScore &hsOut ) const
{ {
// return max grade of notes in difficulty class // return max grade of notes in difficulty class
vector<Steps*> aNotes; vector<Steps*> aNotes;
@@ -538,17 +540,18 @@ HighScore ProfileManager::GetHighScoreForDifficulty( const Song *s, const Style
const Steps* pSteps = s->GetStepsByDifficulty( st->m_StepsType, dc ); const Steps* pSteps = s->GetStepsByDifficulty( st->m_StepsType, dc );
if( pSteps && PROFILEMAN->IsPersistentProfile(slot) ) if( pSteps && PROFILEMAN->IsPersistentProfile(slot) )
return PROFILEMAN->GetProfile(slot)->GetStepsHighScoreList(s,pSteps).GetTopScore(); hsOut = PROFILEMAN->GetProfile(slot)->GetStepsHighScoreList(s,pSteps).GetTopScore();
else else
return HighScore(); hsOut = HighScore();
} }
// //
// Course stats // Course stats
// //
void ProfileManager::AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ) void ProfileManager::AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut )
{ {
HighScore hs = hs_;
hs.fPercentDP = max( 0, hs.fPercentDP ); // bump up negative scores hs.fPercentDP = max( 0, hs.fPercentDP ); // bump up negative scores
iPersonalIndexOut = -1; iPersonalIndexOut = -1;
@@ -597,8 +600,9 @@ void ProfileManager::IncrementCoursePlayCount( const Course* pCourse, const Trai
// //
// Category stats // Category stats
// //
void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ) void ProfileManager::AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs_, int &iPersonalIndexOut, int &iMachineIndexOut )
{ {
HighScore hs = hs_;
hs.sName = RANKING_TO_FILL_IN_MARKER[pn]; hs.sName = RANKING_TO_FILL_IN_MARKER[pn];
if( PROFILEMAN->IsPersistentProfile(pn) ) if( PROFILEMAN->IsPersistentProfile(pn) )
PROFILEMAN->GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut ); PROFILEMAN->GetProfile(pn)->AddCategoryHighScore( st, rc, hs, iPersonalIndexOut );
+7 -7
View File
@@ -5,9 +5,7 @@
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "GameConstantsAndTypes.h" #include "GameConstantsAndTypes.h"
#include "HighScore.h"
#include "Difficulty.h" #include "Difficulty.h"
#include "Profile.h"
class Profile; class Profile;
class Song; class Song;
@@ -15,6 +13,7 @@ class Steps;
class Style; class Style;
class Course; class Course;
class Trail; class Trail;
struct HighScore;
struct lua_State; struct lua_State;
class ProfileManager class ProfileManager
@@ -78,20 +77,20 @@ public:
// //
int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const; int GetSongNumTimesPlayed( const Song* pSong, ProfileSlot card ) const;
bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; } bool IsSongNew( const Song* pSong ) const { return GetSongNumTimesPlayed(pSong,PROFILE_SLOT_MACHINE)==0; }
void AddStepsScore( const Song* pSong, const Steps* pSteps , PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); 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 ); void IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps, PlayerNumber pn );
HighScore GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc ) const; void GetHighScoreForDifficulty( const Song *s, const Style *st, ProfileSlot slot, Difficulty dc, HighScore &hsOut ) const;
// //
// Course stats // Course stats
// //
void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); void AddCourseScore( const Course* pCourse, const Trail* pTrail, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn ); void IncrementCoursePlayCount( const Course* pCourse, const Trail* pTrail, PlayerNumber pn );
// //
// Category stats // Category stats
// //
void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); void AddCategoryScore( StepsType st, RankingCategory rc, PlayerNumber pn, const HighScore &hs, int &iPersonalIndexOut, int &iMachineIndexOut );
void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn ); void IncrementCategoryPlayCount( StepsType st, RankingCategory rc, PlayerNumber pn );
@@ -99,7 +98,8 @@ public:
void PushSelf( lua_State *L ); void PushSelf( lua_State *L );
private: private:
Profile::LoadResult LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard ); // 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; void GetMemoryCardProfileDirectoriesToTry( vector<CString> &asDirsToTry ) const;
// Directory that contains the profile. Either on local machine or // Directory that contains the profile. Either on local machine or