diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 5e3f0862d5..3e014b3ea6 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -121,8 +121,10 @@ void Course::LoadFromCRSFile( CString sPath ) // handle the data if( 0 == stricmp(sValueName, "COURSE") ) + { m_sName = sParams[1]; - + m_sTranslitName = m_sName; + } else if( 0 == stricmp(sValueName, "REPEAT") ) { CString str = sParams[1]; diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 819460b5f2..3b6c0c67b3 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -44,9 +44,10 @@ class Course public: Course(); - bool m_bIsAutogen; // was this created by AutoGen? + bool m_bIsAutogen; // was this created by AutoGen? CString m_sPath; CString m_sName; + CString m_sTranslitName; // used for unlocks bool HasBanner() const; diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index 84c6d714e3..887867f52a 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -36,19 +36,26 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") for(int i=1; i <= THEME->GetMetricI("ScreenUnlock", "NumUnlocks"); i++) { // new unlock graphic - Unlocks[i].Load( THEME->GetPathToG(ssprintf("ScreenUnlock icon %d", i)) ); + Unlocks[i].Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) ); + // set graphic location Unlocks[i].SetName( ssprintf("Unlock%d",i) ); SET_XY( Unlocks[i] ); - Song *pSong = SONGMAN->FindSong("", THEME->GetMetric("ScreenUnlock", ssprintf("Unlock%dSong", i)) ); - if( pSong == NULL ) + // get pertaining songentry + SongEntry *pSong = GAMESTATE->m_pUnlockingSys->FindSong( + THEME->GetMetric("ScreenUnlock", + ssprintf("Unlock%dSong", i)) ); + + LOG->Trace("UnlockScreen: Searching for %s", THEME->GetMetric("ScreenUnlock", + ssprintf("Unlock%dSong", i)).c_str() ); + + if( pSong == NULL) continue; Unlocks[i].Command(IconCommand); - const bool SongIsLocked = GAMESTATE->m_pUnlockingSys->SongIsLocked( pSong ); - if ( !SongIsLocked ) + if ( !pSong->isLocked ) this->AddChild(&Unlocks[i]); } diff --git a/stepmania/src/UnlockSystem.cpp b/stepmania/src/UnlockSystem.cpp index 218118a361..fdea0b4010 100644 --- a/stepmania/src/UnlockSystem.cpp +++ b/stepmania/src/UnlockSystem.cpp @@ -50,6 +50,7 @@ bool UnlockSystem::CourseIsLocked( const Course *course ) if (p) { + p->isCourse = true; // updates flag here p->updateLocked(); if (!p->isLocked) tmp = "un"; @@ -91,14 +92,25 @@ bool UnlockSystem::SongIsRoulette( const Song *song ) return p && (p->m_iRouletteSeed != 0) ; } +SongEntry *UnlockSystem::FindSong( CString songname ) +{ + songname.MakeUpper(); + for(int i = 0; i < m_SongEntries.size(); i++) + if (songname == m_SongEntries[i].m_sSongName) + return &m_SongEntries[i]; + + return NULL; +} + SongEntry *UnlockSystem::FindCourse( const Course *pCourse ) { - CString CourseName = pCourse->m_sName; + CString CourseName = pCourse->m_sTranslitName; CourseName.MakeUpper(); for(unsigned i = 0; i < m_SongEntries.size(); i++) { + if( CourseName == m_SongEntries[i].m_sSongName ) return &m_SongEntries[i]; } @@ -106,7 +118,6 @@ SongEntry *UnlockSystem::FindCourse( const Course *pCourse ) return NULL; } - SongEntry *UnlockSystem::FindSong( const Song *pSong ) { /* Manual binary searches are a bad idea; they're insanely easy to get @@ -165,6 +176,7 @@ SongEntry::SongEntry() m_iRouletteSeed = 0; isLocked = true; + isCourse = false; } diff --git a/stepmania/src/UnlockSystem.h b/stepmania/src/UnlockSystem.h index af98ea1562..c4d7e6ab67 100644 --- a/stepmania/src/UnlockSystem.h +++ b/stepmania/src/UnlockSystem.h @@ -36,6 +36,7 @@ struct SongEntry int m_iRouletteSeed; bool isLocked; // cached locked tag + bool isCourse; // used for unlock screen SongEntry(); @@ -56,6 +57,9 @@ public: float ArcadePointsUntilNextUnlock(); float SongPointsUntilNextUnlock(); + SongEntry *FindSong( CString songname ); + // used for screen unlock + bool SongIsLocked( const Song *song ); bool CourseIsLocked( const Course *course ); @@ -74,6 +78,8 @@ public: float UnlockToasty(); bool RouletteUnlock( const Song *song ); + + void DebugPrint(); private: