add bookkeeping to stats.html
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
Bookkeeper* BOOKKEEPER = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
static const CString COINS_DAT = BASE_PATH "Data" SLASH "Coins.dat";
|
||||
static const CString COINS_HTML = BASE_PATH "Data" SLASH "Coins.html";
|
||||
|
||||
const int COINS_DAT_VERSION = 1;
|
||||
|
||||
@@ -185,14 +184,14 @@ int Bookkeeper::GetCoinsForDay( int iDayOfYear )
|
||||
}
|
||||
|
||||
|
||||
void Bookkeeper::GetCoinsLast7Days( int coins[7] )
|
||||
void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] )
|
||||
{
|
||||
UpdateLastSeenTime();
|
||||
|
||||
long lOldTime = m_iLastSeenTime;
|
||||
tm time = *localtime( &lOldTime );
|
||||
|
||||
for( int i=0; i<7; i++ )
|
||||
for( int i=0; i<NUM_LAST_DAYS; i++ )
|
||||
{
|
||||
time = GetYesterday( time );
|
||||
coins[i] = GetCoinsForDay( time.tm_yday );
|
||||
@@ -200,7 +199,7 @@ void Bookkeeper::GetCoinsLast7Days( int coins[7] )
|
||||
}
|
||||
|
||||
|
||||
void Bookkeeper::GetCoinsLast52Weeks( int coins[52] )
|
||||
void Bookkeeper::GetCoinsLastWeeks( int coins[NUM_LAST_WEEKS] )
|
||||
{
|
||||
UpdateLastSeenTime();
|
||||
|
||||
@@ -209,7 +208,7 @@ void Bookkeeper::GetCoinsLast52Weeks( int coins[52] )
|
||||
|
||||
time = GetLastSunday( time );
|
||||
|
||||
for( int w=0; w<52; w++ )
|
||||
for( int w=0; w<NUM_LAST_WEEKS; w++ )
|
||||
{
|
||||
coins[w] = 0;
|
||||
|
||||
@@ -250,3 +249,8 @@ void Bookkeeper::GetCoinsByHour( int coins[HOURS_PER_DAY] )
|
||||
coins[h] += m_iCoinsByHourForYear[d][h];
|
||||
}
|
||||
}
|
||||
|
||||
CString HourToString( int iHourIndex )
|
||||
{
|
||||
return ssprintf("%02d:00", iHourIndex);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,37 @@
|
||||
|
||||
#include "Style.h"
|
||||
|
||||
const int NUM_LAST_DAYS = 7;
|
||||
const int NUM_LAST_WEEKS = 52;
|
||||
const int DAYS_PER_YEAR = 365;
|
||||
const int HOURS_PER_DAY = 24;
|
||||
const int DAYS_IN_WEEK = 7;
|
||||
|
||||
const CString LAST_DAYS_NAME[NUM_LAST_DAYS] =
|
||||
{
|
||||
"Yesterday",
|
||||
"2 Days Ago",
|
||||
"3 Days Ago",
|
||||
"4 Days Ago",
|
||||
"5 Days Ago",
|
||||
"6 Days Ago",
|
||||
"7 Days Ago",
|
||||
};
|
||||
|
||||
const CString DAY_TO_NAME[DAYS_IN_WEEK] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
};
|
||||
|
||||
CString HourToString( int iHourIndex );
|
||||
|
||||
|
||||
class Bookkeeper
|
||||
{
|
||||
public:
|
||||
@@ -27,8 +54,8 @@ public:
|
||||
void CoinInserted();
|
||||
void UpdateLastSeenTime();
|
||||
|
||||
void GetCoinsLast7Days( int coins[7] );
|
||||
void GetCoinsLast52Weeks( int coins[52] );
|
||||
void GetCoinsLastDays( int coins[NUM_LAST_DAYS] );
|
||||
void GetCoinsLastWeeks( int coins[NUM_LAST_WEEKS] );
|
||||
void GetCoinsByDayOfWeek( int coins[DAYS_IN_WEEK] );
|
||||
void GetCoinsByHour( int coins[HOURS_PER_DAY] );
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "ProductInfo.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "Bookkeeper.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
|
||||
@@ -51,6 +53,7 @@ const int CATEGORY_RANKING_VERSION = 4;
|
||||
const int STEPS_SCORES_VERSION = 8;
|
||||
const int COURSE_SCORES_VERSION = 6;
|
||||
|
||||
#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle")
|
||||
|
||||
static const char *MemCardDirs[NUM_PLAYERS] =
|
||||
{
|
||||
@@ -948,8 +951,8 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
|
||||
f.PutLine( "<html>" );
|
||||
f.PutLine( "<head>" );
|
||||
f.PutLine( "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" );
|
||||
f.PutLine( ssprintf("<title>%s</title>", PRODUCT_NAME_VER) );
|
||||
f.PutLine( "<link rel='stylesheet' type='text/css' href='style.css'>" );
|
||||
f.PutLine( ssprintf("<title>%s</title>", STATS_TITLE.c_str() ) );
|
||||
f.PutLine( ssprintf("<link rel='stylesheet' type='text/css' href='%s'>",STYLE_CSS_FILE) );
|
||||
f.PutLine( "</head>" );
|
||||
f.PutLine( "<body>" );
|
||||
}
|
||||
@@ -972,13 +975,20 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
|
||||
// Print table of contents
|
||||
//
|
||||
{
|
||||
f.Write( "<h1><a name='top'>" PRODUCT_NAME_VER "</a></h1>\n" );
|
||||
PRINT_SECTION_START( "Table of Contents" );
|
||||
CString sName =
|
||||
pProfile->m_sLastUsedHighScoreName.empty() ?
|
||||
pProfile->m_sName :
|
||||
pProfile->m_sLastUsedHighScoreName;
|
||||
time_t ltime = time( NULL );
|
||||
CString sTime = ctime( <ime );
|
||||
|
||||
f.Write( ssprintf("<h1><a name='top'>%s for %s - %s</a></h1>\n",STATS_TITLE.c_str(), sName.c_str(), sTime.c_str()) );
|
||||
PRINT_DIV_START("Table of Contents");
|
||||
PRINT_LINK( "Statistics", "#Statistics" );
|
||||
PRINT_LINK( "Popularity Lists", "#Popularity Lists" );
|
||||
PRINT_LINK( "Difficulty Table", "#Difficulty Table" );
|
||||
PRINT_LINK( "Song/Steps List", "#Song/Steps List" );
|
||||
PRINT_LINK( "Bookkeeping", "#Bookkeeping" );
|
||||
PRINT_DIV_END;
|
||||
}
|
||||
|
||||
@@ -990,7 +1000,7 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
|
||||
|
||||
// Memory card stats
|
||||
{
|
||||
PRINT_DIV_START( "Memory Card" );
|
||||
PRINT_DIV_START( "This Profile" );
|
||||
PRINT_LINE_S( "Name", pProfile->m_sName );
|
||||
PRINT_LINE_S( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName );
|
||||
PRINT_LINE_B( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers );
|
||||
@@ -1199,7 +1209,6 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
|
||||
Steps* pSteps = vpSteps[j];
|
||||
if( pSteps->IsAutogen() )
|
||||
continue; // skip autogen
|
||||
f.PutLine( "<div class='section2'>\n" );
|
||||
CString s =
|
||||
GAMEMAN->NotesTypeToString(pSteps->m_StepsType) +
|
||||
" - " +
|
||||
@@ -1213,13 +1222,65 @@ void ProfileManager::SaveStatsWebPageToDir( CString sDir, MemoryCard mc )
|
||||
PRINT_SECTION_END;
|
||||
}
|
||||
|
||||
//
|
||||
// Print Bookkeeping
|
||||
//
|
||||
{
|
||||
PRINT_SECTION_START( "Bookkeeping" );
|
||||
|
||||
// GetCoinsLastDays
|
||||
{
|
||||
int coins[NUM_LAST_DAYS];
|
||||
BOOKKEEPER->GetCoinsLastDays( coins );
|
||||
PRINT_DIV_START( ssprintf("Coins for Last %d Days",NUM_LAST_DAYS).c_str() );
|
||||
for( int i=0; i<NUM_LAST_DAYS; i++ )
|
||||
{
|
||||
CString sDay = (i==0) ? "Today" : ssprintf("%d day(s) ago",i);
|
||||
PRINT_LINE_I( sDay.c_str(), coins[i] );
|
||||
}
|
||||
PRINT_DIV_END;
|
||||
}
|
||||
|
||||
// GetCoinsLastWeeks
|
||||
{
|
||||
int coins[NUM_LAST_WEEKS];
|
||||
BOOKKEEPER->GetCoinsLastWeeks( coins );
|
||||
PRINT_DIV_START( ssprintf("Coins for Last %d Weeks",NUM_LAST_WEEKS).c_str() );
|
||||
for( int i=0; i<NUM_LAST_WEEKS; i++ )
|
||||
{
|
||||
CString sWeek = (i==0) ? "This week" : ssprintf("%d week(s) ago",i);
|
||||
PRINT_LINE_I( sWeek.c_str(), coins[i] );
|
||||
}
|
||||
PRINT_DIV_END;
|
||||
}
|
||||
|
||||
// GetCoinsByHour
|
||||
{
|
||||
int coins[HOURS_PER_DAY];
|
||||
BOOKKEEPER->GetCoinsByHour( coins );
|
||||
PRINT_DIV_START( ssprintf("Coins for Last %d Weeks",HOURS_PER_DAY).c_str() );
|
||||
for( int i=0; i<HOURS_PER_DAY; i++ )
|
||||
{
|
||||
CString sHour = ssprintf("hour %d",i);
|
||||
PRINT_LINE_I( sHour.c_str(), coins[i] );
|
||||
}
|
||||
PRINT_DIV_END;
|
||||
}
|
||||
|
||||
|
||||
PRINT_SECTION_END;
|
||||
}
|
||||
|
||||
PRINT_SECTION_START( "End of File" );
|
||||
PRINT_SECTION_END;
|
||||
|
||||
f.PutLine( "</body>" );
|
||||
f.PutLine( "</html>" );
|
||||
|
||||
//
|
||||
// Copy CSS file from theme. If the copy fails, oh well...
|
||||
//
|
||||
CString sStyleFile = THEME->GetPathToO(STYLE_CSS_FILE);
|
||||
CString sStyleFile = THEME->GetPathToO("ProfileManager style.css");
|
||||
CopyFile2( sStyleFile, sDir+STYLE_CSS_FILE );
|
||||
|
||||
}
|
||||
|
||||
@@ -24,33 +24,6 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "Bookkeeper.h"
|
||||
|
||||
const CString LAST_7_DAYS_NAME[7] =
|
||||
{
|
||||
"Yesterday",
|
||||
"2 Days Ago",
|
||||
"3 Days Ago",
|
||||
"4 Days Ago",
|
||||
"5 Days Ago",
|
||||
"6 Days Ago",
|
||||
"7 Days Ago",
|
||||
};
|
||||
|
||||
const CString DAY_TO_NAME[DAYS_IN_WEEK] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
};
|
||||
|
||||
CString HourToString( int iHourIndex )
|
||||
{
|
||||
return ssprintf("%02d:00", iHourIndex);
|
||||
}
|
||||
|
||||
|
||||
ScreenBookkeeping::ScreenBookkeeping( CString sClassName ) : Screen( sClassName )
|
||||
{
|
||||
@@ -152,27 +125,27 @@ void ScreenBookkeeping::ChangeView( View newView )
|
||||
|
||||
switch( m_View )
|
||||
{
|
||||
case LAST_7_DAYS:
|
||||
case VIEW_LAST_DAYS:
|
||||
{
|
||||
m_textTitle.SetText( "Coin Data of Last 7 days" );
|
||||
m_textTitle.SetText( ssprintf("Coin Data of Last %d days", NUM_LAST_DAYS) );
|
||||
|
||||
int coins[7];
|
||||
BOOKKEEPER->GetCoinsLast7Days( coins );
|
||||
int iTotalLast7 = 0;
|
||||
int coins[NUM_LAST_DAYS];
|
||||
BOOKKEEPER->GetCoinsLastDays( coins );
|
||||
int iTotalLast = 0;
|
||||
|
||||
CString sTitle, sData;
|
||||
for( int i=0; i<7; i++ )
|
||||
for( int i=0; i<NUM_LAST_DAYS; i++ )
|
||||
{
|
||||
sTitle += LAST_7_DAYS_NAME[i] + "\n";
|
||||
sTitle += LAST_DAYS_NAME[i] + "\n";
|
||||
sData += ssprintf("%d",coins[i]) + "\n";
|
||||
iTotalLast7 += coins[i];
|
||||
iTotalLast += coins[i];
|
||||
}
|
||||
|
||||
sTitle += "\n";
|
||||
sData += "\n";
|
||||
|
||||
sTitle += "Average\n";
|
||||
sData += ssprintf("%d\n",iTotalLast7/7);
|
||||
sData += ssprintf("%d\n",iTotalLast/NUM_LAST_DAYS);
|
||||
|
||||
m_textCols[0].SetHorizAlign( Actor::align_left );
|
||||
m_textCols[0].SetText( sTitle );
|
||||
@@ -182,12 +155,12 @@ void ScreenBookkeeping::ChangeView( View newView )
|
||||
m_textCols[3].SetText( sData );
|
||||
}
|
||||
break;
|
||||
case LAST_52_WEEKS:
|
||||
case VIEW_LAST_WEEKS:
|
||||
{
|
||||
m_textTitle.SetText( "Last 52 weeks" );
|
||||
m_textTitle.SetText( ssprintf("Last %d weeks", NUM_LAST_WEEKS) );
|
||||
|
||||
int coins[52];
|
||||
BOOKKEEPER->GetCoinsLast52Weeks( coins );
|
||||
int coins[NUM_LAST_WEEKS];
|
||||
BOOKKEEPER->GetCoinsLastWeeks( coins );
|
||||
|
||||
CString sTitle, sData;
|
||||
for( int col=0; col<4; col++ )
|
||||
@@ -204,7 +177,7 @@ void ScreenBookkeeping::ChangeView( View newView )
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DAY_OF_WEEK:
|
||||
case VIEW_DAY_OF_WEEK:
|
||||
{
|
||||
m_textTitle.SetText( "Day of week" );
|
||||
|
||||
@@ -226,7 +199,7 @@ void ScreenBookkeeping::ChangeView( View newView )
|
||||
m_textCols[3].SetText( sData );
|
||||
}
|
||||
break;
|
||||
case HOUR_OF_DAY:
|
||||
case VIEW_HOUR_OF_DAY:
|
||||
{
|
||||
m_textTitle.SetText( "Hour of day" );
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
virtual void MenuBack( PlayerNumber pn );
|
||||
|
||||
private:
|
||||
enum View { LAST_7_DAYS, LAST_52_WEEKS, DAY_OF_WEEK, HOUR_OF_DAY, NUM_VIEWS };
|
||||
enum View { VIEW_LAST_DAYS, VIEW_LAST_WEEKS, VIEW_DAY_OF_WEEK, VIEW_HOUR_OF_DAY, NUM_VIEWS };
|
||||
|
||||
void ChangeView( View newView );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user