2003-10-13 08:33:39 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenBookkeeping
|
|
|
|
|
|
|
|
|
|
Desc: Where the player maps device input to pad input.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScreenBookkeeping.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "InputMapper.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "RageSounds.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
#include "Bookkeeper.h"
|
|
|
|
|
|
|
|
|
|
|
2004-05-01 23:19:33 +00:00
|
|
|
ScreenBookkeeping::ScreenBookkeeping( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenBookkeeping::ScreenBookkeeping()" );
|
|
|
|
|
|
|
|
|
|
m_textTitle.LoadFromFont( THEME->GetPathToF("Common title") );
|
|
|
|
|
m_textTitle.SetText( "header" );
|
|
|
|
|
m_textTitle.SetXY( CENTER_X, 60 );
|
|
|
|
|
m_textTitle.SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
m_textTitle.SetZoom( 0.8f );
|
|
|
|
|
this->AddChild( &m_textTitle );
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<NUM_BOOKKEEPING_COLS; i++ )
|
|
|
|
|
{
|
2003-12-20 21:41:40 +00:00
|
|
|
float fX = SCALE( i, 0.f, NUM_BOOKKEEPING_COLS-1, SCREEN_LEFT+50, SCREEN_RIGHT-120 );
|
2003-10-13 08:33:39 +00:00
|
|
|
float fY = CENTER_Y+16;
|
|
|
|
|
m_textCols[i].LoadFromFont( THEME->GetPathToF("Common normal") );
|
|
|
|
|
m_textCols[i].SetText( ssprintf("%d",i) );
|
|
|
|
|
m_textCols[i].SetXY( fX, fY );
|
|
|
|
|
m_textCols[i].SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
m_textCols[i].SetZoom( 0.6f );
|
|
|
|
|
this->AddChild( &m_textCols[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeView( (View)0 );
|
|
|
|
|
|
|
|
|
|
SOUND->PlayMusic( THEME->GetPathToS("ScreenBookkeeping music") );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenBookkeeping::~ScreenBookkeeping()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenBookkeeping::~ScreenBookkeeping()" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
|
|
|
|
if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT )
|
|
|
|
|
return; // ignore
|
|
|
|
|
|
|
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default handler
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_GoToNextScreen:
|
|
|
|
|
case SM_GoToPrevScreen:
|
|
|
|
|
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::MenuLeft( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
m_View = (View)(m_View-1);
|
|
|
|
|
CLAMP( (int&)m_View, 0, NUM_VIEWS-1 );
|
|
|
|
|
ChangeView( m_View );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::MenuRight( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
m_View = (View)(m_View+1);
|
|
|
|
|
CLAMP( (int&)m_View, 0, NUM_VIEWS-1 );
|
|
|
|
|
ChangeView( m_View );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::MenuStart( PlayerNumber pn )
|
|
|
|
|
{
|
2004-05-01 23:19:33 +00:00
|
|
|
if( !IsTransitioning() )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2004-03-23 23:56:38 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2004-05-01 23:19:33 +00:00
|
|
|
StartTransitioning( SM_GoToNextScreen );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::MenuBack( PlayerNumber pn )
|
|
|
|
|
{
|
2004-05-01 23:19:33 +00:00
|
|
|
if(!IsTransitioning())
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2004-03-23 23:56:38 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2004-05-01 23:19:33 +00:00
|
|
|
StartTransitioning( SM_GoToPrevScreen );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenBookkeeping::ChangeView( View newView )
|
|
|
|
|
{
|
|
|
|
|
m_View = newView;
|
|
|
|
|
|
|
|
|
|
switch( m_View )
|
|
|
|
|
{
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_LAST_DAYS:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2003-12-10 05:03:17 +00:00
|
|
|
m_textTitle.SetText( ssprintf("Coin Data of Last %d days", NUM_LAST_DAYS) );
|
2003-10-13 08:33:39 +00:00
|
|
|
|
2003-12-10 05:03:17 +00:00
|
|
|
int coins[NUM_LAST_DAYS];
|
|
|
|
|
BOOKKEEPER->GetCoinsLastDays( coins );
|
|
|
|
|
int iTotalLast = 0;
|
2003-10-13 08:33:39 +00:00
|
|
|
|
|
|
|
|
CString sTitle, sData;
|
2003-12-10 05:03:17 +00:00
|
|
|
for( int i=0; i<NUM_LAST_DAYS; i++ )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2004-02-22 20:44:33 +00:00
|
|
|
sTitle += LastDayToString(i) + "\n";
|
2003-10-13 08:33:39 +00:00
|
|
|
sData += ssprintf("%d",coins[i]) + "\n";
|
2003-12-10 05:03:17 +00:00
|
|
|
iTotalLast += coins[i];
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sTitle += "\n";
|
|
|
|
|
sData += "\n";
|
|
|
|
|
|
|
|
|
|
sTitle += "Average\n";
|
2003-12-10 05:03:17 +00:00
|
|
|
sData += ssprintf("%d\n",iTotalLast/NUM_LAST_DAYS);
|
2003-10-13 08:33:39 +00:00
|
|
|
|
|
|
|
|
m_textCols[0].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textCols[0].SetText( sTitle );
|
|
|
|
|
m_textCols[1].SetText( "" );
|
|
|
|
|
m_textCols[2].SetText( "" );
|
|
|
|
|
m_textCols[3].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textCols[3].SetText( sData );
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_LAST_WEEKS:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2003-12-10 05:03:17 +00:00
|
|
|
m_textTitle.SetText( ssprintf("Last %d weeks", NUM_LAST_WEEKS) );
|
2003-10-13 08:33:39 +00:00
|
|
|
|
2003-12-10 05:03:17 +00:00
|
|
|
int coins[NUM_LAST_WEEKS];
|
|
|
|
|
BOOKKEEPER->GetCoinsLastWeeks( coins );
|
2003-10-13 08:33:39 +00:00
|
|
|
|
|
|
|
|
CString sTitle, sData;
|
|
|
|
|
for( int col=0; col<4; col++ )
|
|
|
|
|
{
|
|
|
|
|
CString sTemp;
|
|
|
|
|
for( int row=0; row<52/4; row++ )
|
|
|
|
|
{
|
|
|
|
|
int week = row*4+col;
|
|
|
|
|
sTemp += ssprintf("%d ago: %d\n", week+1, coins[week]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_textCols[col].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textCols[col].SetText( sTemp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_DAY_OF_WEEK:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
|
|
|
|
m_textTitle.SetText( "Day of week" );
|
|
|
|
|
|
|
|
|
|
int coins[DAYS_IN_WEEK];
|
|
|
|
|
BOOKKEEPER->GetCoinsByDayOfWeek( coins );
|
|
|
|
|
|
|
|
|
|
CString sTitle, sData;
|
|
|
|
|
for( int i=0; i<DAYS_IN_WEEK; i++ )
|
|
|
|
|
{
|
2004-02-22 20:44:33 +00:00
|
|
|
sTitle += DayOfWeekToString(i) + "\n";
|
2003-10-13 08:33:39 +00:00
|
|
|
sData += ssprintf("%d",coins[i]) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_textCols[0].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textCols[0].SetText( sTitle );
|
|
|
|
|
m_textCols[1].SetText( "" );
|
|
|
|
|
m_textCols[2].SetText( "" );
|
|
|
|
|
m_textCols[3].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textCols[3].SetText( sData );
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_HOUR_OF_DAY:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
|
|
|
|
m_textTitle.SetText( "Hour of day" );
|
|
|
|
|
|
2004-02-22 20:44:33 +00:00
|
|
|
int coins[HOURS_IN_DAY];
|
2003-10-13 08:33:39 +00:00
|
|
|
BOOKKEEPER->GetCoinsByHour( coins );
|
|
|
|
|
|
2003-12-20 21:41:40 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
CString sTitle1, sData1;
|
2004-02-22 20:44:33 +00:00
|
|
|
for( i=0; i<HOURS_IN_DAY/2; i++ )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2004-02-22 20:44:33 +00:00
|
|
|
sTitle1 += HourInDayToString(i) + "\n";
|
2003-12-20 21:41:40 +00:00
|
|
|
sData1 += ssprintf("%d",coins[i]) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString sTitle2, sData2;
|
2004-02-22 20:44:33 +00:00
|
|
|
for( i=(HOURS_IN_DAY/2); i<HOURS_IN_DAY; i++ )
|
2003-12-20 21:41:40 +00:00
|
|
|
{
|
2004-02-22 20:44:33 +00:00
|
|
|
sTitle2 += HourInDayToString(i) + "\n";
|
2003-12-20 21:41:40 +00:00
|
|
|
sData2 += ssprintf("%d",coins[i]) + "\n";
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_textCols[0].SetHorizAlign( Actor::align_left );
|
2003-12-20 21:41:40 +00:00
|
|
|
m_textCols[0].SetText( sTitle1 );
|
|
|
|
|
m_textCols[1].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textCols[1].SetText( sData1 );
|
|
|
|
|
m_textCols[2].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textCols[2].SetText( sTitle2 );
|
2003-10-13 08:33:39 +00:00
|
|
|
m_textCols[3].SetHorizAlign( Actor::align_right );
|
2003-12-20 21:41:40 +00:00
|
|
|
m_textCols[3].SetText( sData2 );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
}
|