2003-02-16 04:01:45 +00:00
#include "global.h"
2003-01-26 07:33:03 +00:00
#include "ScreenRanking.h"
2005-07-20 09:48:19 +00:00
#include "ScreenManager.h"
2003-01-26 07:33:03 +00:00
#include "ThemeManager.h"
#include "SongManager.h"
#include "GameState.h"
#include "GameManager.h"
2003-07-17 20:10:07 +00:00
#include "Course.h"
2008-03-09 01:51:34 +00:00
#include "Song.h"
2003-12-18 03:40:57 +00:00
#include "Steps.h"
2003-11-02 16:32:45 +00:00
#include "ActorUtil.h"
2003-12-07 07:09:13 +00:00
#include "ProfileManager.h"
2005-07-01 05:07:22 +00:00
#include "Profile.h"
2004-01-29 01:46:08 +00:00
#include "RageLog.h"
2005-02-21 06:22:46 +00:00
#include "UnlockManager.h"
2004-09-21 06:07:12 +00:00
#include "ScreenDimensions.h"
2005-04-15 08:05:29 +00:00
#include "PercentageDisplay.h"
2003-01-26 07:33:03 +00:00
2008-11-24 03:56:54 +00:00
static const char * RankingPageTypeNames [] = {
2004-05-02 03:01:27 +00:00
"Category" ,
"Course" ,
"AllSteps" ,
2005-05-05 19:29:29 +00:00
"NonstopCourses" ,
"OniCourses" ,
"SurvivalCourses" ,
2006-06-12 09:14:20 +00:00
"AllCourses" ,
2004-05-02 03:01:27 +00:00
};
2008-11-24 03:56:54 +00:00
StringToX ( RankingPageType );
2004-01-29 01:46:08 +00:00
2005-03-28 08:01:36 +00:00
AutoScreenMessage ( SM_ShowNextPage )
AutoScreenMessage ( SM_HidePage )
2003-01-26 20:49:05 +00:00
2003-01-26 07:33:03 +00:00
2005-04-25 22:44:32 +00:00
static void GetAllSongsToShow ( vector < Song *> & vpOut , bool bShowOnlyMostRecentScores , int iNumMostRecentScoresToShow )
2005-03-27 03:00:39 +00:00
{
vpOut . clear ();
2007-04-07 05:36:40 +00:00
FOREACH_CONST ( Song * , SONGMAN -> GetSongs (), s )
2005-03-27 03:00:39 +00:00
{
2007-08-13 21:20:51 +00:00
if ( ! ( * s ) -> NormallyDisplayed () )
2005-03-27 03:00:39 +00:00
continue ; // skip
if ( ! ( * s ) -> ShowInDemonstrationAndRanking () )
continue ; // skip
vpOut . push_back ( * s );
}
2005-04-25 22:44:32 +00:00
if ( bShowOnlyMostRecentScores )
{
2005-06-15 02:02:06 +00:00
SongUtil :: SortSongPointerArrayByTitle ( vpOut );
2005-04-25 22:44:32 +00:00
SongUtil :: SortByMostRecentlyPlayedForMachine ( vpOut );
2005-04-26 10:28:20 +00:00
if ( ( int ) vpOut . size () > iNumMostRecentScoresToShow )
2005-04-25 22:44:32 +00:00
vpOut . erase ( vpOut . begin () + iNumMostRecentScoresToShow , vpOut . end () );
}
2005-03-27 03:00:39 +00:00
}
2005-05-05 19:29:29 +00:00
static void GetAllCoursesToShow ( vector < Course *> & vpOut , CourseType ct , bool bShowOnlyMostRecentScores , int iNumMostRecentScoresToShow )
2005-03-27 03:00:39 +00:00
{
vpOut . clear ();
vector < Course *> vpCourses ;
2006-10-07 04:25:28 +00:00
if ( ct == CourseType_Invalid )
2006-06-12 09:14:20 +00:00
SONGMAN -> GetAllCourses ( vpCourses , false );
else
SONGMAN -> GetCourses ( ct , vpCourses , false );
2005-03-27 03:00:39 +00:00
FOREACH_CONST ( Course * , vpCourses , c )
{
if ( UNLOCKMAN -> CourseIsLocked ( * c ) )
continue ; // skip
if ( ! ( * c ) -> ShowInDemonstrationAndRanking () )
continue ; // skip
vpOut . push_back ( * c );
}
2005-04-25 22:44:32 +00:00
if ( bShowOnlyMostRecentScores )
{
2005-06-15 02:02:06 +00:00
CourseUtil :: SortCoursePointerArrayByTitle ( vpOut );
2005-04-25 22:44:32 +00:00
CourseUtil :: SortByMostRecentlyPlayedForMachine ( vpOut );
2005-04-26 10:28:20 +00:00
if ( ( int ) vpOut . size () > iNumMostRecentScoresToShow )
2005-04-25 22:44:32 +00:00
vpOut . erase ( vpOut . begin () + iNumMostRecentScoresToShow , vpOut . end () );
}
2005-03-27 03:00:39 +00:00
}
2006-01-22 01:00:06 +00:00
static RString STEPS_TYPE_COLOR_NAME ( size_t i ) { return ssprintf ( "StepsTypeColor%d" , int ( i + 1 )); }
2005-02-28 17:18:01 +00:00
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS ( ScreenRanking );
REGISTER_SCREEN_CLASS ( ScreenRankingScroller );
REGISTER_SCREEN_CLASS ( ScreenRankingLines );
2005-09-27 19:10:09 +00:00
2005-02-23 06:29:05 +00:00
void ScreenRanking :: Init ()
{
2008-11-24 03:56:54 +00:00
RANKING_PAGE_TYPE . Load ( m_sName , "RankingPageType" );
COURSES_TO_SHOW . Load ( m_sName , "CoursesToShow" );
STEPS_TYPES_TO_SHOW . Load ( m_sName , "StepsTypesToHide" ); // tricky: The metric name is "hide" because ThemeMetricStepsTypesToShow takes a list of what to hide and returns what StepsTypes to show
SECONDS_PER_PAGE . Load ( m_sName , "SecondsPerPage" );
PAGE_FADE_SECONDS . Load ( m_sName , "PageFadeSeconds" );
MANUAL_SCROLLING . Load ( m_sName , "ManualScrolling" );
2005-10-07 03:28:47 +00:00
2005-02-23 06:29:05 +00:00
ScreenAttract :: Init ();
2008-11-24 03:56:54 +00:00
m_RankingPageType = StringToRankingPageType ( RANKING_PAGE_TYPE );
2005-09-21 19:13:13 +00:00
2005-09-21 21:14:09 +00:00
m_textStepsType . SetName ( "StepsType" );
m_textStepsType . LoadFromFont ( THEME -> GetPathF ( m_sName , "steps type" ) );
m_textStepsType . SetShadowLength ( 0 );
this -> AddChild ( & m_textStepsType );
2007-05-02 00:09:16 +00:00
LOAD_ALL_COMMANDS ( m_textStepsType );
2005-09-27 19:10:09 +00:00
}
void ScreenRanking :: BeginScreen ()
{
m_iNextPageToShow = 0 ;
ScreenAttract :: BeginScreen ();
this -> HandleScreenMessage ( SM_ShowNextPage );
}
void ScreenRanking :: Input ( const InputEventPlus & input )
{
LOG -> Trace ( "ScreenRanking::Input()" );
2006-05-26 09:55:25 +00:00
if ( IsTransitioning () )
return ;
2005-09-27 19:10:09 +00:00
// If manually scrolling, then pass the input to Scree::Input so it will call Menu*
if ( ( bool ) MANUAL_SCROLLING )
Screen :: Input ( input );
else
ScreenAttract :: Input ( input );
}
2006-09-15 01:47:24 +00:00
void ScreenRanking :: MenuStart ( const InputEventPlus & input )
2005-09-27 19:10:09 +00:00
{
2007-06-18 16:57:19 +00:00
if ( ! MANUAL_SCROLLING )
return ;
2005-09-27 19:10:09 +00:00
if ( ! IsTransitioning () )
2005-10-13 22:17:13 +00:00
StartTransitioningScreen ( SM_GoToNextScreen );
2005-10-18 03:41:12 +00:00
SCREENMAN -> PlayStartSound ();
2005-09-27 19:10:09 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenRanking :: MenuBack ( const InputEventPlus & input )
2005-09-27 19:10:09 +00:00
{
2007-06-18 16:57:19 +00:00
if ( ! MANUAL_SCROLLING )
return ;
2005-09-27 19:10:09 +00:00
if ( ! IsTransitioning () )
2005-10-13 22:17:13 +00:00
StartTransitioningScreen ( SM_GoToNextScreen );
2005-10-18 03:41:12 +00:00
SCREENMAN -> PlayStartSound ();
2005-09-27 19:10:09 +00:00
}
void ScreenRanking :: HandleScreenMessage ( const ScreenMessage SM )
{
if ( SM == SM_ShowNextPage )
{
if ( m_iNextPageToShow < m_vPagesToShow . size () )
{
float fSecsToShow = SetPage ( m_vPagesToShow [ m_iNextPageToShow ] );
++ m_iNextPageToShow ;
this -> SortByDrawOrder ();
// If manually scrolling, don't automatically change pages.
if ( ! ( bool ) MANUAL_SCROLLING )
this -> PostScreenMessage ( SM_HidePage , fSecsToShow - PAGE_FADE_SECONDS );
}
else
{
2005-10-13 22:17:13 +00:00
StartTransitioningScreen ( SM_GoToNextScreen );
2005-09-27 19:10:09 +00:00
}
}
else if ( SM == SM_HidePage )
{
this -> PlayCommand ( "SwitchPage" );
this -> PostScreenMessage ( SM_ShowNextPage , PAGE_FADE_SECONDS );
}
ScreenAttract :: HandleScreenMessage ( SM );
}
float ScreenRanking :: SetPage ( const PageToShow & pts )
{
// This is going to take a while to load. Possibly longer than one frame.
// So, zero the next update so we don't skip.
SCREENMAN -> ZeroNextUpdate ();
//
// init page
//
2008-03-24 04:39:24 +00:00
StepsType st = pts . aTypes . front (). second ;
2008-03-24 08:53:05 +00:00
m_textStepsType . SetText ( GameManager :: GetStepsTypeInfo ( st ). GetLocalizedString () );
2005-09-27 19:10:09 +00:00
return 0 ;
}
2006-03-27 10:58:37 +00:00
void ScreenRankingScroller :: DoScroll ( int iDir )
{
2007-05-02 22:43:45 +00:00
if ( ! m_ListScoreRowItems . Scroll ( iDir ) )
iDir = 0 ;
Message msg ( "Scrolled" );
msg . SetParam ( "Dir" , iDir );
this -> HandleMessage ( msg );
2006-03-27 10:58:37 +00:00
}
/////////////////////////////////////////////
2005-09-27 19:10:09 +00:00
ScoreScroller :: ScoreScroller ()
{
this -> DeleteChildrenWhenDone ();
}
2007-05-02 22:43:45 +00:00
void ScoreScroller :: SetDisplay ( const vector < DifficultyAndStepsType > & DifficultiesToShow )
2005-09-27 19:10:09 +00:00
{
2007-05-02 22:43:45 +00:00
m_DifficultiesToShow = DifficultiesToShow ;
2005-09-27 19:10:09 +00:00
ShiftSubActors ( INT_MAX );
}
2006-03-27 10:58:37 +00:00
bool ScoreScroller :: Scroll ( int iDir )
2005-09-27 19:10:09 +00:00
{
2007-05-02 22:43:45 +00:00
if ( ( int ) m_vScoreRowItemData . size () <= SONG_SCORE_ROWS_TO_DRAW )
2006-03-27 10:58:37 +00:00
return false ;
2005-09-27 19:10:09 +00:00
float fDest = GetDestinationItem ();
float fOldDest = fDest ;
fDest += iDir ;
2007-05-02 22:43:45 +00:00
float fLowClamp = ( SONG_SCORE_ROWS_TO_DRAW - 1 ) / 2.0f ;
float fHighClamp = m_vScoreRowItemData . size () - ( SONG_SCORE_ROWS_TO_DRAW - 1 ) / 2.0f - 1 ;
2006-03-27 10:58:37 +00:00
CLAMP ( fDest , fLowClamp , fHighClamp );
2005-09-27 19:10:09 +00:00
if ( fOldDest != fDest )
{
SetDestinationItem ( fDest );
2006-03-27 10:58:37 +00:00
return true ;
}
else
{
2006-03-28 04:02:36 +00:00
return false ;
2005-09-27 19:10:09 +00:00
}
}
void ScoreScroller :: ScrollTop ()
{
2007-05-02 22:43:45 +00:00
SetCurrentAndDestinationItem ( ( SONG_SCORE_ROWS_TO_DRAW - 1 ) / 2.0f );
2005-09-27 19:10:09 +00:00
}
void ScoreScroller :: ConfigureActor ( Actor * pActor , int iItem )
{
2007-05-02 22:43:45 +00:00
Actor & item = * dynamic_cast < Actor *> ( pActor );
const ScoreRowItemData & data = m_vScoreRowItemData [ iItem ];
Message msg ( "Set" );
2005-09-27 19:10:09 +00:00
if ( data . m_pSong != NULL )
2007-05-02 22:43:45 +00:00
msg . SetParam ( "Song" , data . m_pSong );
if ( data . m_pCourse != NULL )
msg . SetParam ( "Course" , data . m_pCourse );
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
Lua * L = LUA -> Get ();
lua_newtable ( L );
lua_pushvalue ( L , - 1 );
msg . SetParamFromStack ( L , "Entries" );
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
FOREACH ( DifficultyAndStepsType , m_DifficultiesToShow , iter )
{
Difficulty dc = iter -> first ;
StepsType st = iter -> second ;
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
if ( data . m_pSong != NULL )
2005-09-27 19:10:09 +00:00
{
2007-05-02 22:43:45 +00:00
const Song * pSong = data . m_pSong ;
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
Steps * pSteps = SongUtil :: GetStepsByDifficulty ( pSong , st , dc , false );
if ( pSteps && UNLOCKMAN -> StepsIsLocked ( pSong , pSteps ) )
2005-09-27 19:10:09 +00:00
continue ;
2007-05-02 22:43:45 +00:00
LuaHelpers :: Push ( L , pSteps );
lua_rawseti ( L , - 2 , lua_objlen ( L , - 2 ) + 1 );
}
else if ( data . m_pCourse != NULL )
{
const Course * pCourse = data . m_pCourse ;
Trail * pTrail = pCourse -> GetTrail ( st , dc );
if ( UNLOCKMAN -> CourseIsLocked ( pCourse ) )
continue ;
LuaHelpers :: Push ( L , pTrail );
lua_rawseti ( L , - 2 , lua_objlen ( L , - 2 ) + 1 );
2005-09-27 19:10:09 +00:00
}
}
2007-05-02 22:43:45 +00:00
lua_pop ( L , 1 );
LUA -> Release ( L );
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
item . HandleMessage ( msg );
2005-09-27 19:10:09 +00:00
}
void ScoreScroller :: LoadSongs ( bool bOnlyRecentScores , int iNumRecentScores )
{
vector < Song *> vpSongs ;
GetAllSongsToShow ( vpSongs , bOnlyRecentScores , iNumRecentScores );
m_vScoreRowItemData . resize ( vpSongs . size () );
for ( unsigned i = 0 ; i < m_vScoreRowItemData . size (); ++ i )
m_vScoreRowItemData [ i ]. m_pSong = vpSongs [ i ];
}
void ScoreScroller :: LoadCourses ( CourseType ct , bool bOnlyRecentScores , int iNumRecentScores )
{
vector < Course *> vpCourses ;
GetAllCoursesToShow ( vpCourses , ct , bOnlyRecentScores , iNumRecentScores );
m_vScoreRowItemData . resize ( vpCourses . size () );
for ( unsigned i = 0 ; i < m_vScoreRowItemData . size (); ++ i )
m_vScoreRowItemData [ i ]. m_pCourse = vpCourses [ i ];
}
2007-05-02 22:43:45 +00:00
void ScoreScroller :: Load ( RString sClassName )
2005-09-27 19:10:09 +00:00
{
2007-05-02 22:43:45 +00:00
SONG_SCORE_ROWS_TO_DRAW . Load ( sClassName , "SongScoreRowsToDraw" );
2005-09-27 19:10:09 +00:00
2007-05-02 22:43:45 +00:00
int iNumCopies = SONG_SCORE_ROWS_TO_DRAW + 1 ;
for ( int i = 0 ; i < iNumCopies ; ++ i )
2005-09-27 19:10:09 +00:00
{
2007-05-02 22:43:45 +00:00
Actor * pActor = ActorUtil :: MakeActor ( THEME -> GetPathG ( sClassName , "list item" ) );
this -> AddChild ( pActor );
2005-09-27 19:10:09 +00:00
}
2007-05-02 22:43:45 +00:00
DynamicActorScroller :: SetNumItemsToDraw ( ( float ) SONG_SCORE_ROWS_TO_DRAW );
2006-08-16 18:31:00 +00:00
DynamicActorScroller :: Load2 ();
2005-09-27 19:10:09 +00:00
m_iNumItems = m_vScoreRowItemData . size ();
}
void ScreenRankingScroller :: Init ()
{
2007-05-02 22:43:45 +00:00
ThemeMetric < bool > SHOW_ONLY_MOST_RECENT_SCORES ;
ThemeMetric < RString > DIFFICULTIES_TO_SHOW ;
ThemeMetric < int > NUM_MOST_RECENT_SCORES_TO_SHOW ;
SHOW_ONLY_MOST_RECENT_SCORES . Load ( m_sName , "ShowOnlyMostRecentScores" );
2006-01-15 19:13:38 +00:00
DIFFICULTIES_TO_SHOW . Load ( m_sName , "DifficultiesToShow" );
NUM_MOST_RECENT_SCORES_TO_SHOW . Load ( m_sName , "NumMostRecentScoresToShow" );
2005-09-27 19:10:09 +00:00
ScreenRanking :: Init ();
m_ListScoreRowItems . SetName ( "ListScoreRowItems" );
2007-05-01 21:20:14 +00:00
LOAD_ALL_COMMANDS ( m_ListScoreRowItems );
2008-11-24 03:56:54 +00:00
switch ( m_RankingPageType )
2005-09-27 19:10:09 +00:00
{
2006-06-12 09:14:20 +00:00
default : ASSERT ( 0 );
2008-11-24 03:56:54 +00:00
case RankingPageType_AllSteps :
2006-06-12 09:14:20 +00:00
m_ListScoreRowItems . LoadSongs ( SHOW_ONLY_MOST_RECENT_SCORES , NUM_MOST_RECENT_SCORES_TO_SHOW );
break ;
2008-11-24 03:56:54 +00:00
case RankingPageType_NonstopCourses :
case RankingPageType_OniCourses :
case RankingPageType_SurvivalCourses :
case RankingPageType_AllCourses :
2006-06-12 09:14:20 +00:00
{
CourseType ct ;
2008-11-24 03:56:54 +00:00
switch ( m_RankingPageType )
2006-06-12 09:14:20 +00:00
{
default : ASSERT ( 0 );
2008-11-24 03:56:54 +00:00
case RankingPageType_NonstopCourses : ct = COURSE_TYPE_NONSTOP ; break ;
case RankingPageType_OniCourses : ct = COURSE_TYPE_ONI ; break ;
case RankingPageType_SurvivalCourses : ct = COURSE_TYPE_SURVIVAL ; break ;
case RankingPageType_AllCourses : ct = CourseType_Invalid ; break ;
2006-06-12 09:14:20 +00:00
}
m_ListScoreRowItems . LoadCourses ( ct , SHOW_ONLY_MOST_RECENT_SCORES , NUM_MOST_RECENT_SCORES_TO_SHOW );
}
break ;
2005-09-27 19:10:09 +00:00
}
2007-05-02 22:43:45 +00:00
m_ListScoreRowItems . Load ( m_sName );
2005-09-27 19:10:09 +00:00
this -> AddChild ( & m_ListScoreRowItems );
for ( unsigned i = 0 ; i < STEPS_TYPES_TO_SHOW . GetValue (). size (); i ++ )
{
2007-05-02 22:43:45 +00:00
vector < RString > asDifficulties ;
split ( DIFFICULTIES_TO_SHOW , "," , asDifficulties );
2005-09-27 19:10:09 +00:00
PageToShow pts ;
2007-05-02 22:43:45 +00:00
for ( unsigned d = 0 ; d < asDifficulties . size (); ++ d )
{
vector < RString > asBits ;
split ( asDifficulties [ d ], ":" , asBits , false );
ASSERT ( ! asBits . empty () );
Difficulty dc = StringToDifficulty ( asBits [ 0 ]);
StepsType st = STEPS_TYPES_TO_SHOW . GetValue ()[ i ];
if ( asBits . size () > 1 )
2008-03-24 12:50:16 +00:00
st = GameManager :: StringToStepsType ( asBits [ 1 ] );
2007-05-02 22:43:45 +00:00
pts . aTypes . push_back ( make_pair ( dc , st ) );
}
2005-09-27 19:10:09 +00:00
m_vPagesToShow . push_back ( pts );
}
}
float ScreenRankingScroller :: SetPage ( const PageToShow & pts )
{
ScreenRanking :: SetPage ( pts );
2007-05-02 22:43:45 +00:00
m_ListScoreRowItems . SetDisplay ( pts . aTypes );
2005-09-27 19:10:09 +00:00
if ( ( bool ) MANUAL_SCROLLING )
m_ListScoreRowItems . ScrollTop ();
else
m_ListScoreRowItems . ScrollThroughAllItems ();
return m_ListScoreRowItems . GetSecondsForCompleteScrollThrough ();
}
2008-11-24 03:56:54 +00:00
// RankingPageType_Category:
// RankingPageType_OneCourse:
2005-09-27 19:10:09 +00:00
#define BULLET_X(row) (BULLET_START_X+ROW_SPACING_X*row)
#define BULLET_Y(row) (BULLET_START_Y+ROW_SPACING_Y*row)
2007-05-01 23:52:59 +00:00
#define NAME_X(row) (NAME_START_X+ROW_SPACING_X*row)
#define NAME_Y(row) (NAME_START_Y+ROW_SPACING_Y*row)
2005-09-27 19:10:09 +00:00
#define SCORE_X(row) (SCORE_START_X+ROW_SPACING_X*row)
#define SCORE_Y(row) (SCORE_START_Y+ROW_SPACING_Y*row)
#define POINTS_X(row) (POINTS_START_X+ROW_SPACING_X*row)
#define POINTS_Y(row) (POINTS_START_Y+ROW_SPACING_Y*row)
2007-05-01 23:52:59 +00:00
#define TIME_X(row) (TIME_START_X+ROW_SPACING_X*row)
#define TIME_Y(row) (TIME_START_Y+ROW_SPACING_Y*row)
2005-09-27 19:10:09 +00:00
void ScreenRankingLines :: Init ()
{
2007-05-02 22:43:45 +00:00
NO_SCORE_NAME . Load ( m_sName , "NoScoreName" );
ROW_SPACING_X . Load ( m_sName , "RowSpacingX" );
ROW_SPACING_Y . Load ( m_sName , "RowSpacingY" );
2006-01-15 19:13:38 +00:00
BULLET_START_X . Load ( m_sName , "BulletStartX" );
BULLET_START_Y . Load ( m_sName , "BulletStartY" );
NAME_START_X . Load ( m_sName , "NameStartX" );
NAME_START_Y . Load ( m_sName , "NameStartY" );
SCORE_START_X . Load ( m_sName , "ScoreStartX" );
SCORE_START_Y . Load ( m_sName , "ScoreStartY" );
POINTS_START_X . Load ( m_sName , "PointsStartX" );
POINTS_START_Y . Load ( m_sName , "PointsStartY" );
TIME_START_X . Load ( m_sName , "TimeStartX" );
TIME_START_Y . Load ( m_sName , "TimeStartY" );
2007-05-02 22:43:45 +00:00
STEPS_TYPE_COLOR . Load ( m_sName , STEPS_TYPE_COLOR_NAME , 5 );
2006-01-15 19:13:38 +00:00
2005-09-27 19:10:09 +00:00
ScreenRanking :: Init ();
2003-10-19 02:05:34 +00:00
2008-11-24 03:56:54 +00:00
if ( m_RankingPageType == RankingPageType_Category )
2003-01-26 07:33:03 +00:00
{
2005-09-21 21:14:09 +00:00
m_textCategory . SetName ( "Category" );
m_textCategory . LoadFromFont ( THEME -> GetPathF ( m_sName , "category" ) );
m_textCategory . SetShadowLength ( 0 );
this -> AddChild ( & m_textCategory );
2007-05-01 21:20:14 +00:00
LOAD_ALL_COMMANDS ( m_textCategory );
2005-09-21 21:14:09 +00:00
2005-03-24 21:44:03 +00:00
for ( unsigned i = 0 ; i < STEPS_TYPES_TO_SHOW . GetValue (). size (); i ++ )
2003-01-26 07:33:03 +00:00
{
2006-09-26 20:49:10 +00:00
for ( int c = 0 ; c < NUM_RankingCategory ; c ++ )
2003-01-26 07:33:03 +00:00
{
2003-01-26 20:49:05 +00:00
PageToShow pts ;
2003-04-13 02:34:14 +00:00
pts . colorIndex = i ;
2003-01-26 20:49:05 +00:00
pts . category = ( RankingCategory ) c ;
2007-05-02 22:43:45 +00:00
StepsType st = STEPS_TYPES_TO_SHOW . GetValue ()[ i ];
pts . aTypes . push_back ( make_pair ( Difficulty_Invalid , st ) );
2003-01-26 20:49:05 +00:00
m_vPagesToShow . push_back ( pts );
2003-01-26 07:33:03 +00:00
}
}
}
2008-11-24 03:56:54 +00:00
if ( m_RankingPageType == RankingPageType_OneCourse )
2005-09-21 21:14:09 +00:00
{
m_Banner . SetName ( "Banner" );
this -> AddChild ( & m_Banner );
2007-05-01 21:20:14 +00:00
LOAD_ALL_COMMANDS ( m_Banner );
2005-09-21 21:14:09 +00:00
m_textCourseTitle . SetName ( "CourseTitle" );
m_textCourseTitle . LoadFromFont ( THEME -> GetPathF ( m_sName , "course title" ) );
m_textCourseTitle . SetShadowLength ( 0 );
this -> AddChild ( & m_textCourseTitle );
2007-05-01 21:20:14 +00:00
LOAD_ALL_COMMANDS ( m_textCourseTitle );
2005-09-21 21:14:09 +00:00
2006-01-22 01:00:06 +00:00
vector < RString > asCoursePaths ;
2003-01-26 21:45:13 +00:00
split ( COURSES_TO_SHOW , "," , asCoursePaths , true );
2005-03-24 21:44:03 +00:00
for ( unsigned i = 0 ; i < STEPS_TYPES_TO_SHOW . GetValue (). size (); i ++ )
2003-01-26 07:33:03 +00:00
{
2003-01-26 21:45:13 +00:00
for ( unsigned c = 0 ; c < asCoursePaths . size (); c ++ )
{
PageToShow pts ;
2003-04-13 02:34:14 +00:00
pts . colorIndex = i ;
2007-05-02 22:43:45 +00:00
StepsType st = STEPS_TYPES_TO_SHOW . GetValue ()[ i ];
pts . aTypes . push_back ( make_pair ( Difficulty_Invalid , st ) );
2003-01-26 21:45:13 +00:00
pts . pCourse = SONGMAN -> GetCourseFromPath ( asCoursePaths [ c ] );
2004-06-03 20:47:37 +00:00
if ( pts . pCourse == NULL )
continue ;
2007-05-02 22:43:45 +00:00
pts . pTrail = pts . pCourse -> GetTrail ( st );
2004-06-03 20:47:37 +00:00
if ( pts . pTrail == NULL )
continue ;
m_vPagesToShow . push_back ( pts );
2003-01-26 21:45:13 +00:00
}
2003-01-26 07:33:03 +00:00
}
}
2005-09-27 19:10:09 +00:00
for ( int l = 0 ; l < NUM_RANKING_LINES ; l ++ )
{
m_sprBullets [ l ]. Load ( THEME -> GetPathG ( m_sName , ssprintf ( "bullets 1x%d" , NUM_RANKING_LINES ) ) );
m_sprBullets [ l ] -> SetName ( ssprintf ( "Bullet%d" , l + 1 ) );
m_sprBullets [ l ] -> StopAnimating ();
m_sprBullets [ l ] -> SetState ( l );
m_sprBullets [ l ] -> SetXY ( BULLET_X ( l ), BULLET_Y ( l ) );
ActorUtil :: LoadAllCommands ( * m_sprBullets [ l ], m_sName );
this -> AddChild ( m_sprBullets [ l ] );
m_textNames [ l ]. SetName ( ssprintf ( "Name%d" , l + 1 ) );
m_textNames [ l ]. LoadFromFont ( THEME -> GetPathF ( m_sName , "name" ) );
m_textNames [ l ]. SetXY ( NAME_X ( l ), NAME_Y ( l ) );
ActorUtil :: LoadAllCommands ( m_textNames [ l ], m_sName );
this -> AddChild ( & m_textNames [ l ] );
m_textScores [ l ]. SetName ( ssprintf ( "Score%d" , l + 1 ) );
m_textScores [ l ]. LoadFromFont ( THEME -> GetPathF ( m_sName , "score" ) );
m_textScores [ l ]. SetXY ( SCORE_X ( l ), SCORE_Y ( l ) );
ActorUtil :: LoadAllCommands ( m_textScores [ l ], m_sName );
this -> AddChild ( & m_textScores [ l ] );
m_textPoints [ l ]. SetName ( ssprintf ( "Points%d" , l + 1 ) );
m_textPoints [ l ]. LoadFromFont ( THEME -> GetPathF ( m_sName , "points" ) );
2007-02-13 06:32:26 +00:00
m_textPoints [ l ]. SetVisible ( false );
2005-09-27 19:10:09 +00:00
m_textPoints [ l ]. SetXY ( POINTS_X ( l ), POINTS_Y ( l ) );
ActorUtil :: LoadAllCommands ( m_textPoints [ l ], m_sName );
this -> AddChild ( & m_textPoints [ l ] );
m_textTime [ l ]. SetName ( ssprintf ( "Time%d" , l + 1 ) );
m_textTime [ l ]. LoadFromFont ( THEME -> GetPathF ( m_sName , "time" ) );
2007-02-13 06:32:26 +00:00
m_textTime [ l ]. SetVisible ( false );
2005-09-27 19:10:09 +00:00
m_textTime [ l ]. SetXY ( TIME_X ( l ), TIME_Y ( l ) );
ActorUtil :: LoadAllCommands ( m_textTime [ l ], m_sName );
this -> AddChild ( & m_textTime [ l ] );
}
}
float ScreenRankingLines :: SetPage ( const PageToShow & pts )
{
ScreenRanking :: SetPage ( pts );
bool bShowScores = false ;
bool bShowPoints = false ;
bool bShowTime = false ;
2008-11-24 03:56:54 +00:00
switch ( m_RankingPageType )
2005-09-21 21:42:07 +00:00
{
2008-11-24 03:56:54 +00:00
case RankingPageType_Category :
2005-09-27 19:10:09 +00:00
bShowScores = true ;
break ;
2008-11-24 03:56:54 +00:00
case RankingPageType_OneCourse :
2005-09-27 19:10:09 +00:00
bShowScores = ! pts . pCourse -> IsOni ();
bShowPoints = pts . pCourse -> IsOni ();
bShowTime = pts . pCourse -> IsOni ();
break ;
2005-09-21 21:42:07 +00:00
}
2005-09-27 19:10:09 +00:00
for ( int l = 0 ; l < NUM_RANKING_LINES ; l ++ )
2003-10-14 17:06:30 +00:00
{
2005-09-27 19:10:09 +00:00
m_textNames [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2007-02-13 06:32:26 +00:00
m_textScores [ l ]. SetVisible ( bShowScores );
2005-09-27 19:10:09 +00:00
m_textScores [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2007-02-13 06:32:26 +00:00
m_textPoints [ l ]. SetVisible ( bShowPoints );
2005-09-27 19:10:09 +00:00
m_textPoints [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2007-02-13 06:32:26 +00:00
m_textTime [ l ]. SetVisible ( bShowTime );
2005-09-27 19:10:09 +00:00
m_textTime [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2003-10-14 17:06:30 +00:00
}
2008-11-24 03:56:54 +00:00
switch ( m_RankingPageType )
2003-01-26 07:33:03 +00:00
{
2008-11-24 03:56:54 +00:00
case RankingPageType_Category :
2003-01-26 07:33:03 +00:00
{
2003-12-28 08:20:48 +00:00
m_textCategory . SetText ( ssprintf ( "Type %c" , 'A' + pts . category ) );
2003-10-22 09:45:23 +00:00
2003-01-27 02:00:38 +00:00
for ( int l = 0 ; l < NUM_RANKING_LINES ; l ++ )
2003-01-26 07:33:03 +00:00
{
2007-05-02 22:43:45 +00:00
StepsType st = pts . aTypes . front (). second ;
HighScoreList & hsl = PROFILEMAN -> GetMachineProfile () -> GetCategoryHighScoreList ( st , pts . category );
2004-02-09 06:26:13 +00:00
HighScore hs ;
2003-12-28 08:20:48 +00:00
bool bRecentHighScore = false ;
2004-02-09 06:26:13 +00:00
if ( l < ( int ) hsl . vHighScores . size () )
2003-12-28 08:20:48 +00:00
{
2004-02-09 06:26:13 +00:00
hs = hsl . vHighScores [ l ];
2006-01-22 01:00:06 +00:00
RString * psName = hsl . vHighScores [ l ]. GetNameMutable ();
2003-12-28 08:20:48 +00:00
bRecentHighScore = find ( GAMESTATE -> m_vpsNamesThatWereFilled . begin (), GAMESTATE -> m_vpsNamesThatWereFilled . end (), psName ) != GAMESTATE -> m_vpsNamesThatWereFilled . end ();
}
2003-12-24 23:38:56 +00:00
else
2003-12-28 08:20:48 +00:00
{
2005-08-12 01:52:01 +00:00
hs . SetName ( NO_SCORE_NAME );
2003-12-28 08:20:48 +00:00
}
2003-10-14 17:06:30 +00:00
2004-03-08 02:50:46 +00:00
m_textNames [ l ]. SetText ( hs . GetDisplayName () );
2005-08-12 02:37:04 +00:00
m_textScores [ l ]. SetText ( ssprintf ( "%09i" , hs . GetScore ()) );
2005-02-28 17:18:01 +00:00
m_textNames [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
m_textScores [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2003-02-03 05:53:59 +00:00
if ( bRecentHighScore )
{
2003-03-02 01:43:33 +00:00
m_textNames [ l ]. SetEffectGlowBlink ( 0.1f );
m_textScores [ l ]. SetEffectGlowBlink ( 0.1f );
2003-02-03 05:53:59 +00:00
}
else
{
2005-07-24 03:11:03 +00:00
m_textNames [ l ]. StopEffect ();
m_textScores [ l ]. StopEffect ();
2003-01-27 02:00:38 +00:00
}
2003-01-26 07:33:03 +00:00
}
}
2003-12-28 08:20:48 +00:00
return SECONDS_PER_PAGE ;
2008-11-24 03:56:54 +00:00
case RankingPageType_OneCourse :
2003-01-26 07:33:03 +00:00
{
2005-05-23 00:38:09 +00:00
m_textCourseTitle . SetText ( pts . pCourse -> GetDisplayFullTitle () );
2005-09-21 20:16:53 +00:00
2003-12-28 08:20:48 +00:00
m_Banner . LoadFromCourse ( pts . pCourse );
2003-07-16 02:32:37 +00:00
2004-06-03 20:47:37 +00:00
const HighScoreList & hsl = PROFILEMAN -> GetMachineProfile () -> GetCourseHighScoreList ( pts . pCourse , pts . pTrail );
2003-01-27 02:00:38 +00:00
for ( int l = 0 ; l < NUM_RANKING_LINES ; l ++ )
2003-01-26 07:33:03 +00:00
{
2004-02-09 06:26:13 +00:00
HighScore hs ;
2003-12-28 08:20:48 +00:00
bool bRecentHighScore = false ;
2004-02-09 06:26:13 +00:00
if ( l < ( int ) hsl . vHighScores . size () )
2003-12-28 08:20:48 +00:00
{
2004-02-09 06:26:13 +00:00
hs = hsl . vHighScores [ l ];
2006-01-22 01:00:06 +00:00
const RString * psName = hsl . vHighScores [ l ]. GetNameMutable ();
2003-12-28 08:20:48 +00:00
bRecentHighScore = find ( GAMESTATE -> m_vpsNamesThatWereFilled . begin (), GAMESTATE -> m_vpsNamesThatWereFilled . end (), psName ) != GAMESTATE -> m_vpsNamesThatWereFilled . end ();
}
2003-12-24 23:38:56 +00:00
else
2003-12-28 08:20:48 +00:00
{
2005-08-12 01:52:01 +00:00
hs . SetName ( NO_SCORE_NAME );
2003-12-28 08:20:48 +00:00
}
2004-02-09 06:26:13 +00:00
2004-03-08 02:50:46 +00:00
m_textNames [ l ]. SetText ( hs . GetDisplayName () );
2003-06-30 08:06:47 +00:00
if ( pts . pCourse -> IsOni () )
{
2005-08-12 02:37:04 +00:00
m_textPoints [ l ]. SetText ( ssprintf ( "%04d" , hs . GetScore ()) );
2005-08-12 02:46:58 +00:00
m_textTime [ l ]. SetText ( SecondsToMMSSMsMs ( hs . GetSurviveSeconds ()) );
2003-06-30 08:06:47 +00:00
m_textScores [ l ]. SetText ( "" );
} else {
m_textPoints [ l ]. SetText ( "" );
m_textTime [ l ]. SetText ( "" );
2005-08-12 02:37:04 +00:00
m_textScores [ l ]. SetText ( ssprintf ( "%09d" , hs . GetScore ()) );
2003-06-30 08:06:47 +00:00
}
2005-02-28 17:18:01 +00:00
m_textNames [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
m_textPoints [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
m_textTime [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
m_textScores [ l ]. SetDiffuse ( STEPS_TYPE_COLOR . GetValue ( pts . colorIndex ) );
2003-12-28 08:20:48 +00:00
if ( bRecentHighScore )
2003-01-27 02:00:38 +00:00
{
2003-12-28 08:20:48 +00:00
m_textNames [ l ]. SetEffectGlowBlink ( 0.1f );
m_textScores [ l ]. SetEffectGlowBlink ( 0.1f );
}
else
{
2005-07-24 03:11:03 +00:00
m_textNames [ l ]. StopEffect ();
m_textScores [ l ]. StopEffect ();
2003-01-27 02:00:38 +00:00
}
2003-01-26 07:33:03 +00:00
}
}
2003-12-28 08:20:48 +00:00
return SECONDS_PER_PAGE ;
2003-01-26 07:33:03 +00:00
default :
ASSERT ( 0 );
2003-12-28 08:20:48 +00:00
return 0 ;
2003-01-26 07:33:03 +00:00
}
2003-01-26 20:49:05 +00:00
}
2003-01-26 07:33:03 +00:00
2005-09-27 19:10:09 +00:00
void ScreenRankingLines :: BeginScreen ()
{
ScreenRanking :: BeginScreen ();
}
2004-06-08 05:22:33 +00:00
/*
2007-05-02 22:43:45 +00:00
* (c) 2001-2007 Chris Danford, Glenn Maynard
2004-06-08 05:22:33 +00:00
* 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.
*/