2003-10-13 08:33:39 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenBookkeeping.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "Bookkeeper.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2005-09-05 02:26:50 +00:00
|
|
|
#include "InputEventPlus.h"
|
2005-10-07 01:58:41 +00:00
|
|
|
#include "RageUtil.h"
|
2005-12-27 17:08:23 +00:00
|
|
|
#include "LocalizedString.h"
|
2003-10-13 08:33:39 +00:00
|
|
|
|
|
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenBookkeeping );
|
2005-02-23 06:29:05 +00:00
|
|
|
|
|
|
|
|
void ScreenBookkeeping::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenWithMenuElements::Init();
|
|
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textAllTime.LoadFromFont( THEME->GetPathF(m_sName,"AllTime") );
|
|
|
|
|
m_textAllTime.SetName( "AllTime" );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_textAllTime );
|
|
|
|
|
this->AddChild( &m_textAllTime );
|
|
|
|
|
|
2005-05-09 11:15:45 +00:00
|
|
|
m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"title") );
|
|
|
|
|
m_textTitle.SetName( "Title" );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_textTitle );
|
2003-10-13 08:33:39 +00:00
|
|
|
this->AddChild( &m_textTitle );
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<NUM_BOOKKEEPING_COLS; i++ )
|
|
|
|
|
{
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[i].LoadFromFont( THEME->GetPathF(m_sName,"data") );
|
|
|
|
|
m_textData[i].SetName( "Data" );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_textData[i] );
|
2004-08-22 05:37:12 +00:00
|
|
|
float fX = SCALE( i, 0.f, NUM_BOOKKEEPING_COLS-1, SCREEN_LEFT+50, SCREEN_RIGHT-160 );
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[i].SetX( fX );
|
|
|
|
|
this->AddChild( &m_textData[i] );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeView( (View)0 );
|
2005-05-09 11:15:45 +00:00
|
|
|
|
|
|
|
|
this->SortByDrawOrder();
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenBookkeeping::~ScreenBookkeeping()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenBookkeeping::~ScreenBookkeeping()" );
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-14 18:36:01 +00:00
|
|
|
void ScreenBookkeeping::Update( float fDelta )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-06-14 18:36:01 +00:00
|
|
|
ChangeView( m_View ); // refresh so that counts change in real-time
|
|
|
|
|
|
|
|
|
|
ScreenWithMenuElements::Update( fDelta );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
void ScreenBookkeeping::Input( const InputEventPlus &input )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-09-05 02:26:50 +00:00
|
|
|
if( input.type != IET_FIRST_PRESS && input.type != IET_SLOW_REPEAT )
|
2003-10-13 08:33:39 +00:00
|
|
|
return; // ignore
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
Screen::Input( input ); // default handler
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
2005-10-13 22:17:13 +00:00
|
|
|
StartTransitioningScreen( 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();
|
2005-10-13 22:17:13 +00:00
|
|
|
StartTransitioningScreen( SM_GoToPrevScreen );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-05-05 03:38:38 +00:00
|
|
|
|
|
|
|
|
void ScreenBookkeeping::MenuCoin( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
ChangeView( m_View );
|
|
|
|
|
|
|
|
|
|
Screen::MenuCoin( pn );
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-27 17:08:23 +00:00
|
|
|
static LocalizedString ALL_TIME ( "ScreenBookkeeping", "All-time Total:" );
|
|
|
|
|
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" );
|
|
|
|
|
static LocalizedString HOUR_OF_DAY ( "ScreenBookkeeping", "Coin Data by Hour of Day, All-Time" );
|
2003-10-13 08:33:39 +00:00
|
|
|
void ScreenBookkeeping::ChangeView( View newView )
|
|
|
|
|
{
|
|
|
|
|
m_View = newView;
|
|
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
|
|
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString s;
|
2005-12-27 17:08:23 +00:00
|
|
|
s += ALL_TIME.GetValue();
|
|
|
|
|
s += ssprintf( " %i\n", BOOKKEEPER->GetCoinsTotal() );
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textAllTime.SetText( s );
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-13 08:33:39 +00:00
|
|
|
switch( m_View )
|
|
|
|
|
{
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_LAST_DAYS:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-12-27 17:08:23 +00:00
|
|
|
m_textTitle.SetText( ssprintf(LAST_DAYS.GetValue(), 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;
|
2005-05-09 11:15:45 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString 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
|
|
|
{
|
2006-01-07 04:11:29 +00:00
|
|
|
sTitle += LastDayToLocalizedString(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
|
|
|
}
|
|
|
|
|
|
2005-12-27 17:39:27 +00:00
|
|
|
sTitle += ALL_TIME.GetValue()+"\n";
|
2005-05-05 08:32:42 +00:00
|
|
|
sData += ssprintf("%i\n", iTotalLast);
|
2003-10-13 08:33:39 +00:00
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[0].SetText( "" );
|
|
|
|
|
m_textData[1].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textData[1].SetText( sTitle );
|
|
|
|
|
m_textData[2].SetText( "" );
|
|
|
|
|
m_textData[3].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textData[3].SetText( sData );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_LAST_WEEKS:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-12-27 17:39:27 +00:00
|
|
|
m_textTitle.SetText( ssprintf(LAST_WEEKS.GetValue(), 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
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sTitle, sData;
|
2003-10-13 08:33:39 +00:00
|
|
|
for( int col=0; col<4; col++ )
|
|
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sTemp;
|
2003-10-13 08:33:39 +00:00
|
|
|
for( int row=0; row<52/4; row++ )
|
|
|
|
|
{
|
|
|
|
|
int week = row*4+col;
|
2006-01-07 04:11:29 +00:00
|
|
|
sTemp += LastWeekToLocalizedString(week) + ssprintf(": %d",coins[week]) + "\n";
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[col].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textData[col].SetText( sTemp );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_DAY_OF_WEEK:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-12-27 17:08:23 +00:00
|
|
|
m_textTitle.SetText( DAY_OF_WEEK );
|
2003-10-13 08:33:39 +00:00
|
|
|
|
|
|
|
|
int coins[DAYS_IN_WEEK];
|
|
|
|
|
BOOKKEEPER->GetCoinsByDayOfWeek( coins );
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sTitle, sData;
|
2003-10-13 08:33:39 +00:00
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[0].SetText( "" );
|
|
|
|
|
m_textData[1].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textData[1].SetText( sTitle );
|
|
|
|
|
m_textData[2].SetText( "" );
|
|
|
|
|
m_textData[3].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textData[3].SetText( sData );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2003-12-10 05:03:17 +00:00
|
|
|
case VIEW_HOUR_OF_DAY:
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2005-12-27 17:08:23 +00:00
|
|
|
m_textTitle.SetText( HOUR_OF_DAY );
|
2003-10-13 08:33:39 +00:00
|
|
|
|
2004-02-22 20:44:33 +00:00
|
|
|
int coins[HOURS_IN_DAY];
|
2003-10-13 08:33:39 +00:00
|
|
|
BOOKKEEPER->GetCoinsByHour( coins );
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sTitle1, sData1;
|
2004-09-21 07:53:39 +00:00
|
|
|
for( int i=0; i<HOURS_IN_DAY/2; i++ )
|
2003-10-13 08:33:39 +00:00
|
|
|
{
|
2006-01-07 04:11:29 +00:00
|
|
|
sTitle1 += HourInDayToLocalizedString(i) + "\n";
|
2003-12-20 21:41:40 +00:00
|
|
|
sData1 += ssprintf("%d",coins[i]) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sTitle2, sData2;
|
2004-09-21 07:53:39 +00:00
|
|
|
for( int i=(HOURS_IN_DAY/2); i<HOURS_IN_DAY; i++ )
|
2003-12-20 21:41:40 +00:00
|
|
|
{
|
2006-01-07 04:11:29 +00:00
|
|
|
sTitle2 += HourInDayToLocalizedString(i) + "\n";
|
2003-12-20 21:41:40 +00:00
|
|
|
sData2 += ssprintf("%d",coins[i]) + "\n";
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-13 19:04:21 +00:00
|
|
|
m_textData[0].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textData[0].SetText( sTitle1 );
|
|
|
|
|
m_textData[1].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textData[1].SetText( sData1 );
|
|
|
|
|
m_textData[2].SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_textData[2].SetText( sTitle2 );
|
|
|
|
|
m_textData[3].SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textData[3].SetText( sData2 );
|
2003-10-13 08:33:39 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|