diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index d114feeebe..6c8c299d12 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -9,6 +9,7 @@ DefaultCpuModifiers= JoinPauseSeconds=0.8 DifficultiesToShow=beginner,easy,medium,hard,challenge CourseDifficultiesToShow=easy,regular,difficult +StepsTypesToHide=dance-couple,dance-solo,pump-halfdouble,lights-cabinet ScreenWidth=640 ScreenHeight=480 OverlayScreens=ScreenSystemLayer @@ -3323,7 +3324,6 @@ Class=ScreenRanking Fallback=ScreenAttract NextScreen=ScreenUnlock TimerSeconds=-1 - StepsTypesToHide=dance-couple,dance-solo,pump-halfdouble ShowCategories=1 CoursesToShow=Courses/DDRMAX/NaokiStandard.crs,Courses/DDRMAX/ParanoiaBrothers.crs,Courses/Samples/PlayersBest1-4.crs @@ -4237,34 +4237,6 @@ ShowStyleDouble=1 ShowStyleCouple=1 ShowStyleSolo=1 ShowStyleReal=1 -ShowStepsTypeDance-single=1 -ShowStepsTypeDance-double=1 -ShowStepsTypeDance-couple=1 -ShowStepsTypeDance-solo=1 -ShowStepsTypePump-single=1 -ShowStepsTypePump-halfdouble=1 -ShowStepsTypePump-double=1 -ShowStepsTypePump-couple=1 -ShowStepsTypeEz2-single=1 -ShowStepsTypeEz2-double=1 -ShowStepsTypeEz2-real=1 -ShowStepsTypePara-single=1 -ShowStepsTypePara-versus=1 -ShowStepsTypeDs3ddx-single=1 -ShowStepsTypeBm-single5=1 -ShowStepsTypeBm-double5=1 -ShowStepsTypeBm-single7=1 -ShowStepsTypeBm-double7=1 -ShowStepsTypeManiax-single=1 -ShowStepsTypeManiax-double=1 -ShowStepsTypeTechno-single4=1 -ShowStepsTypeTechno-single5=1 -ShowStepsTypeTechno-single8=1 -ShowStepsTypeTechno-double4=1 -ShowStepsTypeTechno-double5=1 -ShowStepsTypePnm-five=1 -ShowStepsTypePnm-nine=1 -ShowStepsTypeLights-cabinet=1 InternetRankingHomeUrl= InternetRankingUploadUrl= InternetRankingViewGuidUrl= @@ -4286,9 +4258,6 @@ SortLevel5Color=0,1,0,1 [Inventory] ItemUseRateSeconds=0 -[OptionRowHandler] -StepsTypesToHide= - [ScreenMemcardSaveEditsAfterDeleteSteps] [ScreenMemcardSaveEditsAfterSave] diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index faf2e90de5..09e1b4a8d8 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -22,7 +22,6 @@ #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str())) #define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str())) -#define SHOW_STEPS_TYPE(st) THEME->GetMetricB("CatalogXml",ssprintf("ShowStepsType%s",Capitalize(GAMEMAN->StepsTypeToString(st)).c_str())) #define INTERNET_RANKING_HOME_URL THEME->GetMetric ("CatalogXml","InternetRankingHomeUrl") #define INTERNET_RANKING_UPLOAD_URL THEME->GetMetric ("CatalogXml","InternetRankingUploadUrl") #define INTERNET_RANKING_VIEW_GUID_URL THEME->GetMetric ("CatalogXml","InternetRankingViewGuidUrl") @@ -39,11 +38,9 @@ void SaveCatalogXml() XNode xml; xml.m_sName = "Catalog"; - { - bool ShowStepsType[NUM_STEPS_TYPES]; - FOREACH_StepsType( st ) - ShowStepsType[st] = SHOW_STEPS_TYPE( st ); + const vector &vStepsTypesToShow = STEPS_TYPES_TO_SHOW.GetValue(); + { XNode* pNode = xml.AppendChild( "Songs" ); vector vpSongs = SONGMAN->GetAllSongs(); @@ -64,16 +61,11 @@ void SaveCatalogXml() pSongNode->AppendChild( "MainTitle", pSong->GetDisplayMainTitle() ); pSongNode->AppendChild( "SubTitle", pSong->GetDisplaySubTitle() ); - const set &vDiffs = CommonMetrics::GetDifficultiesToShow(); - - FOREACH_StepsType( st ) + FOREACH_CONST( StepsType, vStepsTypesToShow, st ) { - if( !ShowStepsType[st] ) - continue; // skip - - for( set::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), dc ) { - Steps* pSteps = pSong->GetStepsByDifficulty( st, *iter, false ); // no autogen + Steps* pSteps = pSong->GetStepsByDifficulty( *st, *dc, false ); // no autogen if( pSteps == NULL ) continue; // skip @@ -111,16 +103,13 @@ void SaveCatalogXml() pCourseNode->AppendChild( "SubTitle", pCourse->GetDisplaySubTitle() ); pCourseNode->AppendChild( "HasMods", pCourse->HasMods() ); - const set &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); + const vector &vDiffs = DIFFICULTIES_TO_SHOW.GetValue(); - FOREACH_StepsType( st ) + FOREACH_CONST( StepsType, vStepsTypesToShow, st ) { - if( !SHOW_STEPS_TYPE(st) ) - continue; // skip - - for( set::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ ) + FOREACH_CONST( CourseDifficulty, vDiffs, dc ) { - Trail *pTrail = pCourse->GetTrail( st, *iter ); + Trail *pTrail = pCourse->GetTrail( *st, *dc ); if( pTrail == NULL ) continue; if( !pTrail->m_vEntries.size() ) @@ -143,8 +132,7 @@ void SaveCatalogXml() XNode* pNode = xml.AppendChild( "Types" ); { - const set &vDiffs = CommonMetrics::GetDifficultiesToShow(); - FOREACHS_CONST( Difficulty, vDiffs, iter ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter ) { XNode* pNode2 = pNode->AppendChild( "Difficulty", DifficultyToString(*iter) ); pNode2->AppendAttr( "DisplayAs", DifficultyToThemedString(*iter) ); @@ -152,8 +140,7 @@ void SaveCatalogXml() } { - const set &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); - FOREACHS_CONST( CourseDifficulty, vDiffs, iter ) + FOREACH_CONST( CourseDifficulty, COURSE_DIFFICULTIES_TO_SHOW.GetValue(), iter ) { XNode* pNode2 = pNode->AppendChild( "CourseDifficulty", CourseDifficultyToString(*iter) ); pNode2->AppendAttr( "DisplayAs", CourseDifficultyToThemedString(*iter) ); @@ -161,12 +148,10 @@ void SaveCatalogXml() } { - vector vStepsTypes; - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypes ); - FOREACH_CONST( StepsType, vStepsTypes, iter ) + vector vStepsTypesToShow; + GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypesToShow ); + FOREACH_CONST( StepsType, vStepsTypesToShow, iter ) { - if( !SHOW_STEPS_TYPE(*iter) ) - continue; XNode* pNode2 = pNode->AppendChild( "StepsType", GAMEMAN->StepsTypeToString(*iter) ); pNode2->AppendAttr( "DisplayAs", GAMEMAN->StepsTypeToThemedString(*iter) ); } diff --git a/stepmania/src/CommonMetrics.cpp b/stepmania/src/CommonMetrics.cpp index 9cdfc31f2f..a21299c2af 100644 --- a/stepmania/src/CommonMetrics.cpp +++ b/stepmania/src/CommonMetrics.cpp @@ -2,6 +2,9 @@ #include "CommonMetrics.h" #include "RageUtil.h" #include "Foreach.h" +#include "GameManager.h" +#include "RageLog.h" +#include "GameState.h" CString PLAYER_COLOR_NAME( size_t p ) { return ssprintf("ColorP%d",int(p+1)); } @@ -16,64 +19,97 @@ ThemeMetric WINDOW_TITLE ("Common","WindowTitle"); ThemeMetric HOME_EDIT_MODE ("Common","HomeEditMode"); ThemeMetric MAX_COURSE_ENTRIES_BEFORE_VARIOUS ("Common","MaxCourseEntriesBeforeShowVarious"); ThemeMetric TICK_EARLY_SECONDS ("ScreenGameplay","TickEarlySeconds"); +ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW ("Common","DifficultiesToShow"); +ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW ("Common","CourseDifficultiesToShow"); +ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW ("Common","StepsTypesToHide"); -class ThemeMetricDifficultiesToShow : ThemeMetric +ThemeMetricDifficultiesToShow::ThemeMetricDifficultiesToShow( const CString& sGroup, const CString& sName ) : + ThemeMetric(sGroup,sName) { -public: - set m_v; - - ThemeMetricDifficultiesToShow() : ThemeMetric("Common","DifficultiesToShow") {} - void Read() - { - ThemeMetric::Read(); - - m_v.clear(); - - CStringArray v; - split( GetValue(), ",", v ); - ASSERT( v.size() > 0 ); - - FOREACH_CONST( CString, v, i ) - { - Difficulty d = StringToDifficulty( *i ); - if( d == DIFFICULTY_INVALID ) - RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); - m_v.insert( d ); - } - } -}; -ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW; -const set& CommonMetrics::GetDifficultiesToShow() { return DIFFICULTIES_TO_SHOW.m_v; } - - -class ThemeMetricCourseDifficultiesToShow : ThemeMetric + ASSERT( sName.Right(6) == "ToShow" ); +} +void ThemeMetricDifficultiesToShow::Read() { -public: - set m_v; + ThemeMetric::Read(); - ThemeMetricCourseDifficultiesToShow() : ThemeMetric("Common","CourseDifficultiesToShow") {} - void Read() + m_v.clear(); + + CStringArray v; + split( ThemeMetric::GetValue(), ",", v ); + ASSERT( v.size() > 0 ); + + FOREACH_CONST( CString, v, i ) { - ThemeMetric::Read(); - - m_v.clear(); - - CStringArray v; - split( GetValue(), ",", v ); - ASSERT( v.size() > 0 ); - - FOREACH_CONST( CString, v, i ) - { - CourseDifficulty d = StringToCourseDifficulty( *i ); - if( d == DIFFICULTY_INVALID ) - RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); - m_v.insert( d ); - } + Difficulty d = StringToDifficulty( *i ); + if( d == DIFFICULTY_INVALID ) + RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); + m_v.push_back( d ); } -}; -ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW; -const set& CommonMetrics::GetCourseDifficultiesToShow() { return COURSE_DIFFICULTIES_TO_SHOW.m_v; } +} +const vector& ThemeMetricDifficultiesToShow::GetValue() { return m_v; } + + +ThemeMetricCourseDifficultiesToShow::ThemeMetricCourseDifficultiesToShow( const CString& sGroup, const CString& sName ) : + ThemeMetric(sGroup,sName) +{ + ASSERT( sName.Right(6) == "ToShow" ); +} +void ThemeMetricCourseDifficultiesToShow::Read() +{ + ThemeMetric::Read(); + + m_v.clear(); + + CStringArray v; + split( ThemeMetric::GetValue(), ",", v ); + ASSERT( v.size() > 0 ); + + FOREACH_CONST( CString, v, i ) + { + CourseDifficulty d = StringToCourseDifficulty( *i ); + if( d == DIFFICULTY_INVALID ) + RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); + m_v.push_back( d ); + } +} +const vector& ThemeMetricCourseDifficultiesToShow::GetValue() { return m_v; } + + +static void RemoveStepsTypes( vector& inout, CString sStepsTypesToRemove ) +{ + CStringArray v; + split( sStepsTypesToRemove, ",", v ); + ASSERT( v.size() > 0 ); + + // subtract StepsTypes + FOREACH_CONST( CString, v, i ) + { + StepsType st = GameManager::StringToStepsType(*i); + if( st == STEPS_TYPE_INVALID ) + LOG->Warn( "Invalid StepsType value '%s' in '%s'", i->c_str(), sStepsTypesToRemove.c_str() ); + + const vector::iterator iter = find( inout.begin(), inout.end(), st ); + if( iter != inout.end() ) + inout.erase( iter ); + } +} +ThemeMetricStepsTypesToShow::ThemeMetricStepsTypesToShow( const CString& sGroup, const CString& sName ) : + ThemeMetric(sGroup,sName) +{ + ASSERT( sName.Right(6) == "ToHide" ); +} +void ThemeMetricStepsTypesToShow::Read() +{ + ThemeMetric::Read(); + + m_v.clear(); + GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_v ); + + RemoveStepsTypes( m_v, ThemeMetric::GetValue() ); +} +const vector& ThemeMetricStepsTypesToShow::GetValue() { return m_v; } + CString THEME_OPTION_ITEM( CString s, bool bOptional ) { diff --git a/stepmania/src/CommonMetrics.h b/stepmania/src/CommonMetrics.h index c12490db44..cbbeb191f3 100644 --- a/stepmania/src/CommonMetrics.h +++ b/stepmania/src/CommonMetrics.h @@ -6,7 +6,44 @@ #include "ThemeMetric.h" #include "PlayerNumber.h" #include "Difficulty.h" +#include "GameConstantsAndTypes.h" + +// +// Types +// +class ThemeMetricDifficultiesToShow : ThemeMetric +{ +public: + ThemeMetricDifficultiesToShow( const CString& sGroup, const CString& sName ); + void Read(); + const vector &GetValue(); +private: + vector m_v; +}; +class ThemeMetricCourseDifficultiesToShow : ThemeMetric +{ +public: + ThemeMetricCourseDifficultiesToShow( const CString& sGroup, const CString& sName ); + void Read(); + const vector &GetValue(); +private: + vector m_v; +}; +class ThemeMetricStepsTypesToShow : ThemeMetric +{ +public: + ThemeMetricStepsTypesToShow( const CString& sGroup, const CString& sName ); + void Read(); + const vector &GetValue(); +private: + vector m_v; +}; + + +// +// Metrics +// extern ThemeMetric INITIAL_SCREEN; extern ThemeMetric FIRST_RUN_INITIAL_SCREEN; extern ThemeMetric DEFAULT_MODIFIERS; @@ -17,14 +54,12 @@ extern ThemeMetric WINDOW_TITLE; extern ThemeMetric HOME_EDIT_MODE; extern ThemeMetric MAX_COURSE_ENTRIES_BEFORE_VARIOUS; extern ThemeMetric TICK_EARLY_SECONDS; +extern ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW; +extern ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW; +extern ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW; CString THEME_OPTION_ITEM( CString s, bool bOptional ); -namespace CommonMetrics -{ - const set& GetDifficultiesToShow(); - const set& GetCourseDifficultiesToShow(); -} #endif diff --git a/stepmania/src/DifficultyList.cpp b/stepmania/src/DifficultyList.cpp index 955f7b2b13..7451257679 100644 --- a/stepmania/src/DifficultyList.cpp +++ b/stepmania/src/DifficultyList.cpp @@ -286,9 +286,8 @@ void DifficultyList::SetFromGameState() // FIXME: This clamps to between the min and the max difficulty, but // it really should round to the nearest difficulty that's in // DIFFICULTIES_TO_SHOW. - const set &diffs = CommonMetrics::GetDifficultiesToShow(); unsigned i=0; - FOREACHS_CONST( Difficulty, diffs, d ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d ) { m_Rows.resize( m_Rows.size()+1 ); diff --git a/stepmania/src/EditMenu.cpp b/stepmania/src/EditMenu.cpp index d068639162..900fc694f7 100644 --- a/stepmania/src/EditMenu.cpp +++ b/stepmania/src/EditMenu.cpp @@ -121,7 +121,7 @@ EditMenu::EditMenu() // fill in data structures SONGMAN->GetGroupNames( m_sGroups ); - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_StepsTypes ); + m_StepsTypes = STEPS_TYPES_TO_SHOW.GetValue(); if( HOME_EDIT_MODE ) { m_vDifficulties.push_back( DIFFICULTY_EDIT ); diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 4740f9e158..1998ce39d6 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -33,6 +33,7 @@ #include "CommonMetrics.h" #include "Foreach.h" #include "LuaReference.h" +#include "CommonMetrics.h" #include #include @@ -1702,7 +1703,7 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc ) bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir ) { - const set &asDiff = CommonMetrics::GetDifficultiesToShow(); + const vector &v = DIFFICULTIES_TO_SHOW.GetValue(); Difficulty d = m_PreferredDifficulty[pn]; while( 1 ) @@ -1710,7 +1711,7 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir ) d = (Difficulty)(d+dir); if( d < 0 || d >= NUM_DIFFICULTIES ) return false; - if( asDiff.find(d) == asDiff.end() ) + if( find(v.begin(), v.end(), d) == v.end() ) continue; /* not available */ } @@ -1734,7 +1735,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) /* If we have a course selected, only choose among difficulties available in the course. */ const Course *pCourse = this->m_pCurCourse; - const set &asDiff = CommonMetrics::GetCourseDifficultiesToShow(); + const vector &v = COURSE_DIFFICULTIES_TO_SHOW.GetValue(); CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; while( 1 ) @@ -1742,7 +1743,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) cd = (CourseDifficulty)(cd+dir); if( cd < 0 || cd >= NUM_DIFFICULTIES ) return false; - if( asDiff.find(cd) == asDiff.end() ) + if( find(v.begin(),v.end(),cd) == v.end() ) continue; /* not available */ if( !pCourse || pCourse->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType, cd ) ) break; @@ -1753,8 +1754,8 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) bool GameState::IsCourseDifficultyShown( CourseDifficulty cd ) { - const set &asDiff = CommonMetrics::GetCourseDifficultiesToShow(); - return asDiff.find(cd) != asDiff.end(); + const vector &v = COURSE_DIFFICULTIES_TO_SHOW.GetValue(); + return find(v.begin(), v.end(), cd) != v.end(); } Difficulty GameState::GetEasiestNotesDifficulty() const diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index 371b7cbd5b..272368ead5 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -24,8 +24,6 @@ #define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1))) #define ENTRY_DEFAULT(s) THEME->GetMetric ("ScreenOptionsMaster",(s) + "Default") -#define STEPS_TYPES_TO_HIDE THEME->GetMetric ("OptionRowHandler","StepsTypesToHide") - static void SelectExactlyOne( int iSelection, vector &vbSelectedOut ) { for( int i=0; i<(int)vbSelectedOut.size(); i++ ) @@ -429,8 +427,6 @@ public: ASSERT( sParam.size() ); m_sName = sParam; - const set &vDifficulties = CommonMetrics::GetDifficultiesToShow(); - defOut.bOneChoiceForAllPlayers = true; defOut.name = "Difficulty"; Default.m_dc = DIFFICULTY_INVALID; @@ -443,7 +439,7 @@ public: ListEntries.push_back( mc ); } - FOREACHS_CONST( Difficulty, vDifficulties, d ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d ) { CString s = DifficultyToThemedString( *d ); @@ -864,21 +860,7 @@ public: defOut.m_bAllowThemeItems = false; // we theme the text ourself // calculate which StepsTypes to show - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_vStepsTypesToShow ); - - // subtract hidden StepsTypes - vector vsStepsTypesToHide; - split( STEPS_TYPES_TO_HIDE, ",", vsStepsTypesToHide, true ); - for( unsigned i=0; i::iterator iter = find( m_vStepsTypesToShow.begin(), m_vStepsTypesToShow.end(), st ); - if( iter != m_vStepsTypesToShow.end() ) - m_vStepsTypesToShow.erase( iter ); - } - } + m_vStepsTypesToShow = STEPS_TYPES_TO_SHOW.GetValue(); FOREACH_CONST( StepsType, m_vStepsTypesToShow, st ) { diff --git a/stepmania/src/ScreenEnding.cpp b/stepmania/src/ScreenEnding.cpp index d49a699ce0..e4528dfdaa 100644 --- a/stepmania/src/ScreenEnding.cpp +++ b/stepmania/src/ScreenEnding.cpp @@ -84,8 +84,7 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line ) if( GAMESTATE->IsCourseMode() ) { - const set &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); - FOREACHS_CONST( CourseDifficulty, vDiffs, iter ) + FOREACH_CONST( CourseDifficulty, COURSE_DIFFICULTIES_TO_SHOW.GetValue(), iter ) { fActual += pProfile->GetCoursesActual(st,*iter); fPossible += pProfile->GetCoursesPossible(st,*iter); @@ -93,8 +92,7 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line ) } else { - const set &vDiffs = CommonMetrics::GetDifficultiesToShow(); - FOREACHS_CONST( Difficulty, vDiffs, iter ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter ) { fActual += pProfile->GetSongsActual(st,*iter); fPossible += pProfile->GetSongsPossible(st,*iter); diff --git a/stepmania/src/ScreenJukebox.cpp b/stepmania/src/ScreenJukebox.cpp index 50950d371e..ea1fb82085 100644 --- a/stepmania/src/ScreenJukebox.cpp +++ b/stepmania/src/ScreenJukebox.cpp @@ -18,11 +18,10 @@ #include "PlayerState.h" #include "ProfileManager.h" #include "StatsManager.h" - -// HACK: This belongs in ScreenDemonstration -#define DIFFICULTIES_TO_SHOW THEME->GetMetric ("ScreenDemonstration","DifficultiesToShow") +#include "CommonMetrics.h" #define SHOW_COURSE_MODIFIERS THEME->GetMetricB("ScreenJukebox","ShowCourseModifiers") +static ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW_HERE("ScreenDemonstration","DifficultiesToShow"); REGISTER_SCREEN_CLASS( ScreenJukebox ); @@ -41,20 +40,15 @@ bool ScreenJukebox::SetSong( bool bDemonstration ) if ( vSongs.size() == 0 ) SONGMAN->GetSongs( vSongs, GAMESTATE->m_sPreferredSongGroup ); + // // Calculate what difficulties to show // - CStringArray asBits; vector vDifficultiesToShow; if( bDemonstration ) { - split( DIFFICULTIES_TO_SHOW, ",", asBits ); - for( unsigned i=0; i sShowDiffs; - split( DIFFICULTIES_TO_SHOW, ",", sShowDiffs, true ); - - for( vector::const_iterator iter = sShowDiffs.begin(); iter != sShowDiffs.end(); iter++ ) - { - m_vDiffsToShow.push_back( StringToDifficulty( *iter ) ); - } - } - // init Actors for all_steps { + const vector &v = DIFFICULTIES_TO_SHOW.GetValue(); FOREACH_Difficulty( d ) { - bool bShowThis = find(m_vDiffsToShow.begin(), m_vDiffsToShow.end(), d) != m_vDiffsToShow.end(); + bool bShowThis = find( v.begin(), v.end(), d ) != v.end(); if( !bShowThis ) continue; // skip @@ -273,34 +264,12 @@ void ScreenRanking::Init() m_ListCourseRowItems.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); } - // calculate which StepsTypes to show - vector aStepsTypesToShow; - { - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, aStepsTypesToShow ); - - // subtract hidden StepsTypes - { - vector asStepsTypesToHide; - split( STEPS_TYPES_TO_HIDE, ",", asStepsTypesToHide, true ); - for( unsigned i=0; i::iterator iter = find( aStepsTypesToShow.begin(), aStepsTypesToShow.end(), st ); - if( iter != aStepsTypesToShow.end() ) - aStepsTypesToShow.erase( iter ); - } - } - } - } - // // fill m_vPagesToShow // if( SHOW_CATEGORIES ) { - for( unsigned i=0; i asCoursePaths; split( COURSES_TO_SHOW, ",", asCoursePaths, true ); - for( unsigned i=0; iGetCourseFromPath( asCoursePaths[c] ); if( pts.pCourse == NULL ) continue; @@ -343,12 +312,12 @@ void ScreenRanking::Init() vector vpSongs = SONGMAN->GetAllSongs(); if( !vpSongs.empty() ) { - for( unsigned i=0; iGetAllCourses( courses, false ); if( !courses.empty() ) { - for( unsigned i=0; iAddChild( m_sprPageType ); SET_XY_AND_ON_COMMAND( m_sprPageType ); + for( int l=0; lSetHidden( !bShowDifficulty ); + if( bShowDifficulty ) + { + m_sprDifficulty[*iter]->Reset(); + m_sprDifficulty[*iter]->SetXY( DIFFICULTY_X(*iter), DIFFICULTY_Y ); + ON_COMMAND( m_sprDifficulty[*iter] ); + } + } + + m_ListScoreRowItems.SetHidden( !bShowStepsScore ); + if( bShowStepsScore ) + { + m_ListScoreRowItems.Reset(); + SET_XY_AND_ON_COMMAND( m_ListScoreRowItems ); + + vector vpActors; + for( unsigned i=0; im_sprSongFrame.Reset(); + pStepsScoreRowItems->m_sprSongFrame.SetXY( SONG_FRAME_OFFSET_X, SONG_FRAME_OFFSET_Y ); + pStepsScoreRowItems->m_sprSongFrame.SetUseZBuffer( true ); + ON_COMMAND( pStepsScoreRowItems->m_sprSongFrame ); + + pStepsScoreRowItems->m_textSongTitle.Reset(); + pStepsScoreRowItems->m_textSongTitle.SetXY( SONG_TITLE_OFFSET_X, SONG_TITLE_OFFSET_Y ); + pStepsScoreRowItems->m_textSongTitle.SetUseZBuffer( true ); + ON_COMMAND( pStepsScoreRowItems->m_textSongTitle ); + + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter ) { - m_textScores[l].Reset(); - m_textScores[l].SetXY( SCORE_X(l), SCORE_Y(l) ); - m_textScores[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - ON_COMMAND( m_textScores[l] ); - } - - m_textPoints[l].SetHidden( !bShowPoints ); - if( bShowPoints ) - { - m_textPoints[l].Reset(); - m_textPoints[l].SetXY( POINTS_X(l), POINTS_Y(l) ); - m_textPoints[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - ON_COMMAND( m_textPoints[l] ); - } - - m_textTime[l].SetHidden( !bShowTime ); - if( bShowTime ) - { - m_textTime[l].Reset(); - m_textTime[l].SetXY( TIME_X(l), TIME_Y(l) ); - m_textTime[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - ON_COMMAND( m_textTime[l] ); + pStepsScoreRowItems->m_textStepsScore[*iter].Reset(); + pStepsScoreRowItems->m_textStepsScore[*iter].SetXY( STEPS_SCORE_OFFSET_X(*iter), STEPS_SCORE_OFFSET_Y ); + pStepsScoreRowItems->m_textStepsScore[*iter].SetUseZBuffer( true ); + pStepsScoreRowItems->m_textStepsScore[*iter].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); + ON_COMMAND( pStepsScoreRowItems->m_textStepsScore[*iter] ); } } } + FOREACH_ShownCourseDifficulty(d) { - for( vector::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) + m_sprCourseDifficulty[d]->SetHidden( !bShowCourseDifficulty ); + if( bShowCourseDifficulty ) { - m_sprDifficulty[*dc_iter]->SetHidden( !bShowDifficulty ); - if( bShowDifficulty ) - { - m_sprDifficulty[*dc_iter]->Reset(); - m_sprDifficulty[*dc_iter]->SetXY( DIFFICULTY_X(*dc_iter), DIFFICULTY_Y ); - ON_COMMAND( m_sprDifficulty[*dc_iter] ); - } - } - - m_ListScoreRowItems.SetHidden( !bShowStepsScore ); - if( bShowStepsScore ) - { - m_ListScoreRowItems.Reset(); - SET_XY_AND_ON_COMMAND( m_ListScoreRowItems ); - - vector vpActors; - for( unsigned i=0; im_sprSongFrame.Reset(); - pStepsScoreRowItems->m_sprSongFrame.SetXY( SONG_FRAME_OFFSET_X, SONG_FRAME_OFFSET_Y ); - pStepsScoreRowItems->m_sprSongFrame.SetUseZBuffer( true ); - ON_COMMAND( pStepsScoreRowItems->m_sprSongFrame ); - - pStepsScoreRowItems->m_textSongTitle.Reset(); - pStepsScoreRowItems->m_textSongTitle.SetXY( SONG_TITLE_OFFSET_X, SONG_TITLE_OFFSET_Y ); - pStepsScoreRowItems->m_textSongTitle.SetUseZBuffer( true ); - ON_COMMAND( pStepsScoreRowItems->m_textSongTitle ); - - for( vector::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) - { - pStepsScoreRowItems->m_textStepsScore[*dc_iter].Reset(); - pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetXY( STEPS_SCORE_OFFSET_X(*dc_iter), STEPS_SCORE_OFFSET_Y ); - pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetUseZBuffer( true ); - pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - ON_COMMAND( pStepsScoreRowItems->m_textStepsScore[*dc_iter] ); - } - } + m_sprCourseDifficulty[d]->Reset(); + m_sprCourseDifficulty[d]->SetXY( COURSE_DIFFICULTY_X(d), COURSE_DIFFICULTY_Y ); + ON_COMMAND( m_sprCourseDifficulty[d] ); } } + m_ListCourseRowItems.SetHidden( !bShowCourseScore ); + if( bShowCourseScore ) { - FOREACH_ShownCourseDifficulty(d) + m_ListCourseRowItems.Reset(); + SET_XY_AND_ON_COMMAND( m_ListCourseRowItems ); + + vector vpActors; + for( unsigned i=0; iSetHidden( !bShowCourseDifficulty ); - if( bShowCourseDifficulty ) - { - m_sprCourseDifficulty[d]->Reset(); - m_sprCourseDifficulty[d]->SetXY( COURSE_DIFFICULTY_X(d), COURSE_DIFFICULTY_Y ); - ON_COMMAND( m_sprCourseDifficulty[d] ); - } + m_ListCourseRowItems.SetCurrentItem( 0 ); + m_ListCourseRowItems.SetDestinationItem( 0 ); } - m_ListCourseRowItems.SetHidden( !bShowCourseScore ); - if( bShowCourseScore ) + for( unsigned s=0; sm_sprSongFrame.Reset(); + pCourseScoreRowItem->m_sprSongFrame.SetXY( SONG_FRAME_OFFSET_X, SONG_FRAME_OFFSET_Y ); + pCourseScoreRowItem->m_sprSongFrame.SetUseZBuffer( true ); + ON_COMMAND( pCourseScoreRowItem->m_sprSongFrame ); - vector vpActors; - for( unsigned i=0; im_textSongTitle.Reset(); + pCourseScoreRowItem->m_textSongTitle.SetXY( SONG_TITLE_OFFSET_X, SONG_TITLE_OFFSET_Y ); + pCourseScoreRowItem->m_textSongTitle.SetUseZBuffer( true ); + ON_COMMAND( pCourseScoreRowItem->m_textSongTitle ); - if( (bool)MANUAL_SCROLLING ) + FOREACH_ShownCourseDifficulty(d) { - m_ListCourseRowItems.SetCurrentItem( 0 ); - m_ListCourseRowItems.SetDestinationItem( 0 ); - } - - for( unsigned s=0; sm_sprSongFrame.Reset(); - pCourseScoreRowItem->m_sprSongFrame.SetXY( SONG_FRAME_OFFSET_X, SONG_FRAME_OFFSET_Y ); - pCourseScoreRowItem->m_sprSongFrame.SetUseZBuffer( true ); - ON_COMMAND( pCourseScoreRowItem->m_sprSongFrame ); - - pCourseScoreRowItem->m_textSongTitle.Reset(); - pCourseScoreRowItem->m_textSongTitle.SetXY( SONG_TITLE_OFFSET_X, SONG_TITLE_OFFSET_Y ); - pCourseScoreRowItem->m_textSongTitle.SetUseZBuffer( true ); - ON_COMMAND( pCourseScoreRowItem->m_textSongTitle ); - - FOREACH_ShownCourseDifficulty(d) - { - pCourseScoreRowItem->m_textStepsScore[d].Reset(); - pCourseScoreRowItem->m_textStepsScore[d].SetXY( COURSE_SCORE_OFFSET_X(d), COURSE_SCORE_OFFSET_Y ); - pCourseScoreRowItem->m_textStepsScore[d].SetUseZBuffer( true ); - pCourseScoreRowItem->m_textStepsScore[d].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); - ON_COMMAND( pCourseScoreRowItem->m_textStepsScore[d] ); - } + pCourseScoreRowItem->m_textStepsScore[d].Reset(); + pCourseScoreRowItem->m_textStepsScore[d].SetXY( COURSE_SCORE_OFFSET_X(d), COURSE_SCORE_OFFSET_Y ); + pCourseScoreRowItem->m_textStepsScore[d].SetUseZBuffer( true ); + pCourseScoreRowItem->m_textStepsScore[d].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); + ON_COMMAND( pCourseScoreRowItem->m_textStepsScore[d] ); } } } - + // get ranking feat list @@ -835,10 +798,10 @@ float ScreenRanking::SetPage( PageToShow pts ) pStepsScoreRowItem->m_textSongTitle.SetText( pSong->GetFullDisplayTitle() ); - for( vector::iterator dc_iter = m_vDiffsToShow.begin(); dc_iter != m_vDiffsToShow.end(); dc_iter++ ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter ) { - const Steps* pSteps = pSong->GetStepsByDifficulty( pts.nt, *dc_iter, false ); - BitmapText* pTextStepsScore = &pStepsScoreRowItem->m_textStepsScore[*dc_iter]; + const Steps* pSteps = pSong->GetStepsByDifficulty( pts.nt, *iter, false ); + BitmapText* pTextStepsScore = &pStepsScoreRowItem->m_textStepsScore[*iter]; if( pSteps == NULL ) { @@ -934,10 +897,10 @@ void ScreenRanking::TweenPageOffScreen() OFF_COMMAND( m_textPoints[l] ); OFF_COMMAND( m_textTime[l] ); } - for( vector::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter ) { - if( !m_sprDifficulty[*dc_iter]->GetHidden() ) - OFF_COMMAND( m_sprDifficulty[*dc_iter] ); + if( !m_sprDifficulty[*iter]->GetHidden() ) + OFF_COMMAND( m_sprDifficulty[*iter] ); } FOREACH_ShownCourseDifficulty(d) { diff --git a/stepmania/src/ScreenRanking.h b/stepmania/src/ScreenRanking.h index 1bc80692d7..fd3067dbf4 100644 --- a/stepmania/src/ScreenRanking.h +++ b/stepmania/src/ScreenRanking.h @@ -10,6 +10,7 @@ #include "ActorUtil.h" #include "Difficulty.h" #include "ThemeMetric.h" +#include "CommonMetrics.h" class Course; class Song; @@ -102,14 +103,15 @@ protected: ListDisplay m_ListCourseRowItems; vector m_vPagesToShow; - vector m_vDiffsToShow; + // Don't use the version in CommonMetrics because we may have multiple + // ranking screens that want to show different types and difficulties. + ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW; + ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW; - ThemeMetric STEPS_TYPES_TO_HIDE; ThemeMetric SHOW_CATEGORIES; ThemeMetric SHOW_ALL_STEPS_SCORES; ThemeMetric SHOW_ALL_COURSE_SCORES; - ThemeMetric DIFFICULTIES_TO_SHOW; ThemeMetric SECONDS_PER_PAGE; ThemeMetric PAGE_FADE_SECONDS; ThemeMetric PERCENT_DECIMAL_PLACES;