optimize, simplify
This commit is contained in:
@@ -67,11 +67,11 @@ void ActorScroller::Load2(
|
|||||||
m_bLoop = bLoop;
|
m_bLoop = bLoop;
|
||||||
m_fSecondsPerItem = fSecondsPerItem;
|
m_fSecondsPerItem = fSecondsPerItem;
|
||||||
m_fSecondsPauseBetweenItems = fSecondsPauseBetweenItems;
|
m_fSecondsPauseBetweenItems = fSecondsPauseBetweenItems;
|
||||||
m_fCurrentItem = m_bLoop ? +m_fNumItemsToDraw/2 : -(m_fNumItemsToDraw/2)-1;
|
|
||||||
m_fDestinationItem = (float)(m_SubActors.size()+m_fNumItemsToDraw/2+1);
|
|
||||||
m_fPauseCountdownSeconds = 0;
|
m_fPauseCountdownSeconds = 0;
|
||||||
m_fQuantizePixels = 0;
|
m_fQuantizePixels = 0;
|
||||||
|
|
||||||
|
ScrollThroughAllItems();
|
||||||
|
|
||||||
m_bUseMask = true;
|
m_bUseMask = true;
|
||||||
RectF rectBarSize(
|
RectF rectBarSize(
|
||||||
-m_fMaskWidth/2,
|
-m_fMaskWidth/2,
|
||||||
@@ -106,6 +106,12 @@ void ActorScroller::Load3(
|
|||||||
m_bLoaded = true;
|
m_bLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActorScroller::ScrollThroughAllItems()
|
||||||
|
{
|
||||||
|
m_fCurrentItem = m_bLoop ? +m_fNumItemsToDraw/2 : -(m_fNumItemsToDraw/2)-1;
|
||||||
|
m_fDestinationItem = (float)(m_SubActors.size()+m_fNumItemsToDraw/2+1);
|
||||||
|
}
|
||||||
|
|
||||||
float ActorScroller::GetSecondsForCompleteScrollThrough()
|
float ActorScroller::GetSecondsForCompleteScrollThrough()
|
||||||
{
|
{
|
||||||
float fTotalItems = m_fNumItemsToDraw + m_SubActors.size();
|
float fTotalItems = m_fNumItemsToDraw + m_SubActors.size();
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
|
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
|
||||||
float GetCurrentItem() { return m_fCurrentItem; }
|
float GetCurrentItem() { return m_fCurrentItem; }
|
||||||
float GetDestinationItem() { return m_fDestinationItem; }
|
float GetDestinationItem() { return m_fDestinationItem; }
|
||||||
|
void ScrollThroughAllItems();
|
||||||
void SetPauseCountdownSeconds( float fSecs ) { m_fPauseCountdownSeconds = fSecs; }
|
void SetPauseCountdownSeconds( float fSecs ) { m_fPauseCountdownSeconds = fSecs; }
|
||||||
|
|
||||||
float GetSecondsForCompleteScrollThrough();
|
float GetSecondsForCompleteScrollThrough();
|
||||||
|
|||||||
@@ -230,14 +230,13 @@ void ScreenRanking::Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vScoreRowItem.clear();
|
|
||||||
if( m_PageType == PAGE_TYPE_ALL_STEPS )
|
if( m_PageType == PAGE_TYPE_ALL_STEPS )
|
||||||
{
|
{
|
||||||
vector<Song*> vpSongs;
|
vector<Song*> vpSongs;
|
||||||
GetAllSongsToShow( vpSongs, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW );
|
GetAllSongsToShow( vpSongs, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW );
|
||||||
m_vScoreRowItem.resize( vpSongs.size() );
|
m_vScoreRowItemData.resize( vpSongs.size() );
|
||||||
for( unsigned i=0; i<m_vScoreRowItem.size(); ++i )
|
for( unsigned i=0; i<m_vScoreRowItemData.size(); ++i )
|
||||||
m_vScoreRowItem[i].m_pSong = vpSongs[i];
|
m_vScoreRowItemData[i].m_pSong = vpSongs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_PageType == PAGE_TYPE_NONSTOP_COURSES ||
|
if( m_PageType == PAGE_TYPE_NONSTOP_COURSES ||
|
||||||
@@ -250,9 +249,9 @@ void ScreenRanking::Init()
|
|||||||
vector<Course*> vpCourses;
|
vector<Course*> vpCourses;
|
||||||
GetAllCoursesToShow( vpCourses, ct, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW );
|
GetAllCoursesToShow( vpCourses, ct, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW );
|
||||||
LOG->Trace("rankings: adding %u courses", unsigned(vpCourses.size()));
|
LOG->Trace("rankings: adding %u courses", unsigned(vpCourses.size()));
|
||||||
m_vScoreRowItem.resize( vpCourses.size() );
|
m_vScoreRowItemData.resize( vpCourses.size() );
|
||||||
for( unsigned i=0; i<m_vScoreRowItem.size(); ++i )
|
for( unsigned i=0; i<m_vScoreRowItemData.size(); ++i )
|
||||||
m_vScoreRowItem[i].m_pCourse = vpCourses[i];
|
m_vScoreRowItemData[i].m_pCourse = vpCourses[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_PageType == PAGE_TYPE_ALL_STEPS ||
|
if( m_PageType == PAGE_TYPE_ALL_STEPS ||
|
||||||
@@ -271,27 +270,36 @@ void ScreenRanking::Init()
|
|||||||
this->AddChild( m_sprDifficulty[*d] );
|
this->AddChild( m_sprDifficulty[*d] );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i=0; i<m_vScoreRowItem.size(); ++i )
|
ScoreRowItem ItemTemplate;
|
||||||
{
|
{
|
||||||
ScoreRowItem &item = m_vScoreRowItem[i];
|
ItemTemplate.m_sprFrame.Load( THEME->GetPathG(m_sName,"list frame") );
|
||||||
|
ItemTemplate.m_sprFrame->SetName( "Frame" );
|
||||||
|
|
||||||
item.m_sprFrame.Load( THEME->GetPathG(m_sName,"list frame") );
|
ItemTemplate.m_textTitle.SetName( "Title" );
|
||||||
item.m_sprFrame->SetName( "Frame" );
|
ItemTemplate.m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"list title") );
|
||||||
item.AddChild( item.m_sprFrame );
|
|
||||||
|
|
||||||
item.m_textTitle.SetName( "Title" );
|
|
||||||
item.m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"list title") );
|
|
||||||
item.AddChild( &item.m_textTitle );
|
|
||||||
|
|
||||||
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d )
|
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d )
|
||||||
{
|
{
|
||||||
item.m_textScore[*d].SetName( "Score" );
|
ItemTemplate.m_textScore[*d].SetName( "Score" );
|
||||||
item.m_textScore[*d].LoadFromFont( THEME->GetPathF(m_sName,"list score") );
|
ItemTemplate.m_textScore[*d].LoadFromFont( THEME->GetPathF(m_sName,"list score") );
|
||||||
item.AddChild( &item.m_textScore[*d] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_vScoreRowItem.resize( m_vScoreRowItemData.size(), ItemTemplate );
|
||||||
|
|
||||||
|
for( unsigned i=0; i<m_vScoreRowItem.size(); ++i )
|
||||||
|
{
|
||||||
|
ScoreRowItem &item = m_vScoreRowItem[i];
|
||||||
|
item.AddChild( item.m_sprFrame );
|
||||||
|
item.AddChild( &item.m_textTitle );
|
||||||
|
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d )
|
||||||
|
item.AddChild( &item.m_textScore[*d] );
|
||||||
|
}
|
||||||
|
|
||||||
m_ListScoreRowItems.SetName( "ListScoreRowItems" );
|
m_ListScoreRowItems.SetName( "ListScoreRowItems" );
|
||||||
|
for( unsigned i=0; i<m_vScoreRowItem.size(); i++ )
|
||||||
|
m_ListScoreRowItems.AddChild( &m_vScoreRowItem[i] );
|
||||||
|
m_ListScoreRowItems.Load2( (float)SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0 );
|
||||||
this->AddChild( &m_ListScoreRowItems );
|
this->AddChild( &m_ListScoreRowItems );
|
||||||
|
|
||||||
for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
|
for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
|
||||||
@@ -482,14 +490,10 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
|
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
|
||||||
{
|
{
|
||||||
ScoreRowItem &item = m_vScoreRowItem[s];
|
ScoreRowItem &item = m_vScoreRowItem[s];
|
||||||
item.m_sprFrame->SetZTestMode( ZTEST_WRITE_ON_PASS );
|
|
||||||
|
|
||||||
item.m_textTitle.SetZTestMode( ZTEST_WRITE_ON_PASS );
|
|
||||||
|
|
||||||
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), cd )
|
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), cd )
|
||||||
{
|
{
|
||||||
item.m_textScore[*cd].SetXY( SCORE_OFFSET_X(*cd), SCORE_OFFSET_Y );
|
item.m_textScore[*cd].SetXY( SCORE_OFFSET_X(*cd), SCORE_OFFSET_Y );
|
||||||
item.m_textScore[*cd].SetZTestMode( ZTEST_WRITE_ON_PASS );
|
|
||||||
item.m_textScore[*cd].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
|
item.m_textScore[*cd].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,15 +503,11 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
case PAGE_TYPE_NONSTOP_COURSES:
|
case PAGE_TYPE_NONSTOP_COURSES:
|
||||||
case PAGE_TYPE_ONI_COURSES:
|
case PAGE_TYPE_ONI_COURSES:
|
||||||
case PAGE_TYPE_SURVIVAL_COURSES:
|
case PAGE_TYPE_SURVIVAL_COURSES:
|
||||||
m_ListScoreRowItems.RemoveAllChildren();
|
case PAGE_TYPE_ALL_STEPS:
|
||||||
for( unsigned i=0; i<m_vScoreRowItem.size(); i++ )
|
|
||||||
m_ListScoreRowItems.AddChild( &m_vScoreRowItem[i] );
|
|
||||||
m_ListScoreRowItems.Load2( (float)SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0 );
|
|
||||||
|
|
||||||
if( (bool)MANUAL_SCROLLING )
|
if( (bool)MANUAL_SCROLLING )
|
||||||
{
|
|
||||||
m_ListScoreRowItems.SetCurrentAndDestinationItem( (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f );
|
m_ListScoreRowItems.SetCurrentAndDestinationItem( (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f );
|
||||||
}
|
else
|
||||||
|
m_ListScoreRowItems.ScrollThroughAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -608,23 +608,13 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
return SECONDS_PER_PAGE;
|
return SECONDS_PER_PAGE;
|
||||||
case PAGE_TYPE_ALL_STEPS:
|
case PAGE_TYPE_ALL_STEPS:
|
||||||
{
|
{
|
||||||
m_ListScoreRowItems.RemoveAllChildren();
|
|
||||||
for( unsigned i=0; i<m_vScoreRowItem.size(); i++ )
|
|
||||||
m_ListScoreRowItems.AddChild( &m_vScoreRowItem[i] );
|
|
||||||
m_ListScoreRowItems.Load2( (float)SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0 );
|
|
||||||
|
|
||||||
if( (bool)MANUAL_SCROLLING )
|
|
||||||
{
|
|
||||||
m_ListScoreRowItems.SetCurrentAndDestinationItem( (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_textStepsType.SetText( GameManager::StepsTypeToThemedString(pts.st) );
|
m_textStepsType.SetText( GameManager::StepsTypeToThemedString(pts.st) );
|
||||||
|
|
||||||
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
|
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
|
||||||
{
|
{
|
||||||
ScoreRowItem &item = m_vScoreRowItem[s];
|
const Song* pSong = m_vScoreRowItemData[s].m_pSong;
|
||||||
const Song* pSong = item.m_pSong;
|
|
||||||
|
|
||||||
|
ScoreRowItem &item = m_vScoreRowItem[s];
|
||||||
item.m_textTitle.SetText( pSong->GetDisplayFullTitle() );
|
item.m_textTitle.SetText( pSong->GetDisplayFullTitle() );
|
||||||
item.m_textTitle.SetDiffuse( SONGMAN->GetSongColor(pSong) );
|
item.m_textTitle.SetDiffuse( SONGMAN->GetSongColor(pSong) );
|
||||||
|
|
||||||
@@ -669,9 +659,9 @@ float ScreenRanking::SetPage( PageToShow pts )
|
|||||||
|
|
||||||
for( unsigned c=0; c<m_vScoreRowItem.size(); c++ )
|
for( unsigned c=0; c<m_vScoreRowItem.size(); c++ )
|
||||||
{
|
{
|
||||||
ScoreRowItem &item = m_vScoreRowItem[c];
|
const Course* pCourse = m_vScoreRowItemData[c].m_pCourse;
|
||||||
const Course* pCourse = item.m_pCourse;
|
|
||||||
|
|
||||||
|
ScoreRowItem &item = m_vScoreRowItem[c];
|
||||||
item.m_textTitle.SetText( pCourse->GetDisplayFullTitle() );
|
item.m_textTitle.SetText( pCourse->GetDisplayFullTitle() );
|
||||||
item.m_textTitle.SetDiffuse( SONGMAN->GetCourseColor(pCourse) );
|
item.m_textTitle.SetDiffuse( SONGMAN->GetCourseColor(pCourse) );
|
||||||
|
|
||||||
|
|||||||
@@ -86,15 +86,20 @@ protected:
|
|||||||
AutoActor m_sprDifficulty[NUM_DIFFICULTIES]; // for all_steps
|
AutoActor m_sprDifficulty[NUM_DIFFICULTIES]; // for all_steps
|
||||||
struct ScoreRowItem : public ActorFrame // for all_steps and all_courses
|
struct ScoreRowItem : public ActorFrame // for all_steps and all_courses
|
||||||
{
|
{
|
||||||
ScoreRowItem() { m_pSong = NULL; m_pCourse = NULL; }
|
|
||||||
|
|
||||||
Song *m_pSong;
|
|
||||||
Course *m_pCourse;
|
|
||||||
AutoActor m_sprFrame;
|
AutoActor m_sprFrame;
|
||||||
BitmapText m_textTitle;
|
BitmapText m_textTitle;
|
||||||
BitmapText m_textScore[NUM_DIFFICULTIES];
|
BitmapText m_textScore[NUM_DIFFICULTIES];
|
||||||
};
|
};
|
||||||
vector<ScoreRowItem> m_vScoreRowItem; // for all_steps
|
vector<ScoreRowItem> m_vScoreRowItem; // for all_steps
|
||||||
|
|
||||||
|
struct ScoreRowItemData // for all_steps and all_courses
|
||||||
|
{
|
||||||
|
ScoreRowItemData() { m_pSong = NULL; m_pCourse = NULL; }
|
||||||
|
|
||||||
|
Song *m_pSong;
|
||||||
|
Course *m_pCourse;
|
||||||
|
};
|
||||||
|
vector<ScoreRowItemData> m_vScoreRowItemData; // for all_steps
|
||||||
ActorScroller m_ListScoreRowItems;
|
ActorScroller m_ListScoreRowItems;
|
||||||
|
|
||||||
vector<PageToShow> m_vPagesToShow;
|
vector<PageToShow> m_vPagesToShow;
|
||||||
@@ -105,11 +110,6 @@ protected:
|
|||||||
ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW;
|
ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW;
|
||||||
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
|
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
|
||||||
|
|
||||||
ThemeMetric<bool> SHOW_CATEGORIES;
|
|
||||||
ThemeMetric<bool> SHOW_STEPS_SCORES;
|
|
||||||
ThemeMetric<bool> SHOW_NONSTOP_COURSE_SCORES;
|
|
||||||
ThemeMetric<bool> SHOW_ONI_COURSE_SCORES;
|
|
||||||
ThemeMetric<bool> SHOW_SURVIVAL_COURSE_SCORES;
|
|
||||||
ThemeMetric<bool> SHOW_ONLY_MOST_RECENT_SCORES;
|
ThemeMetric<bool> SHOW_ONLY_MOST_RECENT_SCORES;
|
||||||
ThemeMetric<int> NUM_MOST_RECENT_SCORES_TO_SHOW;
|
ThemeMetric<int> NUM_MOST_RECENT_SCORES_TO_SHOW;
|
||||||
ThemeMetric<float> SECONDS_PER_PAGE;
|
ThemeMetric<float> SECONDS_PER_PAGE;
|
||||||
|
|||||||
Reference in New Issue
Block a user