diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index d10d7858bd..646eb8fdac 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -80,7 +80,7 @@ void CourseContentsList::SetFromGameState() if( unsigned(i) < pTrail->m_vEntries.size() ) pte[pn] = &pTrail->m_vEntries[i]; } - d.LoadFromTrailEntry( (int)(truncf(m_fItemAtPosition0InList))+i+1, pte ); + d.SetFromTrailEntry( (int)(truncf(m_fItemAtPosition0InList))+i+1, pte ); } bool bLoop = pMasterTrail->m_vEntries.size() > uNumEntriesToShow; diff --git a/stepmania/src/CourseEntryDisplay.cpp b/stepmania/src/CourseEntryDisplay.cpp index 5080f5f678..9c28d51326 100644 --- a/stepmania/src/CourseEntryDisplay.cpp +++ b/stepmania/src/CourseEntryDisplay.cpp @@ -13,6 +13,13 @@ #include "Style.h" #include "ActorUtil.h" +REGISTER_ACTOR_CLASS( CourseEntryDisplay ) + +CourseEntryDisplay::CourseEntryDisplay() +{ + m_sName = "CourseEntryDisplay"; +} + void CourseEntryDisplay::Load() { SEPARATE_COURSE_METERS .Load( "CourseEntryDisplay", "SeparateCourseMeters" ); @@ -60,6 +67,13 @@ void CourseEntryDisplay::Load() this->AddChild( &m_textModifiers ); } +void CourseEntryDisplay::LoadFromNode( const CString& sDir, const XNode* pNode ) +{ + ActorFrame::LoadFromNode( sDir, pNode ); + + Load(); +} + void CourseEntryDisplay::SetDifficulty( PlayerNumber pn, const CString &text, RageColor c ) { if( !GAMESTATE->IsHumanPlayer(pn) ) @@ -74,7 +88,7 @@ void CourseEntryDisplay::SetDifficulty( PlayerNumber pn, const CString &text, Ra m_textFoot[pn].SetDiffuse( c ); } -void CourseEntryDisplay::LoadFromTrailEntry( int iNum, const TrailEntry *tes[NUM_PLAYERS] ) +void CourseEntryDisplay::SetFromTrailEntry( int iCourseEntryIndex, const TrailEntry *tes[NUM_PLAYERS] ) { const TrailEntry *te = tes[GAMESTATE->m_MasterPlayerNumber]; if( te == NULL ) @@ -120,11 +134,47 @@ void CourseEntryDisplay::LoadFromTrailEntry( int iNum, const TrailEntry *tes[NUM m_TextBanner.SetDiffuse( SONGMAN->GetSongColor( te->pSong ) ); } - m_textNumber.SetText( ssprintf("%d", iNum) ); + m_textNumber.SetText( ssprintf("%d", iCourseEntryIndex) ); m_textModifiers.SetText( te->Modifiers ); } +void CourseEntryDisplay::SetFromGameState( int iCourseEntryIndex ) +{ + const TrailEntry *pTrailEntry[NUM_PLAYERS]; + FOREACH_PlayerNumber( p ) + { + Trail *pTrail = GAMESTATE->m_pCurTrail[p]; + if( pTrail ) + pTrailEntry[p] = &pTrail->m_vEntries[iCourseEntryIndex]; + else + pTrailEntry[p] = NULL; + } + + SetFromTrailEntry( iCourseEntryIndex, pTrailEntry ); +} + + +// lua start +#include "LuaBinding.h" + +class LunaCourseEntryDisplay: public Luna +{ +public: + LunaCourseEntryDisplay() { LUA->Register( Register ); } + + static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(IArg(1)); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( SetFromGameState ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( CourseEntryDisplay, ActorFrame ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/CourseEntryDisplay.h b/stepmania/src/CourseEntryDisplay.h index 314f97248d..b2d8db4fe2 100644 --- a/stepmania/src/CourseEntryDisplay.h +++ b/stepmania/src/CourseEntryDisplay.h @@ -14,9 +14,17 @@ struct TrailEntry; class CourseEntryDisplay : public ActorFrame { public: - void Load(); + CourseEntryDisplay(); + virtual Actor *Copy() const; - void LoadFromTrailEntry( int iNum, const TrailEntry *te[NUM_PLAYERS] ); + void Load(); + void LoadFromNode( const CString& sDir, const XNode* pNode ); + + void SetFromTrailEntry( int iCourseEntryIndex, const TrailEntry *te[NUM_PLAYERS] ); + void SetFromGameState( int iCourseEntryIndex ); + + // Lua + void PushSelf( lua_State *L ); private: void SetDifficulty( PlayerNumber pn, const CString &text, RageColor c );