From fb49d6a41ace000cf23f7b68387e7be1f1f6d731 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 22 Sep 2005 00:08:59 +0000 Subject: [PATCH] optimize, simplify --- stepmania/src/ActorScroller.cpp | 10 ++++- stepmania/src/ActorScroller.h | 1 + stepmania/src/ScreenRanking.cpp | 78 ++++++++++++++------------------- stepmania/src/ScreenRanking.h | 18 ++++---- 4 files changed, 52 insertions(+), 55 deletions(-) diff --git a/stepmania/src/ActorScroller.cpp b/stepmania/src/ActorScroller.cpp index 3684dd3301..593edc8de7 100644 --- a/stepmania/src/ActorScroller.cpp +++ b/stepmania/src/ActorScroller.cpp @@ -67,11 +67,11 @@ void ActorScroller::Load2( m_bLoop = bLoop; m_fSecondsPerItem = fSecondsPerItem; 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_fQuantizePixels = 0; + ScrollThroughAllItems(); + m_bUseMask = true; RectF rectBarSize( -m_fMaskWidth/2, @@ -106,6 +106,12 @@ void ActorScroller::Load3( 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 fTotalItems = m_fNumItemsToDraw + m_SubActors.size(); diff --git a/stepmania/src/ActorScroller.h b/stepmania/src/ActorScroller.h index 643eb20012..cfe7060780 100644 --- a/stepmania/src/ActorScroller.h +++ b/stepmania/src/ActorScroller.h @@ -42,6 +42,7 @@ public: void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; } float GetCurrentItem() { return m_fCurrentItem; } float GetDestinationItem() { return m_fDestinationItem; } + void ScrollThroughAllItems(); void SetPauseCountdownSeconds( float fSecs ) { m_fPauseCountdownSeconds = fSecs; } float GetSecondsForCompleteScrollThrough(); diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 8b55f8235a..fb00cb19c9 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -230,14 +230,13 @@ void ScreenRanking::Init() } } - m_vScoreRowItem.clear(); if( m_PageType == PAGE_TYPE_ALL_STEPS ) { vector vpSongs; GetAllSongsToShow( vpSongs, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW ); - m_vScoreRowItem.resize( vpSongs.size() ); - for( unsigned i=0; i vpCourses; GetAllCoursesToShow( vpCourses, ct, SHOW_ONLY_MOST_RECENT_SCORES, NUM_MOST_RECENT_SCORES_TO_SHOW ); LOG->Trace("rankings: adding %u courses", unsigned(vpCourses.size())); - m_vScoreRowItem.resize( vpCourses.size() ); - for( unsigned i=0; iAddChild( m_sprDifficulty[*d] ); } - for( unsigned i=0; iGetPathG(m_sName,"list frame") ); + ItemTemplate.m_sprFrame->SetName( "Frame" ); - item.m_sprFrame.Load( THEME->GetPathG(m_sName,"list frame") ); - item.m_sprFrame->SetName( "Frame" ); - 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 ); + ItemTemplate.m_textTitle.SetName( "Title" ); + ItemTemplate.m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"list title") ); FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d ) { - item.m_textScore[*d].SetName( "Score" ); - item.m_textScore[*d].LoadFromFont( THEME->GetPathF(m_sName,"list score") ); - item.AddChild( &item.m_textScore[*d] ); + ItemTemplate.m_textScore[*d].SetName( "Score" ); + ItemTemplate.m_textScore[*d].LoadFromFont( THEME->GetPathF(m_sName,"list score") ); } } + m_vScoreRowItem.resize( m_vScoreRowItemData.size(), ItemTemplate ); + + for( unsigned i=0; iAddChild( &m_ListScoreRowItems ); for( unsigned i=0; iSetZTestMode( ZTEST_WRITE_ON_PASS ); - - item.m_textTitle.SetZTestMode( ZTEST_WRITE_ON_PASS ); FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), cd ) { 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) ); } } @@ -499,15 +503,11 @@ float ScreenRanking::SetPage( PageToShow pts ) case PAGE_TYPE_NONSTOP_COURSES: case PAGE_TYPE_ONI_COURSES: case PAGE_TYPE_SURVIVAL_COURSES: - m_ListScoreRowItems.RemoveAllChildren(); - for( unsigned i=0; iGetDisplayFullTitle() ); item.m_textTitle.SetDiffuse( SONGMAN->GetSongColor(pSong) ); @@ -669,9 +659,9 @@ float ScreenRanking::SetPage( PageToShow pts ) for( unsigned c=0; cGetDisplayFullTitle() ); item.m_textTitle.SetDiffuse( SONGMAN->GetCourseColor(pCourse) ); diff --git a/stepmania/src/ScreenRanking.h b/stepmania/src/ScreenRanking.h index 2911abcf49..e3c7853847 100644 --- a/stepmania/src/ScreenRanking.h +++ b/stepmania/src/ScreenRanking.h @@ -86,15 +86,20 @@ protected: AutoActor m_sprDifficulty[NUM_DIFFICULTIES]; // for all_steps 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; BitmapText m_textTitle; BitmapText m_textScore[NUM_DIFFICULTIES]; }; vector 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 m_vScoreRowItemData; // for all_steps ActorScroller m_ListScoreRowItems; vector m_vPagesToShow; @@ -105,11 +110,6 @@ protected: ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW; ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW; - ThemeMetric SHOW_CATEGORIES; - ThemeMetric SHOW_STEPS_SCORES; - ThemeMetric SHOW_NONSTOP_COURSE_SCORES; - ThemeMetric SHOW_ONI_COURSE_SCORES; - ThemeMetric SHOW_SURVIVAL_COURSE_SCORES; ThemeMetric SHOW_ONLY_MOST_RECENT_SCORES; ThemeMetric NUM_MOST_RECENT_SCORES_TO_SHOW; ThemeMetric SECONDS_PER_PAGE;