From b6eebd25179bdec42c9f4f7d88ed1223863fbebb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 8 Mar 2005 06:48:31 +0000 Subject: [PATCH] cache GetPath results, since it may call GetPathTo, which will skip if it reads from the disk (perhaps we need a ThemePath<> cache type, like ThemeMetric<>) --- stepmania/src/ScreenSelectMusic.cpp | 30 ++++++++++++++++++----------- stepmania/src/ScreenSelectMusic.h | 8 ++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 5a80c62890..2e55d454ad 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -38,7 +38,6 @@ const int NUM_SCORE_DIGITS = 9; #define SCORE_FRAME_SORT_CHANGE_COMMAND(i) THEME->GetMetricA(m_sName,ssprintf("ScoreFrameP%iSortChangeCommand", i+1)) static const ScreenMessage SM_AllowOptionsMenuRepeat = ScreenMessage(SM_User+1); -CString g_sFallbackCDTitlePath; static CString g_sCDTitlePath; static bool g_bWantFallbackCdTitle; @@ -82,8 +81,17 @@ void ScreenSelectMusic::Init() m_DisplayMode = GAMESTATE->IsCourseMode() ? DISPLAY_COURSES : DISPLAY_SONGS; /* Cache: */ - g_sFallbackCDTitlePath = THEME->GetPathG(m_sName,"fallback cdtitle"); - TEXTUREMAN->CacheTexture( g_sFallbackCDTitlePath ); + m_sSectionMusicPath = THEME->GetPathS(m_sName,"section music"); + m_sSortMusicPath = THEME->GetPathS(m_sName,"sort music"); + m_sRouletteMusicPath = THEME->GetPathS(m_sName,"roulette music"); + m_sRandomMusicPath = THEME->GetPathS(m_sName,"random music"); + m_sCourseMusicPath = THEME->GetPathS(m_sName,"course music"); + m_sFallbackCDTitlePath = THEME->GetPathG(m_sName,"fallback cdtitle"); + m_sBalloonMarathonPath = THEME->GetPathG(m_sName,"balloon marathon"); + m_sBalloonLongPath = THEME->GetPathG(m_sName,"balloon long"); + + + TEXTUREMAN->CacheTexture( m_sFallbackCDTitlePath ); if( GAMESTATE->m_pCurStyle == NULL ) RageException::Throw( "The Style has not been set. A theme must set the Style before loading ScreenSelectMusic." ); @@ -662,7 +670,7 @@ void ScreenSelectMusic::CheckBackgroundRequests() CString sCDTitlePath = sPath; if( sCDTitlePath.empty() || !IsAFile(sCDTitlePath) ) - sCDTitlePath = g_bWantFallbackCdTitle? g_sFallbackCDTitlePath:CString(""); + sCDTitlePath = g_bWantFallbackCdTitle? m_sFallbackCDTitlePath:CString(""); if( !sCDTitlePath.empty() ) { @@ -1453,7 +1461,7 @@ void ScreenSelectMusic::AfterMusicChange() { case TYPE_SECTION: g_sBannerPath = SONGMAN->GetGroupBannerPath( sGroup ); - m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"section music"); + m_sSampleMusicToPlay = m_sSectionMusicPath; break; case TYPE_SORT: bWantBanner = false; /* we load it ourself */ @@ -1463,7 +1471,7 @@ void ScreenSelectMusic::AfterMusicChange() m_Banner.LoadMode(); break; } - m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"sort music"); + m_sSampleMusicToPlay = m_sSortMusicPath; break; default: ASSERT(0); @@ -1537,14 +1545,14 @@ void ScreenSelectMusic::AfterMusicChange() if( pSong->m_fMusicLengthSeconds > PREFSMAN->m_fMarathonVerSongSeconds ) { m_sprBalloon.StopTweening(); - m_sprBalloon.Load( THEME->GetPathG(m_sName,"balloon marathon") ); + m_sprBalloon.Load( m_sBalloonMarathonPath ); SET_XY( m_sprBalloon ); COMMAND( m_sprBalloon, "Show" ); } else if( pSong->m_fMusicLengthSeconds > PREFSMAN->m_fLongVerSongSeconds ) { m_sprBalloon.StopTweening(); - m_sprBalloon.Load( THEME->GetPathG(m_sName,"balloon long") ); + m_sprBalloon.Load( m_sBalloonLongPath ); SET_XY( m_sprBalloon ); COMMAND( m_sprBalloon, "Show" ); } @@ -1585,10 +1593,10 @@ void ScreenSelectMusic::AfterMusicChange() switch( m_MusicWheel.GetSelectedType() ) { case TYPE_ROULETTE: - m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"roulette music"); + m_sSampleMusicToPlay = m_sRouletteMusicPath; break; case TYPE_RANDOM: - m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"random music"); + m_sSampleMusicToPlay = m_sRandomMusicPath; break; default: ASSERT(0); @@ -1610,7 +1618,7 @@ void ScreenSelectMusic::AfterMusicChange() pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyle()->m_StepsType ); - m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"course music"); + m_sSampleMusicToPlay = m_sCourseMusicPath; m_fSampleStartSeconds = 0; m_fSampleLengthSeconds = -1; diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index d13532941f..434dc5c822 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -85,6 +85,14 @@ protected: ThemeMetric ALIGN_MUSIC_BEATS; ThemeMetric CODES; + CString m_sSectionMusicPath; + CString m_sSortMusicPath; + CString m_sRouletteMusicPath; + CString m_sRandomMusicPath; + CString m_sCourseMusicPath; + CString m_sFallbackCDTitlePath; + CString m_sBalloonMarathonPath; + CString m_sBalloonLongPath; Sprite m_sprCharacterIcon[NUM_PLAYERS]; Sprite m_sprBannerMask;