From 7a9796f769da79818e138ebf7e0acb9843d31f80 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Fri, 1 Apr 2011 01:35:14 -0400 Subject: [PATCH] Add metrics for BPM and Song Length sorting. Fixes request 173. --- Themes/_fallback/metrics.ini | 3 +++ src/SongUtil.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 72a53b7a53..58d1b6d53d 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -843,6 +843,9 @@ ShowRoulette=true ShowRandom=false ShowPortal=false # +SortBPMDivision=20 +SortLengthDivision=5 +# MostPlayedSongsToShow=30 RecentSongsToShow=30 # diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index d221159346..2641f860f0 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -19,6 +19,9 @@ #include "LuaBinding.h" #include "EnumHelper.h" +ThemeMetric SORT_BPM_DIVISION ( "MusicWheel", "SortBPMDivision" ); +ThemeMetric SORT_LENGTH_DIVISION ( "MusicWheel", "SortLengthDivision" ); + bool SongCriteria::Matches( const Song *pSong ) const { if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName ) @@ -595,8 +598,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so return SORT_NOT_AVAILABLE.GetValue(); case SORT_BPM: { - // todo: make this a theme metric? -aj - const int iBPMGroupSize = 20; + const int iBPMGroupSize = SORT_BPM_DIVISION; DisplayBpms bpms; pSong->GetDisplayBpms( bpms ); int iMaxBPM = (int)bpms.GetMax(); @@ -605,8 +607,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so } case SORT_LENGTH: { - // todo: make this a theme metric? -aj - const int iSortLengthSize = 5; + const int iSortLengthSize = SORT_LENGTH_DIVISION; int iMaxLength = (int)pSong->m_fMusicLengthSeconds; iMaxLength += (iSortLengthSize - (iMaxLength%iSortLengthSize) - 1); int iMinLength = iMaxLength - (iSortLengthSize-1);