add song play counts

This commit is contained in:
Chris Danford
2008-07-31 10:22:27 +00:00
parent b93c4567c9
commit 09d3bd0a48
2 changed files with 47 additions and 4 deletions
+44 -1
View File
@@ -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<Song*> 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; i<NUM_BOOKKEEPING_COLS; i++ )
{
RString s;
for( int j=0; j<iSongPerCol; j++ )
{
int index = i*NUM_BOOKKEEPING_COLS + j;
if( index < (int)vpSongs.size() )
{
Song *pSong = vpSongs[index];
int iCount = pProfile->GetSongNumTimesPlayed( 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) );
+3 -3
View File
@@ -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 );