From 09d3bd0a48b6f4fc2052da56b289294fc76baf8c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 31 Jul 2008 10:22:27 +0000 Subject: [PATCH] add song play counts --- stepmania/src/ScreenBookkeeping.cpp | 45 ++++++++++++++++++++++++++++- stepmania/src/ScreenBookkeeping.h | 6 ++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/stepmania/src/ScreenBookkeeping.cpp b/stepmania/src/ScreenBookkeeping.cpp index 141fe71317..74b0fd77a3 100644 --- a/stepmania/src/ScreenBookkeeping.cpp +++ b/stepmania/src/ScreenBookkeeping.cpp @@ -8,6 +8,11 @@ #include "InputEventPlus.h" #include "RageUtil.h" #include "LocalizedString.h" +#include "Song.h" +#include "SongManager.h" +#include "UnlockManager.h" +#include "ProfileManager.h" +#include "Profile.h" REGISTER_SCREEN_CLASS( ScreenBookkeeping ); @@ -93,7 +98,8 @@ void ScreenBookkeeping::MenuCoin( const InputEventPlus &input ) Screen::MenuCoin( input ); } -static LocalizedString ALL_TIME ( "ScreenBookkeeping", "All-time Total:" ); +static LocalizedString ALL_TIME ( "ScreenBookkeeping", "All-time Coin Total:" ); +static LocalizedString SONG_PLAYS ( "ScreenBookkeeping", "Total Song Plays: %d" ); static LocalizedString LAST_DAYS ( "ScreenBookkeeping", "Coin Data of Last %d Days" ); static LocalizedString LAST_WEEKS ( "ScreenBookkeeping", "Coin Data of Last %d Weeks" ); static LocalizedString DAY_OF_WEEK ( "ScreenBookkeeping", "Coin Data by Day of Week, All-Time" ); @@ -112,6 +118,43 @@ void ScreenBookkeeping::ChangeView( View newView ) switch( m_View ) { + case View_SongsPlays: + { + Profile *pProfile = PROFILEMAN->GetMachineProfile(); + + vector vpSongs; + int iCount = 0; + FOREACH_CONST( Song *, SONGMAN->GetSongs(), s ) + { + Song *pSong = *s; + if( UNLOCKMAN->SongIsLocked(pSong) & ~LOCKED_DISABLED ) + continue; + iCount += pProfile->GetSongNumTimesPlayed( pSong ); + vpSongs.push_back( pSong ); + } + m_textTitle.SetText( ssprintf(SONG_PLAYS.GetValue(), iCount) ); + SongUtil::SortSongPointerArrayByNumPlays( vpSongs, pProfile, true ); + + const int iSongPerCol = 15; + + for( int i=0; iGetSongNumTimesPlayed( pSong ); + s += ssprintf("%4d",iCount) + " " + pSong->GetDisplayFullTitle() + "\n"; + } + } + m_textData[i].SetText( s ); + m_textData[i].SetHorizAlign( align_left ); + } + } + break; case VIEW_LAST_DAYS: { m_textTitle.SetText( ssprintf(LAST_DAYS.GetValue(), NUM_LAST_DAYS) ); diff --git a/stepmania/src/ScreenBookkeeping.h b/stepmania/src/ScreenBookkeeping.h index 09c26f88e5..e6c0ffe7ea 100644 --- a/stepmania/src/ScreenBookkeeping.h +++ b/stepmania/src/ScreenBookkeeping.h @@ -1,7 +1,7 @@ /* ScreenBookkeeping - Show coin drop stats. */ -#ifndef SCREEN_BOOKKEEPING_H -#define SCREEN_BOOKKEEPING_H +#ifndef ScreenBookkeeping_H +#define ScreenBookkeeping_H #include "ScreenWithMenuElements.h" #include "BitmapText.h" @@ -25,7 +25,7 @@ public: private: virtual bool GenericTweenOn() const { return true; } virtual bool GenericTweenOff() const { return true; } - enum View { VIEW_LAST_DAYS, VIEW_LAST_WEEKS, VIEW_DAY_OF_WEEK, VIEW_HOUR_OF_DAY, NUM_VIEWS }; + enum View { View_SongsPlays, VIEW_LAST_DAYS, VIEW_LAST_WEEKS, VIEW_DAY_OF_WEEK, VIEW_HOUR_OF_DAY, NUM_VIEWS }; void ChangeView( View newView );