like Player, split NoteField loading into Load and Init, with Init having the expensive part, which we do only once

This commit is contained in:
Glenn Maynard
2005-03-18 04:43:59 +00:00
parent b6b9b11b0f
commit 02197dab9c
4 changed files with 21 additions and 17 deletions
+10 -8
View File
@@ -59,8 +59,8 @@ void NoteField::CacheNoteSkin( CString skin )
return;
LOG->Trace("NoteField::CacheNoteSkin: cache %s", skin.c_str() );
NoteDisplayCols *nd = new NoteDisplayCols( m_pNoteData->GetNumTracks() );
for( int c=0; c<m_pNoteData->GetNumTracks(); c++ )
NoteDisplayCols *nd = new NoteDisplayCols( GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer );
for( int c=0; c<GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; c++ )
nd->display[c].Load( c, m_pPlayerState, skin, m_fYReverseOffsetPixels );
nd->m_ReceptorArrowRow.Load( m_pPlayerState, skin, m_fYReverseOffsetPixels );
nd->m_GhostArrowRow.Load( m_pPlayerState, skin, m_fYReverseOffsetPixels );
@@ -78,25 +78,27 @@ void NoteField::CacheAllUsedNoteSkins()
CacheNoteSkin( skins[i] );
}
void NoteField::Init( const PlayerState* pPlayerState, float fYReverseOffsetPixels )
{
m_pPlayerState = pPlayerState;
m_fYReverseOffsetPixels = fYReverseOffsetPixels;
CacheAllUsedNoteSkins();
}
void NoteField::Load(
const NoteData *pNoteData,
const PlayerState* pPlayerState,
int iFirstPixelToDraw,
int iLastPixelToDraw,
float fYReverseOffsetPixels )
int iLastPixelToDraw )
{
m_pNoteData = pNoteData;
m_pPlayerState = pPlayerState;
m_iStartDrawingPixel = iFirstPixelToDraw;
m_iEndDrawingPixel = iLastPixelToDraw;
m_fYReverseOffsetPixels = fYReverseOffsetPixels;
m_fPercentFadeToFail = -1;
m_LastSeenBeatToNoteSkinRev = -1;
ASSERT( m_pNoteData->GetNumTracks() == GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer );
CacheAllUsedNoteSkins();
RefreshBeatToNoteSkin();
}
+2 -3
View File
@@ -22,12 +22,11 @@ public:
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
virtual void Init( const PlayerState* pPlayerState, float fYReverseOffsetPixels );
virtual void Load(
const NoteData* pNoteData,
const PlayerState* pPlayerState,
int iStartDrawingPixel,
int iEndDrawingPixel,
float fYReverseOffsetPixels );
int iEndDrawingPixel );
virtual void Unload();
int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT
+4 -3
View File
@@ -158,6 +158,9 @@ void Player::Init(
m_Combo.SetName( "Combo" );
m_Combo.Load( pn );
m_fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD;
m_pNoteField->Init( m_pPlayerState, m_fNoteFieldHeight );
ActorUtil::OnCommand( m_Combo, sType );
}
@@ -234,9 +237,7 @@ void Player::Load( const NoteData& noteData )
if( m_pNoteField )
m_pNoteField->SetY( fNoteFieldMiddle );
m_fNoteFieldHeight = GRAY_ARROWS_Y_REVERSE-GRAY_ARROWS_Y_STANDARD;
if( m_pNoteField )
m_pNoteField->Load( &m_NoteData, m_pPlayerState, iStartDrawingAtPixels, iStopDrawingAtPixels, m_fNoteFieldHeight );
m_pNoteField->Load( &m_NoteData, iStartDrawingAtPixels, iStopDrawingAtPixels );
const bool bReverse = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetReversePercentForColumn(0) == 1;
bool bPlayerUsingBothSides = GAMESTATE->GetCurrentStyle()->m_StyleType==ONE_PLAYER_TWO_SIDES;
+5 -3
View File
@@ -555,14 +555,16 @@ void ScreenEdit::Init()
m_NoteFieldEdit.SetZoom( 0.5f );
m_NoteDataEdit.CopyAll( noteData );
m_NoteFieldEdit.Load( &m_NoteDataEdit, GAMESTATE->m_pPlayerState[PLAYER_1], -240, 800, PLAYER_HEIGHT*2 );
m_NoteFieldEdit.Init( GAMESTATE->m_pPlayerState[PLAYER_1], PLAYER_HEIGHT*2 );
m_NoteFieldEdit.Load( &m_NoteDataEdit, -240, 800 );
m_rectRecordBack.StretchTo( RectF(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
m_rectRecordBack.SetDiffuse( RageColor(0,0,0,0) );
m_NoteFieldRecord.SetXY( EDIT_X, PLAYER_Y );
m_NoteDataRecord.CopyAll( noteData );
m_NoteFieldRecord.Load( &m_NoteDataRecord, GAMESTATE->m_pPlayerState[PLAYER_1], -150, 350, 350 );
m_NoteFieldRecord.Init( GAMESTATE->m_pPlayerState[PLAYER_1], 350 );
m_NoteFieldRecord.Load( &m_NoteDataRecord, -150, 350 );
m_Clipboard.SetNumTracks( m_NoteDataEdit.GetNumTracks() );
@@ -2235,7 +2237,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
// initialize m_NoteFieldRecord
m_NoteDataRecord.SetNumTracks( m_NoteDataEdit.GetNumTracks() );
m_NoteDataRecord.CopyAll( m_NoteDataEdit );
m_NoteFieldRecord.Load( &m_NoteDataRecord, GAMESTATE->m_pPlayerState[PLAYER_1], -150, 350, 350 );
m_NoteFieldRecord.Load( &m_NoteDataRecord, -150, 350 );
m_rectRecordBack.StopTweening();
m_rectRecordBack.BeginTweening( 0.5f );