diff --git a/stepmania/src/MusicSortDisplay.cpp b/stepmania/src/MusicSortDisplay.cpp index 2d1e868f97..e52954a5e3 100644 --- a/stepmania/src/MusicSortDisplay.cpp +++ b/stepmania/src/MusicSortDisplay.cpp @@ -28,7 +28,7 @@ MusicSortDisplay::MusicSortDisplay() } -void MusicSortDisplay::Set( MusicSortOrder so ) +void MusicSortDisplay::Set( SongSortOrder so ) { switch( so ) diff --git a/stepmania/src/MusicSortDisplay.h b/stepmania/src/MusicSortDisplay.h index 04b541bc7c..5d4df4aa66 100644 --- a/stepmania/src/MusicSortDisplay.h +++ b/stepmania/src/MusicSortDisplay.h @@ -16,16 +16,15 @@ class MusicSortDisplay; #include "Sprite.h" +#include "GameTypes.h" -enum MusicSortOrder { SORT_GROUP, SORT_TITLE, SORT_BPM, SORT_ARTIST, SORT_MOST_PLAYED, NUM_SORT_ORDERS }; - class MusicSortDisplay : public Sprite { public: MusicSortDisplay(); - void Set( MusicSortOrder so ); + void Set( SongSortOrder so ); protected: diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 4458d340a7..e3233ba4ce 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -203,12 +203,13 @@ MusicWheel::MusicWheel() } + m_SortOrder = GAMEINFO->m_SongSortOrder; + m_MusicSortDisplay.Set( m_SortOrder ); + m_MusicSortDisplay.SetXY( SORT_ICON_ON_SCREEN_X, SORT_ICON_ON_SCREEN_Y ); - m_SortOrder = SORT_GROUP; m_sExpandedSectionName = ""; - RebuildWheelItems(); m_iSelection = 0; @@ -218,21 +219,31 @@ MusicWheel::MusicWheel() // find the previously selected song (if any), and select it - for( i=0; im_pCurSong ) + if( GetCurWheelItems()[i].m_pSong != NULL + && GetCurWheelItems()[i].m_pSong == GAMEINFO->m_pCurSong ) m_iSelection = i; } + + + for( int so=0; som_SongSortOrder = m_SortOrder; +} + +void MusicWheel::BuildWheelItems( CArray &arrayWheelItems, SongSortOrder so ) { CArray arraySongs; arraySongs.Copy( GAMEINFO->m_pSongs ); // sort the songs - switch( m_SortOrder ) + switch( so ) { case SORT_GROUP: SortSongPointerArrayByGroup( arraySongs ); @@ -254,22 +265,29 @@ void MusicWheel::RebuildWheelItems() } - m_WheelItems.RemoveAll(); // clear out the previous wheel items... + for( int i=0; iGetNumTimesPlayed(); + } + arrayWheelItems.RemoveAll(); // clear out the previous wheel items... // ...and load new ones - switch( m_SortOrder ) + switch( so ) { case SORT_GROUP: case SORT_MOST_PLAYED: case SORT_BPM: // make WheelItems without sections - m_WheelItems.SetSize( arraySongs.GetSize() ); + arrayWheelItems.SetSize( arraySongs.GetSize() ); { for( int i=0; i< arraySongs.GetSize(); i++ ) { Song* pSong = arraySongs[i]; - m_WheelItems[i].LoadFromSong( pSong ); - m_WheelItems[i].SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); + WheelItem &WI = arrayWheelItems[i]; + WI.LoadFromSong( pSong ); + WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); + WI.m_sSectionName = ""; } } break; @@ -277,7 +295,7 @@ void MusicWheel::RebuildWheelItems() case SORT_ARTIST: // make WheelItems with sections - m_WheelItems.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items + arrayWheelItems.SetSize( arraySongs.GetSize()*2 ); // make sure we have enough room for all music and section items { CString sLastSection = ""; @@ -286,24 +304,24 @@ void MusicWheel::RebuildWheelItems() for( int i=0; i< arraySongs.GetSize(); i++ ) { Song* pSong = arraySongs[i]; - CString sThisSection = GetSectionNameFromSongAndSort( pSong, m_SortOrder ); + CString sThisSection = GetSectionNameFromSongAndSort( pSong, so ); if( sThisSection != sLastSection ) // new section, make a section item { - WheelItem &WI = m_WheelItems[iCurWheelItem++]; + WheelItem &WI = arrayWheelItems[iCurWheelItem++]; WI.LoadFromSectionName( sThisSection ); + WI.m_sSectionName = sThisSection; WI.SetTintColor( COLOR_SECTION_TINTS[iNextSectionTint++] ); if( iNextSectionTint >= NUM_SECTION_TINTS ) iNextSectionTint = 0; sLastSection = sThisSection; } - if( sThisSection == m_sExpandedSectionName ) // this song is in the expanded section - { - WheelItem &WI = m_WheelItems[iCurWheelItem++]; - WI.LoadFromSong( pSong ); - WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); - } + + WheelItem &WI = arrayWheelItems[iCurWheelItem++]; + WI.LoadFromSong( pSong ); + WI.m_sSectionName = sThisSection; + WI.SetTintColor( *m_mapGroupNameToColorPtr[pSong->GetGroupName()] ); } - m_WheelItems.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items + arrayWheelItems.SetSize( iCurWheelItem ); // make sure we have enough room for all music and section items } break; default: @@ -311,26 +329,30 @@ void MusicWheel::RebuildWheelItems() } - if( m_SortOrder == SORT_MOST_PLAYED ) + if( so == SORT_MOST_PLAYED ) { // init crown icons - for( int i=0; i m_WheelItems.GetSize()-1 ) - iIndex = 0; + do + { + iIndex++; + if( iIndex > GetCurWheelItems().GetSize()-1 ) + iIndex = 0; + } + while( GetCurWheelItems()[iIndex].m_WheelItemType == WheelItem::TYPE_MUSIC + && GetCurWheelItems()[iIndex].m_sSectionName != "" + && GetCurWheelItems()[iIndex].m_sSectionName != m_sExpandedSectionName ); + } @@ -446,9 +483,9 @@ void MusicWheel::Update( float fDeltaTime ) - for( int i=0; i NUM_SORT_ORDERS-1 ) - m_SortOrder = (MusicSortOrder)0; + m_SortOrder = (SongSortOrder)0; m_sExpandedSectionName = GetSectionNameFromSongAndSort( pPrevSelectedSong, m_SortOrder ); - RebuildWheelItems(); + //RebuildWheelItems(); m_MusicSortDisplay.Set( m_SortOrder ); m_MusicSortDisplay.BeginTweening( FADE_TIME, TWEEN_BIAS_BEGIN ); @@ -482,9 +519,9 @@ void MusicWheel::Update( float fDeltaTime ) // find the previously selected song, and select it - for( i=0; iStop(); - m_iSelection--; - if( m_iSelection < 0 ) - m_iSelection = m_WheelItems.GetSize()-1; + do + { + m_iSelection--; + if( m_iSelection < 0 ) + m_iSelection = GetCurWheelItems().GetSize()-1; + } + while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC + && GetCurWheelItems()[m_iSelection].m_sSectionName != "" + && GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName ); + m_fPositionOffsetFromSelection -= 1; @@ -558,9 +602,16 @@ void MusicWheel::NextMusic() MUSIC->Stop(); - m_iSelection++; - if( m_iSelection > m_WheelItems.GetSize()-1 ) - m_iSelection = 0; + do + { + m_iSelection++; + if( m_iSelection > GetCurWheelItems().GetSize()-1 ) + m_iSelection = 0; + } + while( GetCurWheelItems()[m_iSelection].m_WheelItemType == WheelItem::TYPE_MUSIC + && GetCurWheelItems()[m_iSelection].m_sSectionName != "" + && GetCurWheelItems()[m_iSelection].m_sSectionName != m_sExpandedSectionName ); + m_fPositionOffsetFromSelection += 1; @@ -593,17 +644,17 @@ void MusicWheel::NextSort() bool MusicWheel::Select() { - switch( m_WheelItems[m_iSelection].m_WheelItemType ) + switch( GetCurWheelItems()[m_iSelection].m_WheelItemType ) { case WheelItem::TYPE_SECTION: { - CString sThisItemSectionName = m_WheelItems[m_iSelection].GetSectionName(); + CString sThisItemSectionName = GetCurWheelItems()[m_iSelection].GetSectionName(); if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded m_sExpandedSectionName = ""; // collapse it else // already collapsed m_sExpandedSectionName = sThisItemSectionName; // expand it - RebuildWheelItems(); + //RebuildWheelItems(); m_soundExpand.PlayRandom(); @@ -611,10 +662,10 @@ bool MusicWheel::Select() m_iSelection = 0; // reset in case we can't find the last selected song // find the section header and select it - for( int i=0; i &arrayWheelItems, SongSortOrder so ); + void SwitchSortOrder(); Sprite m_sprSelectionBackground; @@ -108,8 +112,9 @@ protected: - CArray m_WheelItems; - MusicSortOrder m_SortOrder; + CArray m_WheelItems[NUM_SORT_ORDERS]; + SongSortOrder m_SortOrder; + CArray &GetCurWheelItems() { return m_WheelItems[m_SortOrder]; }; int m_iSelection; CString m_sExpandedSectionName; @@ -136,37 +141,37 @@ protected: - CString GetSectionNameFromSongAndSort( Song* pSong, MusicSortOrder order ) + CString GetSectionNameFromSongAndSort( Song* pSong, SongSortOrder so ) { CString sTemp; - switch( m_SortOrder ) + switch( so ) { case SORT_GROUP: sTemp = pSong->GetGroupName(); sTemp.MakeUpper(); - if( sTemp.GetLength() > 0 ) - return sTemp; - else - return " "; + sTemp = (sTemp.GetLength() > 0) ? sTemp : ""; + if( IsAnInt(sTemp) ) + sTemp = "NUM"; + return sTemp; case SORT_ARTIST: sTemp = pSong->GetArtist(); sTemp.MakeUpper(); - if( sTemp.GetLength() > 0 ) - return sTemp[0]; - else - return " "; + sTemp = (sTemp.GetLength() > 0) ? sTemp.Left(1) : ""; + if( IsAnInt(sTemp) ) + sTemp = "NUM"; + return sTemp; case SORT_TITLE: sTemp = pSong->GetTitle(); sTemp.MakeUpper(); - if( sTemp.GetLength() > 0 ) - return sTemp[0]; - else - return " "; + sTemp = (sTemp.GetLength() > 0) ? sTemp.Left(1) : ""; + if( IsAnInt(sTemp) ) + sTemp = "NUM"; + return sTemp; case SORT_BPM: case SORT_MOST_PLAYED: default: - return " "; + return ""; } }; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 6c1c656098..983e7d1296 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -1065,23 +1065,24 @@ void Player::DrawColorArrows() float fYOffset = GetColorArrowYOffset( j, m_fSongBeat ); - float fYPos = GetColorArrowYPos( j, m_fSongBeat ); + if( hss.m_HoldScore == HoldStepScore::HOLD_STEPPED_ON || hss.m_HoldScore == HoldStepScore::HOLD_SCORE_OK ) { if( fYPos < GetGrayArrowYPos() ) continue; // don't draw } + + if( hss.m_HoldScore == HoldStepScore::HOLD_STEPPED_ON || hss.m_HoldScore == HoldStepScore::HOLD_SCORE_OK ) + fYPos = max( fYPos, GetGrayArrowYPos() ); if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; + m_ColorArrow[iColNum].SetY( fYPos ); float fAlpha = GetColorArrowAlphaFromYOffset( fYOffset ); m_ColorArrow[iColNum].SetAlpha( fAlpha ); m_ColorArrow[iColNum].DrawGrayPart(); - if( hss.m_HoldScore == HoldStepScore::HOLD_STEPPED_ON || hss.m_HoldScore == HoldStepScore::HOLD_SCORE_OK ) - fYPos = max( fYPos, GetGrayArrowYPos() ); - if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; m_ColorArrow[iColNum].SetY( fYPos ); m_ColorArrow[iColNum].SetColorPartFromIndexAndBeat( i, m_fSongBeat ); m_ColorArrow[iColNum].SetGrayPartFromIndexAndBeat( i, m_fSongBeat ); diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index dd50e9bf49..2b1e626e64 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -95,9 +95,10 @@ void RageLog( LPCTSTR fmt, ...) CString sBuff = vssprintf( fmt, va ); sBuff += "\n"; - fprintf(g_fileLog, sBuff); - fclose( g_fileLog ); - g_fileLog = fopen( g_sLogFileName, "w" ); + fprintf( g_fileLog, sBuff ); + fflush( g_fileLog ); +// fclose( g_fileLog ); +// g_fileLog = fopen( g_sLogFileName, "w" ); } void RageLogHr( HRESULT hr, LPCTSTR fmt, ...) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index 74b7c4a59d..1a96c759b9 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -111,13 +111,8 @@ void RageLogHr( HRESULT hr, LPCTSTR fmt, ...); VOID DisplayErrorAndDie( CString sError ); -#if defined(DEBUG) | defined(_DEBUG) - #define RageError(str) DisplayErrorAndDie( ssprintf( "%s\n\n%s(%d)", str, __FILE__, (DWORD)__LINE__) ) - #define RageErrorHr(str,hr) DisplayErrorAndDie( ssprintf("%s (%s)\n\n%s(%d)", str, DXGetErrorString8(hr), __FILE__, (DWORD)__LINE__) ) -#else - #define RageError(str) DisplayErrorAndDie( ssprintf( "%s\n\n%", str ) ) - #define RageErrorHr(str,hr) DisplayErrorAndDie( ssprintf("%s (%s)\n\n%", str, DXGetErrorString8(hr) ) ) -#endif +#define RageError(str) DisplayErrorAndDie( ssprintf( "%s\n\n%s(%d)", str, __FILE__, (DWORD)__LINE__) ) +#define RageErrorHr(str,hr) DisplayErrorAndDie( ssprintf("%s (%s)\n\n%s(%d)", str, DXGetErrorString8(hr), __FILE__, (DWORD)__LINE__) ) LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 7c12da8558..594633a907 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -788,7 +788,7 @@ int CompareSongPointersByMostPlayed(const void *arg1, const void *arg2) CString sFilePath1 = pSong1->GetSongFilePath(); // this is unique among songs CString sFilePath2 = pSong2->GetSongFilePath(); - if( iNumTimesPlayed1 < iNumTimesPlayed2 ) + if( iNumTimesPlayed1 > iNumTimesPlayed2 ) return -1; else if( iNumTimesPlayed1 == iNumTimesPlayed2 ) return CompareCStrings( (void*)&sFilePath1, (void*)&sFilePath2 );