diff --git a/stepmania/Themes/default/Graphics/ScreenEvaluation difficulty icons 1x6.redir b/stepmania/Themes/default/Graphics/ScreenEvaluation difficulty icons 1x6.redir new file mode 100644 index 0000000000..353f649648 --- /dev/null +++ b/stepmania/Themes/default/Graphics/ScreenEvaluation difficulty icons 1x6.redir @@ -0,0 +1 @@ +ScreenSelectMusic difficulty icons 1x6 diff --git a/stepmania/Themes/default/Graphics/ScreenGameplay difficulty icons 2x6.png b/stepmania/Themes/default/Graphics/ScreenGameplay difficulty icons 2x6.png new file mode 100644 index 0000000000..39525cdec7 Binary files /dev/null and b/stepmania/Themes/default/Graphics/ScreenGameplay difficulty icons 2x6.png differ diff --git a/stepmania/Themes/default/Graphics/ScreenSelectMusic difficulty icons 1x6.png b/stepmania/Themes/default/Graphics/ScreenSelectMusic difficulty icons 1x6.png new file mode 100644 index 0000000000..c025724924 Binary files /dev/null and b/stepmania/Themes/default/Graphics/ScreenSelectMusic difficulty icons 1x6.png differ diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index c4e530e524..ef934e5a27 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -2911,6 +2911,7 @@ EasyColor=0.9,0.9,0,1 // yellow MediumColor=1,0.1,0.1,1 // light red HardColor=0.2,1,0.2,1 // light green ChallengeColor=0.2,0.6,1.0,1 // blue +EditColor=0.8,0.8,0.8,1 // gray ExtraColor=1.0,0.0,0.0,1.0 // red ExtraColorMeter=10 @@ -3079,6 +3080,7 @@ EasyColor=0,0,0,0 MediumColor=0,0,0,0 HardColor=0,0,0,0 ChallengeColor=0,0,0,0 +EditColor=0,0,0,0 ShowStream= ShowVoltage= ShowAir= diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 5bfea013fb..6317cf36a4 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -1036,10 +1036,10 @@ void Course::AddHighScore( StepsType st, PlayerNumber pn, MemCardData::HighScore m_MemCardDatas[st][pn].AddHighScore( hs, iPersonalIndexOut ); else iPersonalIndexOut = -1; - m_MemCardDatas[st][MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut ); + m_MemCardDatas[st][PROFILE_SLOT_MACHINE].AddHighScore( hs, iMachineIndexOut ); } -int Course::GetNumTimesPlayed( MemoryCard card ) const +int Course::GetNumTimesPlayed( ProfileSlot card ) const { int iTotalNumTimesPlayed = 0; for( unsigned i = 0; i < NUM_STEPS_TYPES; ++i ) @@ -1077,7 +1077,7 @@ void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ) } -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, MemoryCard card ) +void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, ProfileSlot card ) { for(unsigned i = 0; i < arrayCoursePointers.size(); ++i) course_sort_val[arrayCoursePointers[i]] = (float) arrayCoursePointers[i]->GetNumTimesPlayed( card ); diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index bc1e8aaf01..9632753333 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -176,21 +176,21 @@ public: return vHighScores[0]; } - } m_MemCardDatas[NUM_STEPS_TYPES][NUM_MEMORY_CARDS]; + } m_MemCardDatas[NUM_STEPS_TYPES][NUM_PROFILE_SLOTS]; void AddHighScore( StepsType st, PlayerNumber pn, MemCardData::HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); - MemCardData::HighScore GetTopScore( StepsType st, MemoryCard card ) + MemCardData::HighScore GetTopScore( StepsType st, ProfileSlot slot ) { - return m_MemCardDatas[st][card].GetTopScore(); + return m_MemCardDatas[st][slot].GetTopScore(); } - int GetNumTimesPlayed( StepsType st, MemoryCard card ) const + int GetNumTimesPlayed( StepsType st, ProfileSlot slot ) const { - return m_MemCardDatas[st][card].iNumTimesPlayed; + return m_MemCardDatas[st][slot].iNumTimesPlayed; } - int GetNumTimesPlayed( MemoryCard card ) const; + int GetNumTimesPlayed( ProfileSlot slot ) const; // sorting values int SortOrder_TotalDifficulty; @@ -217,7 +217,7 @@ void SortCoursePointerArrayByType( vector &apCourses ); void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ); void SortCoursePointerArrayByTotalDifficulty( vector &apCourses ); void SortCoursePointerArrayByRanking( vector &apCourses ); -void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, MemoryCard card ); +void SortCoursePointerArrayByMostPlayed( vector &arrayCoursePointers, ProfileSlot slot ); void MoveRandomToEnd( vector &apCourses ); diff --git a/stepmania/src/DifficultyDisplay.cpp b/stepmania/src/DifficultyDisplay.cpp index 07a998746a..702ba8512e 100644 --- a/stepmania/src/DifficultyDisplay.cpp +++ b/stepmania/src/DifficultyDisplay.cpp @@ -14,7 +14,7 @@ DifficultyDisplay::DifficultyDisplay() int diff; for( diff = DIFFICULTY_BEGINNER; diff <= DIFFICULTY_CHALLENGE; ++diff ) { - m_difficulty[diff].Load( THEME->GetPathToG("DifficultyDisplay bar 5x1") ); + m_difficulty[diff].Load( THEME->GetPathToG(ssprintf("DifficultyDisplay bar %dx1",NUM_DIFFICULTIES)) ); m_difficulty[diff].SetState(diff); m_difficulty[diff].StopAnimating(); this->AddChild( &m_difficulty[diff] ); diff --git a/stepmania/src/DifficultyIcon.cpp b/stepmania/src/DifficultyIcon.cpp index b8ba2961c3..63c65dbccf 100644 --- a/stepmania/src/DifficultyIcon.cpp +++ b/stepmania/src/DifficultyIcon.cpp @@ -26,8 +26,16 @@ bool DifficultyIcon::Load( CString sPath ) { Sprite::Load( sPath ); int iStates = GetNumStates(); - if( iStates != 5 && iStates != 10 ) - HOOKS->MessageBoxOK( ssprintf("The difficulty icon graphic '%s' must have 5 or 10 frames. It has %d states.", sPath.c_str(), iStates) ); + if( iStates != NUM_DIFFICULTIES && iStates != NUM_DIFFICULTIES*2 ) + { + CString sError = ssprintf( + "The difficulty icon graphic '%s' must have %d or %d frames. It has %d states.", + sPath.c_str(), + NUM_DIFFICULTIES, + NUM_DIFFICULTIES*2, + iStates ); + HOOKS->MessageBoxOK( sError ); + } StopAnimating(); return true; } @@ -47,9 +55,9 @@ void DifficultyIcon::SetFromNotes( PlayerNumber pn, Steps* pNotes ) switch( GetNumStates() ) { - case 5: SetState( iStateNo ); break; - case 10: SetState( iStateNo*2+pn ); break; - default: SetState( 0 ); break; + case NUM_DIFFICULTIES: SetState( iStateNo ); break; + case NUM_DIFFICULTIES*2: SetState( iStateNo*2+pn ); break; + default: SetState( 0 ); break; } } } diff --git a/stepmania/src/DifficultyList.cpp b/stepmania/src/DifficultyList.cpp index d5ff91d5a2..d716439d90 100644 --- a/stepmania/src/DifficultyList.cpp +++ b/stepmania/src/DifficultyList.cpp @@ -305,7 +305,11 @@ void DifficultyList::SetFromGameState() Difficulty dc = row.m_Steps->GetDifficulty(); - CString s = SONGMAN->GetDifficultyThemeName(dc); + CString s; + if( row.m_Steps->GetDifficulty() == DIFFICULTY_EDIT ) + s = row.m_Steps->GetDescription(); + else + s = SONGMAN->GetDifficultyThemeName(dc); m_Descriptions[i].SetMaxWidth( DESCRIPTION_MAX_WIDTH ); m_Descriptions[i].SetText( s ); /* Don't mess with alpha; it might be fading on. */ diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 5828c0e0e8..b7c2894dd7 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -41,6 +41,7 @@ CString DifficultyToString( Difficulty dc ) case DIFFICULTY_MEDIUM: return "medium"; case DIFFICULTY_HARD: return "hard"; case DIFFICULTY_CHALLENGE: return "challenge"; + case DIFFICULTY_EDIT: return "edit"; default: ASSERT(0); return ""; // invalid Difficulty } } @@ -67,6 +68,7 @@ Difficulty StringToDifficulty( CString sDC ) else if( sDC == "challenge" ) return DIFFICULTY_CHALLENGE; else if( sDC == "expert" ) return DIFFICULTY_CHALLENGE; else if( sDC == "oni" ) return DIFFICULTY_CHALLENGE; + else if( sDC == "edit" ) return DIFFICULTY_EDIT; else return DIFFICULTY_INVALID; } diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index f70c5ddd51..65fc2e7f9d 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -66,6 +66,7 @@ enum Difficulty DIFFICULTY_MEDIUM, // corresponds to Trick, Another, Standard, Normal DIFFICULTY_HARD, // corresponds to Maniac, SSR, Heavy, Crazy DIFFICULTY_CHALLENGE, // corresponds to 5th SMANIAC, MAX2 Challenge, EX Challenge + DIFFICULTY_EDIT, NUM_DIFFICULTIES, DIFFICULTY_INVALID }; @@ -200,14 +201,15 @@ enum HoldNoteScore // -// MemCard stuff +// Profile and MemCard stuff // -enum MemoryCard +enum ProfileSlot { - MEMORY_CARD_PLAYER_1, - MEMORY_CARD_PLAYER_2, - MEMORY_CARD_MACHINE, - NUM_MEMORY_CARDS + PROFILE_SLOT_PLAYER_1, + PROFILE_SLOT_PLAYER_2, + PROFILE_SLOT_MACHINE, + NUM_PROFILE_SLOTS, + PROFILE_SLOT_INVALID }; enum MemoryCardState diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index fa094b07eb..5256f61da2 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -161,11 +161,6 @@ void GameState::Reset() m_iCpuSkill[p] = 5; } - for( p=0; pSaveProfile( (PlayerNumber)p ); - PROFILEMAN->UnloadProfile( (PlayerNumber)p ); - } MEMCARDMAN->LockCards( false ); LIGHTSMAN->SetLightMode( LIGHTMODE_ATTRACT ); @@ -192,6 +187,12 @@ void CheckStageStats( const StageStats &ss, int p ) // RAGE_ASSERT_M( ss.iMeter[p] < MAX_METER+1, ssprintf("%i", ss.iMeter[p]) ); } +void GameState::PlayersFinalized() +{ + MEMCARDMAN->LockCards( true ); + SONGMAN->LoadAllFromProfiles(); +} + void GameState::EndGame() { // Update profile stats @@ -265,6 +266,14 @@ void GameState::EndGame() BOOKKEEPER->WriteToDisk(); PROFILEMAN->SaveMachineScoresToDisk(); + + for( p=0; pSaveProfile( (PlayerNumber)p ); + PROFILEMAN->UnloadProfile( (PlayerNumber)p ); + } + + SONGMAN->FreeAllLoadedFromProfiles(); } void GameState::Update( float fDelta ) @@ -1122,7 +1131,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsO Steps* pSteps = vSongAndSteps[i].pSteps; // Find Machine Records - vector &vMachineHighScores = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores; + vector &vMachineHighScores = pSteps->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores; for( j=0; j &asFeatsO // Find Machine Records for( i=0; i &vHighScores = PROFILEMAN->m_CategoryDatas[MEMORY_CARD_MACHINE][nt][i].vHighScores; + vector &vHighScores = PROFILEMAN->m_CategoryDatas[PROFILE_SLOT_MACHINE][nt][i].vHighScores; for( unsigned j=0; j &asFeatsO // Find Machine Records { - vector &vHighScores = pCourse->m_MemCardDatas[nt][MEMORY_CARD_MACHINE].vHighScores; + vector &vHighScores = pCourse->m_MemCardDatas[nt][PROFILE_SLOT_MACHINE].vHighScores; for( unsigned i=0; iLockCards( true ); + GAMESTATE->PlayersFinalized(); } } diff --git a/stepmania/src/MusicWheelItem.cpp b/stepmania/src/MusicWheelItem.cpp index e7376e2528..8e58ba5f2e 100644 --- a/stepmania/src/MusicWheelItem.cpp +++ b/stepmania/src/MusicWheelItem.cpp @@ -186,7 +186,7 @@ void MusicWheelItem::LoadFromWheelItemData( WheelItemData* pWID ) ASSERT( 0 ); // invalid type } } -Steps::MemCardData::HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, MemoryCard card, Difficulty dc ); +Steps::MemCardData::HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, ProfileSlot card, Difficulty dc ); void MusicWheelItem::RefreshGrades() { @@ -207,9 +207,9 @@ void MusicWheelItem::RefreshGrades() dc = GAMESTATE->m_PreferredDifficulty[p]; Grade grade; if( PROFILEMAN->IsUsingProfile((PlayerNumber)p) ) - grade = GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyleDef(), (MemoryCard)p, dc ).grade; + grade = GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyleDef(), (ProfileSlot)p, dc ).grade; else - grade = GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyleDef(), MEMORY_CARD_MACHINE, dc ).grade; + grade = GetHighScoreForDifficulty( data->m_pSong, GAMESTATE->GetCurrentStyleDef(), PROFILE_SLOT_MACHINE, dc ).grade; m_GradeDisplay[p].SetGrade( (PlayerNumber)p, grade ); } diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 3638ac5ee7..cd543c74a3 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -6,6 +6,7 @@ #include "MsdFile.h" #include "RageLog.h" #include "RageUtil.h" +#include "SongManager.h" void SMLoader::LoadFromSMTokens( CString sNotesType, @@ -378,3 +379,69 @@ bool SMLoader::LoadFromDir( CString sPath, Song &out ) return LoadFromSMFile( sPath + aFileNames[0], out ); } +bool SMLoader::LoadEdit( CString sEditFilePath ) +{ + LOG->Trace( "Song::LoadEdit(%s)", sEditFilePath.c_str() ); + + MsdFile msd; + bool bResult = msd.ReadFile( sEditFilePath ); + if( !bResult ) + RageException::Throw( "Error opening file '%s'.", sEditFilePath.c_str() ); + + Song* pSong = NULL; + + for( unsigned i=0; iWarn( "The edit file '%s' has more than one #SONG tag.", sEditFilePath.c_str() ); + return false; + } + + CString& sSongFullTitle = sParams[1]; + sSongFullTitle.Replace( '\\', '/' ); + + pSong = SONGMAN->FindSong( sSongFullTitle ); + if( pSong == NULL ) + { + LOG->Warn( "The edit file '%s' required a song '%s' that isn't present.", sEditFilePath.c_str(), sSongFullTitle.c_str() ); + return false; + } + } + + else if( 0==stricmp(sValueName,"NOTES") ) + { + if( pSong == NULL ) + { + LOG->Warn( "The edit file '%s' has doesn't have a #SONG tag preceeding the first #NOTES tag.", sEditFilePath.c_str() ); + return false; + } + + Steps* pNewNotes = new Steps; + ASSERT( pNewNotes ); + pSong->m_apNotes.push_back( pNewNotes ); + + if( iNumParams < 7 ) + { + LOG->Trace( "The song file '%s' is has %d fields in a #NOTES tag, but should have at least %d.", sEditFilePath.c_str(), iNumParams, 7 ); + continue; + } + + LoadFromSMTokens( + sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6], (iNumParams>=8)?sParams[7]:"", + *pNewNotes); + } + else + LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() ); + } + + return true; + +} diff --git a/stepmania/src/NotesLoaderSM.h b/stepmania/src/NotesLoaderSM.h index 44f00ac9d9..6a544090c2 100644 --- a/stepmania/src/NotesLoaderSM.h +++ b/stepmania/src/NotesLoaderSM.h @@ -33,6 +33,7 @@ public: bool LoadFromDir( CString sPath, Song &out ); static bool LoadTimingFromFile( const CString &fn, TimingData &out ); static void LoadTimingFromSMFile( const MsdFile &msd, TimingData &out ); + static bool LoadEdit( CString sEditFilePath ); }; #endif diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index d9c0c96b0e..6ab9c72fa3 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -68,13 +68,13 @@ static const PaneModes PaneMode[NUM_PANES] = // PANEMODE_COURSE }; -static MemoryCard PlayerMemCard( PlayerNumber pn ) +static ProfileSlot PlayerMemCard( PlayerNumber pn ) { switch( pn ) { - case PLAYER_1: return MEMORY_CARD_PLAYER_1; - default: ASSERT(0); - case PLAYER_2: return MEMORY_CARD_PLAYER_2; + case PLAYER_1: return PROFILE_SLOT_PLAYER_1; + case PLAYER_2: return PROFILE_SLOT_PLAYER_2; + default: ASSERT(0); return PROFILE_SLOT_MACHINE; }; } @@ -198,12 +198,12 @@ void PaneDisplay::SetContent( PaneContents c ) case SONG_MACHINE_HIGH_NAME: /* set val for color */ case SONG_MACHINE_HIGH_SCORE: - val = 100.0f * GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetTopScore( MEMORY_CARD_MACHINE ).fPercentDP; + val = 100.0f * GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetTopScore( PROFILE_SLOT_MACHINE ).fPercentDP; break; case SONG_MACHINE_RANK: { - const vector best = SONGMAN->GetBestSongs( MEMORY_CARD_MACHINE ); + const vector best = SONGMAN->GetBestSongs( PROFILE_SLOT_MACHINE ); val = (float) FindIndex( best.begin(), best.end(), GAMESTATE->m_pCurSong ); val += 1; break; @@ -219,16 +219,16 @@ void PaneDisplay::SetContent( PaneContents c ) case COURSE_MACHINE_HIGH_NAME: /* set val for color */ case COURSE_MACHINE_HIGH_SCORE: - val = 100.0f * GAMESTATE->m_pCurCourse->GetTopScore( GAMESTATE->GetCurrentStyleDef()->m_StepsType, MEMORY_CARD_MACHINE ).fPercentDP; + val = 100.0f * GAMESTATE->m_pCurCourse->GetTopScore( GAMESTATE->GetCurrentStyleDef()->m_StepsType, PROFILE_SLOT_MACHINE ).fPercentDP; break; case COURSE_MACHINE_NUM_PLAYS: - val = (float) GAMESTATE->m_pCurCourse->GetNumTimesPlayed( MEMORY_CARD_MACHINE ); + val = (float) GAMESTATE->m_pCurCourse->GetNumTimesPlayed( PROFILE_SLOT_MACHINE ); break; case COURSE_MACHINE_RANK: { - const vector best = SONGMAN->GetBestCourses( MEMORY_CARD_MACHINE ); + const vector best = SONGMAN->GetBestCourses( PROFILE_SLOT_MACHINE ); val = (float) FindIndex( best.begin(), best.end(), GAMESTATE->m_pCurCourse ); val += 1; } @@ -265,10 +265,10 @@ void PaneDisplay::SetContent( PaneContents c ) switch( c ) { case SONG_MACHINE_HIGH_NAME: - str = GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetTopScore( MEMORY_CARD_MACHINE ).sName; + str = GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetTopScore( PROFILE_SLOT_MACHINE ).sName; break; case COURSE_MACHINE_HIGH_NAME: - str = GAMESTATE->m_pCurCourse->GetTopScore( GAMESTATE->GetCurrentStyleDef()->m_StepsType, MEMORY_CARD_MACHINE ).sName; + str = GAMESTATE->m_pCurCourse->GetTopScore( GAMESTATE->GetCurrentStyleDef()->m_StepsType, PROFILE_SLOT_MACHINE ).sName; break; case SONG_MACHINE_HIGH_SCORE: diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index ec19076ae9..d07b2a9602 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -141,9 +141,9 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs return false; } - ReadCategoryScoresFromDir( m_sProfileDir[pn], (MemoryCard)pn ); - ReadSongScoresFromDir( m_sProfileDir[pn], (MemoryCard)pn ); - ReadCourseScoresFromDir( m_sProfileDir[pn], (MemoryCard)pn ); + ReadCategoryScoresFromDir( m_sProfileDir[pn], (ProfileSlot)pn ); + ReadSongScoresFromDir( m_sProfileDir[pn], (ProfileSlot)pn ); + ReadCourseScoresFromDir( m_sProfileDir[pn], (ProfileSlot)pn ); // apply saved default modifiers if any if( m_Profile[pn].m_bUsingProfileDefaultModifiers ) @@ -245,10 +245,10 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) m_Profile[pn].SaveToIni( m_sProfileDir[pn]+PROFILE_FILE ); - SaveCategoryScoresToDir( m_sProfileDir[pn], (MemoryCard)pn ); - SaveSongScoresToDir( m_sProfileDir[pn], (MemoryCard)pn ); - SaveCourseScoresToDir( m_sProfileDir[pn], (MemoryCard)pn ); - SaveStatsWebPageToDir( m_sProfileDir[pn], (MemoryCard)pn ); + SaveCategoryScoresToDir( m_sProfileDir[pn], (ProfileSlot)pn ); + SaveSongScoresToDir( m_sProfileDir[pn], (ProfileSlot)pn ); + SaveCourseScoresToDir( m_sProfileDir[pn], (ProfileSlot)pn ); + SaveStatsWebPageToDir( m_sProfileDir[pn], (ProfileSlot)pn ); return true; } @@ -414,10 +414,10 @@ void ProfileManager::SaveMachineScoresToDisk() { m_MachineProfile.SaveToIni( MACHINE_PROFILE_DIR PROFILE_FILE ); - SaveCategoryScoresToDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); - SaveSongScoresToDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); - SaveCourseScoresToDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); - SaveStatsWebPageToDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); + SaveCategoryScoresToDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); + SaveSongScoresToDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); + SaveCourseScoresToDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); + SaveStatsWebPageToDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); } void ProfileManager::CategoryData::AddHighScore( HighScore hs, int &iIndexOut ) @@ -440,7 +440,7 @@ void ProfileManager::CategoryData::AddHighScore( HighScore hs, int &iIndexOut ) #define WARN_AND_RETURN { LOG->Warn("Error parsing file '%s' at %s:%d",fn.c_str(),__FILE__,__LINE__); return; } -void ProfileManager::ReadSongScoresFromDir( CString sDir, MemoryCard mc ) +void ProfileManager::ReadSongScoresFromDir( CString sDir, ProfileSlot slot ) { CString fn = sDir + SONG_SCORES_FILE; @@ -503,14 +503,14 @@ void ProfileManager::ReadSongScoresFromDir( CString sDir, MemoryCard mc ) WARN_AND_RETURN; if( pNotes ) - pNotes->m_MemCardDatas[mc].iNumTimesPlayed = iNumTimesPlayed; + pNotes->m_MemCardDatas[slot].iNumTimesPlayed = iNumTimesPlayed; int iNumHighScores; if( !FileRead(f, iNumHighScores) ) WARN_AND_RETURN; if( pNotes ) - pNotes->m_MemCardDatas[mc].vHighScores.resize( iNumHighScores ); + pNotes->m_MemCardDatas[slot].vHighScores.resize( iNumHighScores ); int l; for( l=0; lm_MemCardDatas[mc].vHighScores[l].sName = sName; - pNotes->m_MemCardDatas[mc].vHighScores[l].grade = grade; - pNotes->m_MemCardDatas[mc].vHighScores[l].iScore = iScore; - pNotes->m_MemCardDatas[mc].vHighScores[l].fPercentDP = fPercentDP; + pNotes->m_MemCardDatas[slot].vHighScores[l].sName = sName; + pNotes->m_MemCardDatas[slot].vHighScores[l].grade = grade; + pNotes->m_MemCardDatas[slot].vHighScores[l].iScore = iScore; + pNotes->m_MemCardDatas[slot].vHighScores[l].fPercentDP = fPercentDP; } // ignore all high scores that are 0 for( l=0; lm_MemCardDatas[mc].vHighScores[l].iScore <= 0 ) + if( pNotes && pNotes->m_MemCardDatas[slot].vHighScores[l].iScore <= 0 ) { - pNotes->m_MemCardDatas[mc].vHighScores.resize(l); + pNotes->m_MemCardDatas[slot].vHighScores.resize(l); break; } } @@ -555,7 +555,7 @@ void ProfileManager::ReadSongScoresFromDir( CString sDir, MemoryCard mc ) } -void ProfileManager::ReadCategoryScoresFromDir( CString sDir, MemoryCard mc ) +void ProfileManager::ReadCategoryScoresFromDir( CString sDir, ProfileSlot slot ) { CString fn = sDir + CATEGORY_SCORES_FILE; @@ -580,7 +580,7 @@ void ProfileManager::ReadCategoryScoresFromDir( CString sDir, MemoryCard mc ) if( !FileRead(f, iNumHighScores) ) WARN_AND_RETURN; - m_CategoryDatas[mc][st][rc].vHighScores.resize( iNumHighScores ); + m_CategoryDatas[slot][st][rc].vHighScores.resize( iNumHighScores ); for( int l=0; lm_MemCardDatas[st][mc].iNumTimesPlayed = iNumTimesPlayed; + pCourse->m_MemCardDatas[st][slot].iNumTimesPlayed = iNumTimesPlayed; int iNumHighScores; if( !FileRead(f, iNumHighScores) ) WARN_AND_RETURN; if( pCourse ) - pCourse->m_MemCardDatas[st][mc].vHighScores.resize(iNumHighScores); + pCourse->m_MemCardDatas[st][slot].vHighScores.resize(iNumHighScores); for( int l=0; lm_MemCardDatas[st][mc].vHighScores[l].sName = sName; - pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore = iScore; - pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP = fPercentDP; - pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime = fSurviveTime; + pCourse->m_MemCardDatas[st][slot].vHighScores[l].sName = sName; + pCourse->m_MemCardDatas[st][slot].vHighScores[l].iScore = iScore; + pCourse->m_MemCardDatas[st][slot].vHighScores[l].fPercentDP = fPercentDP; + pCourse->m_MemCardDatas[st][slot].vHighScores[l].fSurviveTime = fSurviveTime; } } } @@ -697,9 +697,9 @@ void ProfileManager::InitMachineScoresFromDisk() ReadSM300NoteScores(); // category ranking - ReadCategoryScoresFromDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); - ReadSongScoresFromDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); - ReadCourseScoresFromDir( MACHINE_PROFILE_DIR, MEMORY_CARD_MACHINE ); + ReadCategoryScoresFromDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); + ReadSongScoresFromDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); + ReadCourseScoresFromDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE ); if( !m_MachineProfile.LoadFromIni(MACHINE_PROFILE_DIR PROFILE_FILE) ) { @@ -758,26 +758,26 @@ void ProfileManager::ReadSM300NoteScores() char szGradeLetters[10]; // longest possible string is "AAA" int iMaxCombo; // throw away - pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores.resize(1); + pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores.resize(1); iRetVal = sscanf( value, "%d::%[^:]::%d::%d", - &pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].iNumTimesPlayed, + &pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].iNumTimesPlayed, szGradeLetters, - &pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores[0].iScore, + &pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores[0].iScore, &iMaxCombo ); if( iRetVal != 4 ) continue; - pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores[0].grade = StringToGrade( szGradeLetters ); + pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores[0].grade = StringToGrade( szGradeLetters ); } } } -void ProfileManager::SaveCategoryScoresToDir( CString sDir, MemoryCard mc ) +void ProfileManager::SaveCategoryScoresToDir( CString sDir, ProfileSlot slot ) { CString fn = sDir + CATEGORY_SCORES_FILE; @@ -796,23 +796,23 @@ void ProfileManager::SaveCategoryScoresToDir( CString sDir, MemoryCard mc ) { for( int rc=0; rcm_MemCardDatas[st][mc].iNumTimesPlayed ) + if( pCourse->m_MemCardDatas[st][slot].iNumTimesPlayed ) ++NumStepsPlayed; FileWrite( f, NumStepsPlayed ); for( st=0; stm_MemCardDatas[st][mc].iNumTimesPlayed ) + if( !pCourse->m_MemCardDatas[st][slot].iNumTimesPlayed ) continue; --NumStepsPlayed; FileWrite( f, st ); - FileWrite( f, pCourse->m_MemCardDatas[st][mc].iNumTimesPlayed ); - FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores.size() ); - for( unsigned l=0; lm_MemCardDatas[st][mc].vHighScores.size(); l++ ) + FileWrite( f, pCourse->m_MemCardDatas[st][slot].iNumTimesPlayed ); + FileWrite( f, pCourse->m_MemCardDatas[st][slot].vHighScores.size() ); + for( unsigned l=0; lm_MemCardDatas[st][slot].vHighScores.size(); l++ ) { // tricky: wipe out "name to fill in" markers - if( IsRankingToFillIn(pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName) ) - pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName = ""; + if( IsRankingToFillIn(pCourse->m_MemCardDatas[st][slot].vHighScores[l].sName) ) + pCourse->m_MemCardDatas[st][slot].vHighScores[l].sName = ""; - FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].sName ); - FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].iScore ); - FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fPercentDP ); - FileWrite( f, pCourse->m_MemCardDatas[st][mc].vHighScores[l].fSurviveTime ); + FileWrite( f, pCourse->m_MemCardDatas[st][slot].vHighScores[l].sName ); + FileWrite( f, pCourse->m_MemCardDatas[st][slot].vHighScores[l].iScore ); + FileWrite( f, pCourse->m_MemCardDatas[st][slot].vHighScores[l].fPercentDP ); + FileWrite( f, pCourse->m_MemCardDatas[st][slot].vHighScores[l].fSurviveTime ); } } ASSERT( !NumStepsPlayed ); } } -void ProfileManager::SaveSongScoresToDir( CString sDir, MemoryCard mc ) +void ProfileManager::SaveSongScoresToDir( CString sDir, ProfileSlot slot ) { CString fn = sDir + SONG_SCORES_FILE; @@ -905,7 +905,7 @@ void ProfileManager::SaveSongScoresToDir( CString sDir, MemoryCard mc ) for( unsigned i=0; im_apNotes.size(); ++i ) { Steps* pNotes = pSong->m_apNotes[i]; - if( pNotes->m_MemCardDatas[mc].iNumTimesPlayed == 0 && pNotes->m_MemCardDatas[mc].vHighScores.empty() ) + if( pNotes->m_MemCardDatas[slot].iNumTimesPlayed == 0 && pNotes->m_MemCardDatas[slot].vHighScores.empty() ) continue; vNotes.push_back( pNotes ); } @@ -924,20 +924,20 @@ void ProfileManager::SaveSongScoresToDir( CString sDir, MemoryCard mc ) FileWrite( f, pNotes->m_StepsType ); FileWrite( f, pNotes->GetDifficulty() ); FileWrite( f, pNotes->GetDescription() ); - FileWrite( f, pNotes->m_MemCardDatas[mc].iNumTimesPlayed ); + FileWrite( f, pNotes->m_MemCardDatas[slot].iNumTimesPlayed ); - FileWrite( f, pNotes->m_MemCardDatas[mc].vHighScores.size() ); + FileWrite( f, pNotes->m_MemCardDatas[slot].vHighScores.size() ); - for( int l=0; l<(int)pNotes->m_MemCardDatas[mc].vHighScores.size(); l++ ) + for( int l=0; l<(int)pNotes->m_MemCardDatas[slot].vHighScores.size(); l++ ) { // tricky: wipe out "name to fill in" markers - if( IsRankingToFillIn(pNotes->m_MemCardDatas[mc].vHighScores[l].sName) ) - pNotes->m_MemCardDatas[mc].vHighScores[l].sName = ""; + if( IsRankingToFillIn(pNotes->m_MemCardDatas[slot].vHighScores[l].sName) ) + pNotes->m_MemCardDatas[slot].vHighScores[l].sName = ""; - FileWrite( f, pNotes->m_MemCardDatas[mc].vHighScores[l].sName ); - FileWrite( f, pNotes->m_MemCardDatas[mc].vHighScores[l].grade ); - FileWrite( f, pNotes->m_MemCardDatas[mc].vHighScores[l].iScore ); - FileWrite( f, pNotes->m_MemCardDatas[mc].vHighScores[l].fPercentDP ); + FileWrite( f, pNotes->m_MemCardDatas[slot].vHighScores[l].sName ); + FileWrite( f, pNotes->m_MemCardDatas[slot].vHighScores[l].grade ); + FileWrite( f, pNotes->m_MemCardDatas[slot].vHighScores[l].iScore ); + FileWrite( f, pNotes->m_MemCardDatas[slot].vHighScores[l].fPercentDP ); } } } @@ -949,7 +949,7 @@ void ProfileManager::SaveSongScoresToDir( CString sDir, MemoryCard mc ) return str; } */ -void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) +void ProfileManager::SaveStatsWebPageToDir( CString sDir, ProfileSlot slot ) { CString fn = sDir + STATS_HTML_FILE; @@ -958,10 +958,10 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) // Get Profile // Profile* pProfile; - if( mc == MEMORY_CARD_MACHINE ) + if( slot == PROFILE_SLOT_MACHINE ) pProfile = GetMachineProfile(); else - pProfile = GetProfile( (PlayerNumber)mc ); + pProfile = GetProfile( (PlayerNumber)slot ); ASSERT(pProfile); // @@ -1150,12 +1150,12 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) { unsigned uNumToShow = min( vpSongs.size(), (unsigned)100 ); - SortSongPointerArrayByMostPlayed( vpSongs, mc ); + SortSongPointerArrayByMostPlayed( vpSongs, slot ); PRINT_DIV_START( "Songs by Popularity" ); for( unsigned i=0; iGetFullDisplayTitle(), ssprintf("#%u",(unsigned)pSong).c_str(), pSong->GetNumTimesPlayed(mc) ); + PRINT_LINE_RANK_LINK( i+1, pSong->GetFullDisplayTitle(), ssprintf("#%u",(unsigned)pSong).c_str(), pSong->GetNumTimesPlayed(slot) ); } PRINT_DIV_END; } @@ -1164,7 +1164,7 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) { unsigned uNumToShow = min( vpAllSteps.size(), (unsigned)100 ); - SortStepsPointerArrayByMostPlayed( vpAllSteps, mc ); + SortStepsPointerArrayByMostPlayed( vpAllSteps, slot ); PRINT_DIV_START( "Steps by Popularity" ); for( unsigned i=0; iNotesTypeToString(pSteps->m_StepsType); s += " "; s += DifficultyToString(pSteps->GetDifficulty()); - PRINT_LINE_RANK_LINK( i+1, s, ssprintf("#%u",(unsigned)pSteps).c_str(), pSteps->GetNumTimesPlayed(mc) ); + PRINT_LINE_RANK_LINK( i+1, s, ssprintf("#%u",(unsigned)pSteps).c_str(), pSteps->GetNumTimesPlayed(slot) ); } PRINT_DIV_END; } @@ -1185,12 +1185,12 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) { unsigned uNumToShow = min( vpCourses.size(), (unsigned)100 ); - SortCoursePointerArrayByMostPlayed( vpCourses, mc ); + SortCoursePointerArrayByMostPlayed( vpCourses, slot ); PRINT_DIV_START( "Courses by Popularity" ); for( unsigned i=0; im_sName, ssprintf("#%u",(unsigned)pCourse).c_str(), pCourse->GetNumTimesPlayed(mc) ); + PRINT_LINE_RANK_LINK( i+1, pCourse->m_sName, ssprintf("#%u",(unsigned)pCourse).c_str(), pCourse->GetNumTimesPlayed(slot) ); } PRINT_DIV_END; } @@ -1240,13 +1240,13 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) if( pSteps ) { CString sHighScore; - if( !pSteps->m_MemCardDatas[mc].vHighScores.empty() ) + if( !pSteps->m_MemCardDatas[slot].vHighScores.empty() ) { - sHighScore += pSteps->m_MemCardDatas[mc].vHighScores[0].sName; + sHighScore += pSteps->m_MemCardDatas[slot].vHighScores[0].sName; sHighScore += "
"; - sHighScore += GradeToString( pSteps->m_MemCardDatas[mc].vHighScores[0].grade ); + sHighScore += GradeToString( pSteps->m_MemCardDatas[slot].vHighScores[0].grade ); sHighScore += "
"; - sHighScore += ssprintf("%d",pSteps->m_MemCardDatas[mc].vHighScores[0].iScore); + sHighScore += ssprintf("%d",pSteps->m_MemCardDatas[slot].vHighScores[0].iScore); } f.PutLine( ssprintf("

%s

", (unsigned)pSteps, // use pointer value as the hash @@ -1352,7 +1352,7 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) pSong->GetDisplayBPM( fMinBPM, fMaxBPM ); CString sBPM = (fMinBPM==fMaxBPM) ? ssprintf("%.1f",fMinBPM) : ssprintf("%.1f - %.1f",fMinBPM,fMaxBPM); PRINT_LINE_S( "BPM", sBPM ); - PRINT_LINE_I( "NumTimesPlayed", pSong->GetNumTimesPlayed(mc) ); + PRINT_LINE_I( "NumTimesPlayed", pSong->GetNumTimesPlayed(slot) ); PRINT_LINE_S( "Credit", pSong->m_sCredit ); PRINT_LINE_S( "MusicLength", SecondsToTime(pSong->m_fMusicLengthSeconds) ); PRINT_LINE_B( "Lyrics", !pSong->m_sLyricsFile.empty() ); @@ -1371,9 +1371,9 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc ) " - " + DifficultyToString(pSteps->GetDifficulty()); PRINT_DIV2_START_ANCHOR( /*Steps primary key*/pSteps, s.c_str() ); // use pointer value as the hash - PRINT_LINE_I( "NumTimesPlayed", pSteps->m_MemCardDatas[mc].iNumTimesPlayed ); + PRINT_LINE_I( "NumTimesPlayed", pSteps->m_MemCardDatas[slot].iNumTimesPlayed ); - vector& vHighScores = pSteps->m_MemCardDatas[mc].vHighScores; + vector& vHighScores = pSteps->m_MemCardDatas[slot].vHighScores; for( unsigned i=0; im_pCurCourse->m_MemCardDatas[st][mc].iNumTimesPlayed; } @@ -592,7 +592,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S if( !GAMESTATE->IsPlayerEnabled(p) ) continue; - m_DifficultyIcon[p].Load( THEME->GetPathToG("ScreenGameplay difficulty icons 2x5") ); + m_DifficultyIcon[p].Load( THEME->GetPathToG(ssprintf("ScreenGameplay difficulty icons 2x%d",NUM_DIFFICULTIES)) ); /* Position it in LoadNextSong. */ this->AddChild( &m_DifficultyIcon[p] ); @@ -873,7 +873,7 @@ void ScreenGameplay::LoadNextSong() * even if the people playing it aren't good at it.) */ if( !m_bDemonstration ) { - for( int mc = 0; mc < NUM_MEMORY_CARDS; ++mc ) + for( int mc = 0; mc < NUM_PROFILE_SLOTS; ++mc ) ++GAMESTATE->m_pCurNotes[p]->m_MemCardDatas[mc].iNumTimesPlayed; } diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index df8e6b61e9..06cd0f8e40 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -673,10 +673,10 @@ float ScreenRanking::SetPage( PageToShow pts ) { ProfileManager::CategoryData::HighScore hs; bool bRecentHighScore = false; - if( l < (int)PROFILEMAN->m_CategoryDatas[MEMORY_CARD_MACHINE][pts.nt][pts.category].vHighScores.size() ) + if( l < (int)PROFILEMAN->m_CategoryDatas[PROFILE_SLOT_MACHINE][pts.nt][pts.category].vHighScores.size() ) { - hs = PROFILEMAN->m_CategoryDatas[MEMORY_CARD_MACHINE][pts.nt][pts.category].vHighScores[l]; - CString *psName = &PROFILEMAN->m_CategoryDatas[MEMORY_CARD_MACHINE][pts.nt][pts.category].vHighScores[l].sName; + hs = PROFILEMAN->m_CategoryDatas[PROFILE_SLOT_MACHINE][pts.nt][pts.category].vHighScores[l]; + CString *psName = &PROFILEMAN->m_CategoryDatas[PROFILE_SLOT_MACHINE][pts.nt][pts.category].vHighScores[l].sName; bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); } else @@ -714,10 +714,10 @@ float ScreenRanking::SetPage( PageToShow pts ) { Course::MemCardData::HighScore hs; bool bRecentHighScore = false; - if( l < (int)pts.pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores.size() ) + if( l < (int)pts.pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores.size() ) { - hs = pts.pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores[l]; - CString *psName = &pts.pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores[l].sName; + hs = pts.pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores[l]; + CString *psName = &pts.pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores[l].sName; bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); } else @@ -780,10 +780,10 @@ float ScreenRanking::SetPage( PageToShow pts ) { Steps::MemCardData::HighScore hs; bool bRecentHighScore = false; - if( !pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores.empty() ) + if( !pSteps->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores.empty() ) { - hs = pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores[0]; - const CString *psName = &pSteps->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores[0].sName; + hs = pSteps->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores[0]; + const CString *psName = &pSteps->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores[0].sName; bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); } else @@ -818,10 +818,10 @@ float ScreenRanking::SetPage( PageToShow pts ) Course::MemCardData::HighScore hs; bool bRecentHighScore = false; - if( !pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores.empty() ) + if( !pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores.empty() ) { - hs = pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores[0]; - const CString *psName = &pCourse->m_MemCardDatas[pts.nt][MEMORY_CARD_MACHINE].vHighScores[0].sName; + hs = pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores[0]; + const CString *psName = &pCourse->m_MemCardDatas[pts.nt][PROFILE_SLOT_MACHINE].vHighScores[0].sName; bRecentHighScore = find( GAMESTATE->m_vpsNamesThatWereFilled.begin(), GAMESTATE->m_vpsNamesThatWereFilled.end(), psName ) != GAMESTATE->m_vpsNamesThatWereFilled.end(); } else diff --git a/stepmania/src/ScreenSelectCourse.cpp b/stepmania/src/ScreenSelectCourse.cpp index 0316630a14..c76746ae64 100644 --- a/stepmania/src/ScreenSelectCourse.cpp +++ b/stepmania/src/ScreenSelectCourse.cpp @@ -416,7 +416,7 @@ void ScreenSelectCourse::AfterCourseChange() { const StepsType &st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; - int mc = MEMORY_CARD_MACHINE; + int mc = PROFILE_SLOT_MACHINE; if( PROFILEMAN->IsUsingProfile( (PlayerNumber)p ) ) mc = p; diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 06c8839023..be41c56323 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -241,7 +241,7 @@ ScreenSelectMusic::ScreenSelectMusic( CString sClassName ) : Screen( sClassName this->AddChild( &m_sprDifficultyFrame[p] ); m_DifficultyIcon[p].SetName( ssprintf("DifficultyIconP%d",p+1) ); - m_DifficultyIcon[p].Load( THEME->GetPathToG("ScreenSelectMusic difficulty icons 1x5") ); + m_DifficultyIcon[p].Load( THEME->GetPathToG(ssprintf("ScreenSelectMusic difficulty icons 1x%d",NUM_DIFFICULTIES)) ); SET_XY( m_DifficultyIcon[p] ); this->AddChild( &m_DifficultyIcon[p] ); @@ -1151,8 +1151,8 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn ) } else { - if( !pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores.empty() ) - iScore = pNotes->m_MemCardDatas[MEMORY_CARD_MACHINE].vHighScores[0].iScore; + if( !pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores.empty() ) + iScore = pNotes->m_MemCardDatas[PROFILE_SLOT_MACHINE].vHighScores[0].iScore; } m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); } @@ -1316,7 +1316,7 @@ void ScreenSelectMusic::AfterMusicChange() TEXTUREMAN->EnableOddDimensionWarning(); FlipSpriteHorizontally(m_sprCDTitleBack); - const vector best = SONGMAN->GetBestSongs( MEMORY_CARD_MACHINE ); + const vector best = SONGMAN->GetBestSongs( PROFILE_SLOT_MACHINE ); const int index = FindIndex( best.begin(), best.end(), pSong ); if( index != -1 ) m_MachineRank.SetText( ssprintf("%i", index+1) ); @@ -1416,7 +1416,7 @@ void ScreenSelectMusic::AfterMusicChange() } } - const vector best = SONGMAN->GetBestCourses( MEMORY_CARD_MACHINE ); + const vector best = SONGMAN->GetBestCourses( PROFILE_SLOT_MACHINE ); const int index = FindCourseIndexOfSameMode( best.begin(), best.end(), pCourse ); if( index != -1 ) m_MachineRank.SetText( ssprintf("%i", index+1) ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index f9ff953d8f..8f858d3fab 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -72,6 +72,7 @@ void SortBackgroundChangesArray( vector &arrayBackgroundChange ////////////////////////////// Song::Song() { + m_LoadedFromProfile = PROFILE_SLOT_INVALID; m_bChangedSinceSave = false; m_fMusicSampleStartSeconds = -1; m_fMusicSampleLengthSeconds = DEFAULT_MUSIC_SAMPLE_LENGTH; @@ -1114,7 +1115,7 @@ void Song::RemoveAutoGenNotes() } -Steps::MemCardData::HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, MemoryCard card, Difficulty dc ) +Steps::MemCardData::HighScore GetHighScoreForDifficulty( const Song *s, const StyleDef *st, ProfileSlot card, Difficulty dc ) { // return max grade of notes in difficulty class vector aNotes; @@ -1132,7 +1133,7 @@ Steps::MemCardData::HighScore GetHighScoreForDifficulty( const Song *s, const St bool Song::IsNew() const { - return GetNumTimesPlayed(MEMORY_CARD_MACHINE) == 0; + return GetNumTimesPlayed(PROFILE_SLOT_MACHINE) == 0; } bool Song::IsEasy( StepsType nt ) const @@ -1386,7 +1387,7 @@ bool CompareSongPointersBySortValueDescending(const Song *pSong1, const Song *pS return song_sort_val[pSong1] > song_sort_val[pSong2]; } -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, MemoryCard card ) +void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, ProfileSlot card ) { for(unsigned i = 0; i < arraySongPointers.size(); ++i) song_sort_val[arraySongPointers[i]] = ssprintf("%9i", arraySongPointers[i]->GetNumTimesPlayed(card)); @@ -1552,7 +1553,7 @@ bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(G bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); } bool Song::HasBGChanges() const {return !m_BackgroundChanges.empty(); } -int Song::GetNumTimesPlayed( MemoryCard card ) const +int Song::GetNumTimesPlayed( ProfileSlot card ) const { int iTotalNumTimesPlayed = 0; for( unsigned i=0; iGetTopScore(MEMORY_CARD_MACHINE).grade == g ) + if( pSteps->GetTopScore(PROFILE_SLOT_MACHINE).grade == g ) iCount++; } return iCount; @@ -1699,3 +1700,12 @@ bool Song::Matches(CString sGroup, CString sSong) const return false; } +void Song::FreeAllLoadedFromProfiles() +{ + for( unsigned s=0; sWasLoadedFromProfile() ) + this->RemoveNotes( pSteps ); + } +} diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 16f1402323..9d6e077e6a 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -31,6 +31,8 @@ #include "RageTextureManager.h" #include "Banner.h" #include "ProfileManager.h" +#include "MemoryCardManager.h" +#include "NotesLoaderSM.h" SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program @@ -45,6 +47,7 @@ CachedThemeMetricC EASY_COLOR ("SongManager","EasyColor"); CachedThemeMetricC MEDIUM_COLOR ("SongManager","MediumColor"); CachedThemeMetricC HARD_COLOR ("SongManager","HardColor"); CachedThemeMetricC CHALLENGE_COLOR ("SongManager","ChallengeColor"); +CachedThemeMetricC EDIT_COLOR ("SongManager","EditColor"); CachedThemeMetricC EXTRA_COLOR ("SongManager","ExtraColor"); CachedThemeMetricI EXTRA_COLOR_METER ("SongManager","ExtraColorMeter"); @@ -66,6 +69,7 @@ static void UpdateMetrics() MEDIUM_COLOR.Refresh(); HARD_COLOR.Refresh(); CHALLENGE_COLOR.Refresh(); + EDIT_COLOR.Refresh(); EXTRA_COLOR.Refresh(); EXTRA_COLOR_METER.Refresh(); } @@ -397,7 +401,8 @@ RageColor SongManager::GetDifficultyColor( Difficulty dc ) const case DIFFICULTY_MEDIUM: return MEDIUM_COLOR; case DIFFICULTY_HARD: return HARD_COLOR; case DIFFICULTY_CHALLENGE: return CHALLENGE_COLOR; - default: ASSERT(0); return CHALLENGE_COLOR; + case DIFFICULTY_EDIT: return EDIT_COLOR; + default: ASSERT(0); return EDIT_COLOR; } } @@ -777,6 +782,8 @@ Song* SongManager::GetSongFromDir( CString sDir ) if( sDir.Right(1) != "/" ) sDir += "/"; + sDir.Replace( '\\', '/' ); + for( unsigned int i=0; iGetSongDir()) == 0 ) return m_pSongs[i]; @@ -822,7 +829,7 @@ Course* SongManager::GetCourseFromName( CString sName ) Song *SongManager::FindSong( CString sPath ) { - sPath.Replace( "\\", "/" ); + sPath.Replace( '\\', '/' ); CStringArray bits; split( sPath, "/", bits ); @@ -860,13 +867,13 @@ Course *SongManager::FindCourse( CString sName ) void SongManager::UpdateBestAndShuffled() { // update players best - for( int i = 0; i < NUM_MEMORY_CARDS; ++i ) + for( int i = 0; i < NUM_PROFILE_SLOTS; ++i ) { m_pBestSongs[i] = m_pSongs; - SortSongPointerArrayByMostPlayed( m_pBestSongs[i], (MemoryCard) i ); + SortSongPointerArrayByMostPlayed( m_pBestSongs[i], (ProfileSlot) i ); m_pBestCourses[i] = m_pCourses; - SortCoursePointerArrayByMostPlayed( m_pBestCourses[i], (MemoryCard) i ); + SortCoursePointerArrayByMostPlayed( m_pBestCourses[i], (ProfileSlot) i ); } // update shuffled @@ -899,3 +906,43 @@ void SongManager::UpdateRankingCourses() } } +void SongManager::LoadAllFromProfiles() +{ + for( int s=0; sGetProfileDir( (ProfileSlot)s ); + if( sProfileDir.empty() ) + continue; // skip + // + // Load all edits. Edits are dangling .sm files in the Edits folder + // + { + CString sEditsDir = sProfileDir+"Edits/"; + CStringArray asEditsFilesWithPath; + GetDirListing( sEditsDir+"*.sm", asEditsFilesWithPath, false, true ); + + for( unsigned i=0; iFreeAllLoadedFromProfiles(); + } +} + diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 51eb52bf96..b5f6b7c606 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -36,6 +36,9 @@ public: void FreeSongs(); void Cleanup(); + void LoadAllFromProfiles(); // song, edits + void FreeAllLoadedFromProfiles(); + void LoadGroupSymLinks( CString sDir, CString sGroupFolder ); void InitCoursesFromDisk( LoadingWindow *ld ); @@ -61,8 +64,8 @@ public: // Lookup const vector &GetAllSongs() const { return m_pSongs; } - const vector &GetBestSongs( MemoryCard card=MEMORY_CARD_MACHINE ) const { return m_pBestSongs[MEMORY_CARD_MACHINE]; } - const vector &GetBestCourses( MemoryCard card=MEMORY_CARD_MACHINE ) const { return m_pBestCourses[MEMORY_CARD_MACHINE]; } + const vector &GetBestSongs( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestSongs[PROFILE_SLOT_MACHINE]; } + const vector &GetBestCourses( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[PROFILE_SLOT_MACHINE]; } void GetSongs( vector &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const; void GetSongs( vector &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); } void GetSongs( vector &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); } @@ -103,12 +106,12 @@ protected: Song *FindSong( CString sGroup, CString sSong ); vector m_pSongs; // all songs that can be played - vector m_pBestSongs[NUM_MEMORY_CARDS]; + vector m_pBestSongs[NUM_PROFILE_SLOTS]; vector m_pShuffledSongs; // used by GetRandomSong CStringArray m_sGroupNames; CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it vector m_pCourses; - vector m_pBestCourses[NUM_MEMORY_CARDS]; + vector m_pBestCourses[NUM_PROFILE_SLOTS]; vector m_pShuffledCourses; // used by GetRandomCourse }; diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 23e4a722f9..80458b4e26 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -36,7 +36,7 @@ Steps::Steps() * until after b6 to do this. -glenn */ /* Yep, it should be STEPS_TYPE_INVALID. -Chris */ m_StepsType = STEPS_TYPE_INVALID; - m_bIsAnEdit = false; + m_LoadedFromProfile = PROFILE_SLOT_INVALID; m_Difficulty = DIFFICULTY_INVALID; m_iMeter = 0; for(int i = 0; i < NUM_RADAR_CATEGORIES; ++i) @@ -127,7 +127,7 @@ float Steps::PredictMeter() const const float DifficultyCoeffs[NUM_DIFFICULTIES] = { - -0.877f, -0.877f, 0, 0.722f, 0.722f + -0.877f, -0.877f, 0, 0.722f, 0.722f, 0 }; pMeter += DifficultyCoeffs[this->GetDifficulty()]; @@ -233,7 +233,6 @@ void Steps::DeAutogen() Decompress(); // fills in notes with sliding window transform - m_bIsAnEdit = Real()->m_bIsAnEdit; m_sDescription = Real()->m_sDescription; m_Difficulty = Real()->m_Difficulty; m_iMeter = Real()->m_iMeter; @@ -287,12 +286,6 @@ bool Steps::IsAutogen() const return parent != NULL; } -void Steps::SetIsAnEdit(bool b) -{ - DeAutogen(); - m_bIsAnEdit = b; -} - void Steps::SetDescription(CString desc) { DeAutogen(); @@ -334,7 +327,7 @@ bool CompareStepsPointersBySortValueDescending(const Steps *pSteps1, const Steps return steps_sort_val[pSteps1] > steps_sort_val[pSteps2]; } -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, MemoryCard card ) +void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, ProfileSlot card ) { for(unsigned i = 0; i < vStepsPointers.size(); ++i) steps_sort_val[vStepsPointers[i]] = ssprintf("%9i", vStepsPointers[i]->GetNumTimesPlayed(card)); @@ -434,6 +427,6 @@ void Steps::AddHighScore( PlayerNumber pn, MemCardData::HighScore hs, int &iPers m_MemCardDatas[pn].AddHighScore( hs, iPersonalIndexOut ); else iPersonalIndexOut = -1; - m_MemCardDatas[MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut ); + m_MemCardDatas[PROFILE_SLOT_MACHINE].AddHighScore( hs, iMachineIndexOut ); } diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index 3e15821d3f..ab843a3abd 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -33,12 +33,14 @@ public: void Decompress() const; void DeAutogen(); /* If this Steps is autogenerated, make it a real Steps. */ + // Use a special value of difficulty + bool IsAnEdit() const { return m_Difficulty == DIFFICULTY_EDIT; } + bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } CString GetDescription() const { return Real()->m_sDescription; } Difficulty GetDifficulty() const { return Real()->m_Difficulty; } int GetMeter() const { return Real()->m_iMeter; } const float *GetRadarValues() const { return Real()->m_fRadarValues; } - void SetIsAnEdit(bool b); void SetDescription(CString desc); void SetDifficulty(Difficulty d); void SetMeter(int meter); @@ -91,18 +93,18 @@ public: return vHighScores[0]; } - } m_MemCardDatas[NUM_MEMORY_CARDS]; + } m_MemCardDatas[NUM_PROFILE_SLOTS]; void AddHighScore( PlayerNumber pn, MemCardData::HighScore hs, int &iPersonalIndexOut, int &iMachineIndexOut ); - MemCardData::HighScore GetTopScore( MemoryCard card ) + MemCardData::HighScore GetTopScore( ProfileSlot slot ) { - return m_MemCardDatas[card].GetTopScore(); + return m_MemCardDatas[slot].GetTopScore(); } - int GetNumTimesPlayed( MemoryCard card ) + int GetNumTimesPlayed( ProfileSlot slot ) { - return m_MemCardDatas[card].iNumTimesPlayed; + return m_MemCardDatas[slot].iNumTimesPlayed; } void TidyUpData(); @@ -125,7 +127,7 @@ protected: const Steps *Real() const; /* These values are pulled from the autogen source first, if there is one. */ - bool m_bIsAnEdit; // true if this was loaded from a memory card + ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile CString m_sDescription; // Step author, edit name, or something meaningful Difficulty m_Difficulty; // difficulty classification int m_iMeter; // difficulty rating from MIN_METER to MAX_METER @@ -139,6 +141,6 @@ bool CompareNotesPointersByDifficulty(const Steps *pNotes1, const Steps *pNotes2 void SortNotesArrayByDifficulty( vector &arrayNotess ); bool CompareStepsPointersByTypeAndDifficulty(const Steps *pStep1, const Steps *pStep2); void SortStepsByTypeAndDifficulty( vector &arraySongPointers ); -void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, MemoryCard card ); +void SortStepsPointerArrayByMostPlayed( vector &vStepsPointers, ProfileSlot slot ); #endif diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 1ded5acbcb..a57e43839d 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -94,7 +94,7 @@ public: CString m_sGroupName; - + ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile bool m_bChangedSinceSave; bool m_bIsSymLink; @@ -188,7 +188,7 @@ public: Steps* GetStepsByDescription( StepsType nt, CString sDescription, bool bIncludeAutoGen = true ) const; Steps* GetClosestNotes( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const; void GetEdits( vector& arrayAddTo, StepsType nt, bool bIncludeAutoGen = true ) const; - int GetNumTimesPlayed( MemoryCard card ) const; + int GetNumTimesPlayed( ProfileSlot slot ) const; bool IsNew() const; bool IsEasy( StepsType nt ) const; bool HasEdits( StepsType nt ) const; @@ -198,6 +198,9 @@ public: void AddNotes( Steps* pNotes ); // we are responsible for deleting the memory pointed to by pNotes! void RemoveNotes( const Steps* pNotes ); + + void FreeAllLoadedFromProfiles(); + bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } }; CString MakeSortString( CString s ); @@ -208,7 +211,7 @@ void SortSongPointerArrayByGrade( vector &arraySongPointers ); void SortSongPointerArrayByArtist( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndDifficulty( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndTitle( vector &arraySongPointers ); -void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, MemoryCard card ); +void SortSongPointerArrayByMostPlayed( vector &arraySongPointers, ProfileSlot slot ); void SortSongPointerArrayByMeter( vector &arraySongPointers, Difficulty dc ); CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so ); void SortSongPointerArrayBySectionName( vector &arraySongPointers, SongSortOrder so );