From dd83b61d04c893768787d6bc9ad762d8f12f67ce Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 7 Apr 2007 23:49:40 +0000 Subject: [PATCH] refactor CourseContentsList --- .../_CourseEntryDisplay bar.png | Bin 0 -> 3071 bytes .../ScreenSelectMusic overlay/default.lua | 62 ++++++++ stepmania/Themes/default/metrics.ini | 24 --- stepmania/src/CourseContentsList.cpp | 147 ++++++++++++++---- stepmania/src/CourseContentsList.h | 6 +- 5 files changed, 180 insertions(+), 59 deletions(-) create mode 100644 stepmania/Themes/default/BGAnimations/ScreenSelectMusic overlay/_CourseEntryDisplay bar.png diff --git a/stepmania/Themes/default/BGAnimations/ScreenSelectMusic overlay/_CourseEntryDisplay bar.png b/stepmania/Themes/default/BGAnimations/ScreenSelectMusic overlay/_CourseEntryDisplay bar.png new file mode 100644 index 0000000000000000000000000000000000000000..ffe610268ceae2864094dc273293463f802828df GIT binary patch literal 3071 zcmVc5F$|!f+j|M!4QZb1k_rg0&Qu_fB(;Y?lXRCpYyk<@xd3vguOC3-Tyf==V6~& zUElh?Z|_lf@FYAR%7Ri5)HMtY3K#&U_hKs@yuq8ae-nYG;z?2kvYhH6yd=g-X*Rwb7Wv3h_d>b zevZKegCQod1HXiwz#2jM_b=D5EHg(221HdsjY$n5h+jGwSBO(&6QmyeivHffz<`Fn zLORB1LV{G4gHV*DMx>8Gk7wRr@l}{(>0>%jYW9)-CY>CpNj~|~s+tX$L#s_D&7k?J zQp2wK3cflR7O*N5Im#SK2HWOIQ+hZy^FS(+)>GnDbNjW)$OQqJYT9J_k292bO=!709jvWj# zST-_!iw8MND~^Jv5IC%~Jo;lidN=Y6OZ#xm_1JqUx{G9ykU=P*O2n~HC|^E_J3j9n zzBc>xS1Bw>iELY5Y7>kZG}o(SRFy>j_ZM3qDOd_E3vCObt(C-s=S!4Tf9F%!TEnjW zxbOfDUitAIw(@F}t3{GBMspm?b*--bShk2=x$rIf%hP!7_trP=ujX3FEEI}?+0?)o z7&MP63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&OYasDB$w7yR;Yn7`Uq6P*Y?cjcQnV_@)hqssK(^G`jYS6R@je4X=8 zSetNumItemsToDraw( (float)MAX_VISIBLE_ITEMS ); + m_iVisibleItems = 5; } CourseContentsList::~CourseContentsList() { - FOREACH( CourseEntryDisplay*, m_vpDisplay, d ) + FOREACH( Actor *, m_vpDisplay, d ) delete *d; m_vpDisplay.clear(); } -void CourseContentsList::Load() -{ - FOREACH( CourseEntryDisplay*, m_vpDisplay, d ) - { - (*d)->SetName( "CourseEntryDisplay" ); - (*d)->Load(); - (*d)->SetUseZBuffer( true ); - } -} - void CourseContentsList::LoadFromNode( const XNode* pNode ) { + pNode->GetAttrValue( "VisibleItems", m_iVisibleItems ); + ActorScroller::LoadFromNode( pNode ); - Load(); + const XNode *pDisplayNode = pNode->GetChild( "Display" ); + if( pDisplayNode == NULL ) + RageException::Throw( "%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str() ); + + for( int i=0; iSetUseZBuffer( true ); + m_vpDisplay.push_back( pDisplay ); + } + + this->SetNumItemsToDraw( (float)m_iVisibleItems ); } void CourseContentsList::SetFromGameState() @@ -57,18 +52,16 @@ void CourseContentsList::SetFromGameState() // the same number of TrailEntries? // They have to have the same number, and of the same songs, or gameplay // isn't going to line up. - Trail* pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber]; + const Trail *pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber]; if( pMasterTrail == NULL ) return; unsigned uNumEntriesToShow = min( pMasterTrail->m_vEntries.size(), m_vpDisplay.size() ); for( int i=0; i<(int)uNumEntriesToShow; i++ ) { - CourseEntryDisplay &d = *m_vpDisplay[i]; - - this->AddChild( &d ); - - d.SetFromGameState( i ); + Actor *pDisplay = m_vpDisplay[i]; + SetItemFromGameState( pDisplay, i ); + this->AddChild( pDisplay ); } bool bLoop = pMasterTrail->m_vEntries.size() > uNumEntriesToShow; @@ -81,11 +74,99 @@ void CourseContentsList::SetFromGameState() this->SetSecondsPauseBetweenItems( 0.7f ); this->ScrollThroughAllItems(); - this->SetCurrentAndDestinationItem( (MAX_VISIBLE_ITEMS-1)/2 ); + this->SetCurrentAndDestinationItem( (m_iVisibleItems-1)/2 ); if( bLoop ) { SetPauseCountdownSeconds( 1.5f ); - this->SetDestinationItem( MAX_ITEMS+1 ); // loop forever + this->SetDestinationItem( m_vpDisplay.size()+1 ); // loop forever + } +} + +void CourseContentsList::SetItemFromGameState( Actor *pActor, int iCourseEntryIndex ) +{ + const Course *pCourse = GAMESTATE->m_pCurCourse; + + const TrailEntry *tes[NUM_PLAYERS]; + const CourseEntry *ces[NUM_PLAYERS]; + FOREACH_PlayerNumber( p ) + { + const Trail *pTrail = GAMESTATE->m_pCurTrail[p]; + if( pTrail && iCourseEntryIndex < (int) pTrail->m_vEntries.size() ) + { + tes[p] = &pTrail->m_vEntries[iCourseEntryIndex]; + ces[p] = &pCourse->m_vEntries[iCourseEntryIndex]; + } + else + { + tes[p] = NULL; + ces[p] = NULL; + } + } + + + const TrailEntry *te = tes[GAMESTATE->m_MasterPlayerNumber]; + if( te == NULL ) + return; + + FOREACH_HumanPlayer(pn) + { + const TrailEntry *te = tes[pn]; + if( te == NULL ) + continue; + + RString s; + Difficulty dc; + if( te->bSecret ) + { + const CourseEntry *ce = ces[pn]; + if( ce == NULL ) + continue; + + int iLow = ce->stepsCriteria.m_iLowMeter; + int iHigh = ce->stepsCriteria.m_iHighMeter; + + bool bLowIsSet = iLow != -1; + bool bHighIsSet = iHigh != -1; + + if( !bLowIsSet && !bHighIsSet ) + { + s = "?"; + } + if( !bLowIsSet && bHighIsSet ) + { + s = ssprintf( ">=%d", iHigh ); + } + else if( bLowIsSet && !bHighIsSet ) + { + s = ssprintf( "<=%d", iLow ); + } + else if( bLowIsSet && bHighIsSet ) + { + if( iLow == iHigh ) + s = ssprintf( "%d", iLow ); + else + s = ssprintf( "%d-%d", iLow, iHigh ); + } + + dc = te->dc; + if( dc == Difficulty_Invalid ) + dc = Difficulty_Edit; + } + else + { + s = ssprintf("%d", te->pSteps->GetMeter()); + dc = te->pSteps->GetDifficulty(); + } + + Message msg("SetSong"); + msg.SetParam( "PlayerNumber", pn ); + msg.SetParam( "Difficulty", dc ); + msg.SetParam( "Meter", s ); + msg.SetParam( "Number", iCourseEntryIndex+1 ); + msg.SetParam( "Modifiers", te->Modifiers ); + if( !te->bSecret ) + msg.SetParam( "Song", te->pSong ); + pActor->HandleMessage( msg ); } } diff --git a/stepmania/src/CourseContentsList.h b/stepmania/src/CourseContentsList.h index 3e665f022d..59e6abc4c9 100644 --- a/stepmania/src/CourseContentsList.h +++ b/stepmania/src/CourseContentsList.h @@ -13,7 +13,6 @@ public: ~CourseContentsList(); virtual CourseContentsList *Copy() const; - void Load(); void LoadFromNode( const XNode* pNode ); void SetFromGameState(); @@ -22,7 +21,10 @@ public: void PushSelf( lua_State *L ); protected: - vector m_vpDisplay; + void SetItemFromGameState( Actor *pActor, int iCourseEntryIndex ); + + int m_iVisibleItems; + vector m_vpDisplay; }; #endif