#include "global.h" #include "ScreenBookkeeping.h" #include "ScreenManager.h" #include "RageLog.h" #include "ThemeManager.h" #include "Bookkeeper.h" #include "ScreenDimensions.h" #include "InputEventPlus.h" #include "RageUtil.h" #include "LocalizedString.h" REGISTER_SCREEN_CLASS( ScreenBookkeeping ); void ScreenBookkeeping::Init() { ScreenWithMenuElements::Init(); m_textAllTime.LoadFromFont( THEME->GetPathF(m_sName,"AllTime") ); m_textAllTime.SetName( "AllTime" ); SET_XY_AND_ON_COMMAND( m_textAllTime ); this->AddChild( &m_textAllTime ); m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"title") ); m_textTitle.SetName( "Title" ); SET_XY_AND_ON_COMMAND( m_textTitle ); this->AddChild( &m_textTitle ); for( int i=0; iGetPathF(m_sName,"data") ); m_textData[i].SetName( "Data" ); SET_XY_AND_ON_COMMAND( m_textData[i] ); float fX = SCALE( i, 0.f, NUM_BOOKKEEPING_COLS-1, SCREEN_LEFT+50, SCREEN_RIGHT-160 ); m_textData[i].SetX( fX ); this->AddChild( &m_textData[i] ); } ChangeView( (View)0 ); this->SortByDrawOrder(); } ScreenBookkeeping::~ScreenBookkeeping() { LOG->Trace( "ScreenBookkeeping::~ScreenBookkeeping()" ); } void ScreenBookkeeping::Update( float fDelta ) { ChangeView( m_View ); // refresh so that counts change in real-time ScreenWithMenuElements::Update( fDelta ); } void ScreenBookkeeping::Input( const InputEventPlus &input ) { if( input.type != IET_FIRST_PRESS && input.type != IET_SLOW_REPEAT ) return; // ignore Screen::Input( input ); // default handler } 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 ) { if( !IsTransitioning() ) { SCREENMAN->PlayStartSound(); StartTransitioningScreen( SM_GoToNextScreen ); } } void ScreenBookkeeping::MenuBack( PlayerNumber pn ) { if(!IsTransitioning()) { SCREENMAN->PlayStartSound(); StartTransitioningScreen( SM_GoToPrevScreen ); } } void ScreenBookkeeping::MenuCoin( PlayerNumber pn ) { ChangeView( m_View ); Screen::MenuCoin( pn ); } 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" ); void ScreenBookkeeping::ChangeView( View newView ) { m_View = newView; { RString s; s += ALL_TIME.GetValue(); s += ssprintf( " %i\n", BOOKKEEPER->GetCoinsTotal() ); m_textAllTime.SetText( s ); } switch( m_View ) { case VIEW_LAST_DAYS: { m_textTitle.SetText( ssprintf(LAST_DAYS.GetValue(), NUM_LAST_DAYS) ); int coins[NUM_LAST_DAYS]; BOOKKEEPER->GetCoinsLastDays( coins ); int iTotalLast = 0; RString sTitle, sData; for( int i=0; iGetCoinsLastWeeks( coins ); RString sTitle, sData; for( int col=0; col<4; col++ ) { RString sTemp; for( int row=0; row<52/4; row++ ) { int week = row*4+col; sTemp += LastWeekToLocalizedString(week) + ssprintf(": %d",coins[week]) + "\n"; } m_textData[col].SetHorizAlign( Actor::align_left ); m_textData[col].SetText( sTemp ); } } break; case VIEW_DAY_OF_WEEK: { m_textTitle.SetText( DAY_OF_WEEK ); int coins[DAYS_IN_WEEK]; BOOKKEEPER->GetCoinsByDayOfWeek( coins ); RString sTitle, sData; for( int i=0; iGetCoinsByHour( coins ); RString sTitle1, sData1; for( int i=0; i