diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index 1313a3d4fa..d87613dcd8 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -8,6 +8,10 @@ #include "FontManager.h" #include "Font.h" #include "CommonMetrics.h" +#include "GameState.h" +#include "song.h" +#include "Course.h" +#include "Style.h" static const CString SelectTypeNames[NUM_SELECT_TYPES] = { "SelectOne", @@ -29,6 +33,7 @@ StringToX( LayoutType ); #define PREPARE_ITEM_TEXT( s ) if( s!= "" ) { if( THEME_ITEMS ) s = THEME_OPTION_ITEM( s, false ); if( CAPITALIZE_ALL_OPTION_NAMES ) s.MakeUpper(); } +static CString OPTION_TITLE( CString s ) { return THEME->GetMetric("OptionTitles",s); } const CString NEXT_ROW_NAME = "NextRow"; @@ -106,6 +111,8 @@ void OptionRow::LoadMetrics( const CString &sType ) SHOW_UNDERLINES .Load(m_sType,"ShowUnderlines"); TWEEN_SECONDS .Load(m_sType,"TweenSeconds"); THEME_ITEMS .Load(m_sType,"ThemeItems"); + THEME_ITEMS .Load(m_sType,"ThemeItems"); + SHOW_BPM_IN_SPEED_TITLE .Load(m_sName,"ShowBpmInSpeedTitle"); FOREACH_PlayerNumber( p ) m_OptionIcons[p].Load( m_sType ); @@ -144,10 +151,54 @@ void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pH } } -void OptionRow::AfterImportOptions( - const CString &sTitle, - float fY - ) +CString OptionRow::GetRowTitle() const +{ + CString sLineName = m_RowDef.name; + CString sTitle = THEME_TITLES ? OPTION_TITLE(sLineName) : sLineName; + + // HACK: tack the BPM onto the name of the speed line + if( sLineName.CompareNoCase("speed")==0 ) + { + bool bShowBpmInSpeedTitle = SHOW_BPM_IN_SPEED_TITLE; + + if( GAMESTATE->m_pCurCourse ) + { + Trail* pTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber]; + const int iNumCourseEntries = pTrail->m_vEntries.size(); + if( iNumCourseEntries > MAX_COURSE_ENTRIES_BEFORE_VARIOUS ) + bShowBpmInSpeedTitle = false; + } + + if( bShowBpmInSpeedTitle ) + { + DisplayBpms bpms; + if( GAMESTATE->m_pCurSong ) + { + Song* pSong = GAMESTATE->m_pCurSong; + pSong->GetDisplayBpms( bpms ); + } + else if( GAMESTATE->m_pCurCourse ) + { + Course *pCourse = GAMESTATE->m_pCurCourse; + StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; + Trail* pTrail = pCourse->GetTrail( st ); + ASSERT( pTrail ); + pTrail->GetDisplayBpms( bpms ); + } + + if( bpms.IsSecret() ) + sTitle += ssprintf( " (??" "?)" ); /* split so gcc doesn't think this is a trigraph */ + else if( bpms.BpmIsConstant() ) + sTitle += ssprintf( " (%.0f)", bpms.GetMin() ); + else + sTitle += ssprintf( " (%.0f-%.0f)", bpms.GetMin(), bpms.GetMax() ); + } + } + + return sTitle; +} + +void OptionRow::AfterImportOptions( float fY ) { // Make all selections the same if bOneChoiceForAllPlayers if( m_RowDef.bOneChoiceForAllPlayers ) @@ -312,6 +363,7 @@ void OptionRow::AfterImportOptions( m_textTitle.LoadFromFont( THEME->GetPathF(m_sType,"title") ); + CString sTitle = GetRowTitle(); m_textTitle.SetText( sTitle ); m_textTitle.SetXY( LABELS_X, fY ); m_textTitle.RunCommands( LABELS_ON_COMMAND ); diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 5a1dd7143a..693ba265ce 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -86,13 +86,12 @@ public: void LoadExit(); void LoadOptionIcon( PlayerNumber pn, const CString &sText ); + CString GetRowTitle() const; + void ImportOptions( PlayerNumber pn ); int ExportOptions( PlayerNumber pn ); - void AfterImportOptions( - const CString &sTitle, - float fY - ); + void AfterImportOptions( float fY ); void DetachHandler(); void PositionUnderlines( PlayerNumber pn ); @@ -201,6 +200,8 @@ protected: ThemeMetric SHOW_UNDERLINES; ThemeMetric TWEEN_SECONDS; ThemeMetric THEME_ITEMS; + ThemeMetric THEME_TITLES; + ThemeMetric SHOW_BPM_IN_SPEED_TITLE; }; #endif diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 40e63cf39f..19dae5854c 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -10,12 +10,8 @@ #include "InputMapper.h" #include "ActorUtil.h" #include "ProfileManager.h" -#include "song.h" -#include "Course.h" -#include "Style.h" #include "ScreenDimensions.h" #include "Command.h" -#include "CommonMetrics.h" /* @@ -71,10 +67,6 @@ static CString EXPLANATION_X_NAME( size_t p ) { return ssprintf("ExplanationP% static CString EXPLANATION_Y_NAME( size_t p ) { return ssprintf("ExplanationP%dY",p+1); } static CString EXPLANATION_ON_COMMAND_NAME( size_t p ) { return ssprintf("ExplanationP%dOnCommand",p+1); } -static CString OPTION_TITLE( CString s ) -{ - return THEME->GetMetric("OptionTitles",s); -} static CString OPTION_EXPLANATION( CString s ) { return THEME->GetMetric("OptionExplanations",s); @@ -97,14 +89,12 @@ ScreenOptions::ScreenOptions( CString sClassName ) : ScreenWithMenuElements(sCla SCROLL_BAR_HEIGHT (m_sName,"ScrollBarHeight"), SCROLL_BAR_TIME (m_sName,"ScrollBarTime"), EXPLANATION_ZOOM (m_sName,"ExplanationZoom"), - SHOW_BPM_IN_SPEED_TITLE (m_sName,"ShowBpmInSpeedTitle"), FRAME_ON_COMMAND (m_sName,"FrameOnCommand"), FRAME_OFF_COMMAND (m_sName,"FrameOffCommand"), SHOW_EXIT_ROW (m_sName,"ShowExitRow"), SEPARATE_EXIT_ROW (m_sName,"SeparateExitRow"), SEPARATE_EXIT_ROW_Y (m_sName,"SeparateExitRowY"), - SHOW_EXPLANATIONS (m_sName,"ShowExplanations"), - THEME_TITLES (m_sName,"ThemeTitles") + SHOW_EXPLANATIONS (m_sName,"ShowExplanations") { m_fLockInputSecs = 0.0001f; // always lock for a tiny amount of time so that we throw away any queued inputs during the load. @@ -173,10 +163,7 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v CLAMP( pos, 0, NUM_ROWS_SHOWN-1 ); const float fY = ROW_Y.GetValue( pos ); - row.AfterImportOptions( - GetRowTitle( r ), - fY - ); + row.AfterImportOptions( fY ); } m_sprPage.Load( THEME->GetPathG(m_sName,"page") ); @@ -273,7 +260,6 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v for( int r=0; r<(int)m_Rows.size(); r++ ) // foreach row { GetExplanationText( r ); - GetRowTitle( r ); } // put focus on the first enabled row @@ -334,55 +320,6 @@ CString ScreenOptions::GetExplanationText( int iRow ) const return SHOW_EXPLANATIONS ? OPTION_EXPLANATION(sLineName) : ""; } -CString ScreenOptions::GetRowTitle( int iRow ) const -{ - OptionRow &row = *m_Rows[iRow]; - - CString sLineName = row.GetRowDef().name; - CString sTitle = THEME_TITLES ? OPTION_TITLE(sLineName) : sLineName; - - // HACK: tack the BPM onto the name of the speed line - if( sLineName.CompareNoCase("speed")==0 ) - { - bool bShowBpmInSpeedTitle = SHOW_BPM_IN_SPEED_TITLE; - - if( GAMESTATE->m_pCurCourse ) - { - Trail* pTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber]; - const int iNumCourseEntries = pTrail->m_vEntries.size(); - if( iNumCourseEntries > MAX_COURSE_ENTRIES_BEFORE_VARIOUS ) - bShowBpmInSpeedTitle = false; - } - - if( bShowBpmInSpeedTitle ) - { - DisplayBpms bpms; - if( GAMESTATE->m_pCurSong ) - { - Song* pSong = GAMESTATE->m_pCurSong; - pSong->GetDisplayBpms( bpms ); - } - else if( GAMESTATE->m_pCurCourse ) - { - Course *pCourse = GAMESTATE->m_pCurCourse; - StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; - Trail* pTrail = pCourse->GetTrail( st ); - ASSERT( pTrail ); - pTrail->GetDisplayBpms( bpms ); - } - - if( bpms.IsSecret() ) - sTitle += ssprintf( " (??" "?)" ); /* split so gcc doesn't think this is a trigraph */ - else if( bpms.BpmIsConstant() ) - sTitle += ssprintf( " (%.0f)", bpms.GetMin() ); - else - sTitle += ssprintf( " (%.0f-%.0f)", bpms.GetMin(), bpms.GetMax() ); - } - } - - return sTitle; -} - BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow ) { ASSERT_M( iRow < (int)m_Rows.size(), ssprintf("%i < %i", iRow, (int)m_Rows.size() ) ); diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index 7007792cc5..77fa96a13f 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -38,7 +38,6 @@ protected: void InitOptionsText(); void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); CString GetExplanationText( int row ) const; - CString GetRowTitle( int row ) const; BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow ); void PositionUnderlines( int row, PlayerNumber pn ); void PositionAllUnderlines(); @@ -134,14 +133,12 @@ protected: ThemeMetric SCROLL_BAR_HEIGHT; ThemeMetric SCROLL_BAR_TIME; ThemeMetric EXPLANATION_ZOOM; - ThemeMetric SHOW_BPM_IN_SPEED_TITLE; ThemeMetric FRAME_ON_COMMAND; ThemeMetric FRAME_OFF_COMMAND; ThemeMetric SHOW_EXIT_ROW; ThemeMetric SEPARATE_EXIT_ROW; ThemeMetric SEPARATE_EXIT_ROW_Y; ThemeMetric SHOW_EXPLANATIONS; - ThemeMetric THEME_TITLES; float m_fLockInputSecs; };