remove hard-coded loading of Board commands and make generic

This commit is contained in:
Chris Danford
2006-12-12 00:19:35 +00:00
parent d78274b515
commit ab85bc0e83
2 changed files with 19 additions and 17 deletions
+16 -14
View File
@@ -23,9 +23,7 @@
static ThemeMetric<bool> SHOW_BOARD( "NoteField", "ShowBoard" ); static ThemeMetric<bool> SHOW_BOARD( "NoteField", "ShowBoard" );
static ThemeMetric<bool> SHOW_BEAT_BARS( "NoteField", "ShowBeatBars" ); static ThemeMetric<bool> SHOW_BEAT_BARS( "NoteField", "ShowBeatBars" );
static ThemeMetric<float> FADE_BEFORE_TARGETS_PERCENT( "NoteField", "FadeBeforeTargetsPercent" ); static ThemeMetric<float> FADE_BEFORE_TARGETS_PERCENT( "NoteField", "FadeBeforeTargetsPercent" );
static ThemeMetric<apActorCommands> BOARD_ON_COMMAND( "NoteField", "BoardOnCommand" );
static ThemeMetric<apActorCommands> COMBO_STOPPED_COMMAND( "NoteField", "ComboStoppedCommand" ); static ThemeMetric<apActorCommands> COMBO_STOPPED_COMMAND( "NoteField", "ComboStoppedCommand" );
static ThemeMetric<apActorCommands> BOARD_COMBO_STOPPED_COMMAND( "NoteField", "BoardComboStoppedCommand" );
NoteField::NoteField() NoteField::NoteField()
{ {
@@ -40,9 +38,8 @@ NoteField::NoteField()
m_rectMarkerBar.SetEffectDiffuseShift( 2, RageColor(1,1,1,0.5f), RageColor(0.5f,0.5f,0.5f,0.5f) ); m_rectMarkerBar.SetEffectDiffuseShift( 2, RageColor(1,1,1,0.5f), RageColor(0.5f,0.5f,0.5f,0.5f) );
m_sprBoard.Load( THEME->GetPathG("NoteField","board") ); m_sprBoard.Load( THEME->GetPathG("NoteField","board") );
m_sprBoard.RunCommands( BOARD_ON_COMMAND ); m_sprBoard->PlayCommand( "On" );
m_sprBoard.AddCommand( "ComboStopped", BOARD_COMBO_STOPPED_COMMAND ); this->AddChild( m_sprBoard );
this->AddChild( &m_sprBoard );
m_fBoardOffsetPixels = 0; m_fBoardOffsetPixels = 0;
m_fCurrentBeatLastUpdate = -1; m_fCurrentBeatLastUpdate = -1;
@@ -192,7 +189,7 @@ void NoteField::Update( float fDeltaTime )
// update m_fBoardOffsetPixels, m_fCurrentBeatLastUpdate, m_fYPosCurrentBeatLastUpdate // update m_fBoardOffsetPixels, m_fCurrentBeatLastUpdate, m_fYPosCurrentBeatLastUpdate
const float fCurrentBeat = GAMESTATE->m_fSongBeat; const float fCurrentBeat = GAMESTATE->m_fSongBeat;
bool bTweeningOn = m_sprBoard.GetCurrentDiffuseAlpha() >= 0.98 && m_sprBoard.GetCurrentDiffuseAlpha() < 1.00; // HACK bool bTweeningOn = m_sprBoard->GetCurrentDiffuseAlpha() >= 0.98 && m_sprBoard->GetCurrentDiffuseAlpha() < 1.00; // HACK
if( !bTweeningOn && m_fCurrentBeatLastUpdate != -1 ) if( !bTweeningOn && m_fCurrentBeatLastUpdate != -1 )
{ {
const float fYOffsetLast = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate ); const float fYOffsetLast = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
@@ -202,7 +199,7 @@ void NoteField::Update( float fDeltaTime )
//LOG->Trace( "speed = %f, %f, %f, %f, %f, %f", fSpeed, fYOffsetAtCurrent, fYOffsetAtNext, fSecondsAtCurrent, fSecondsAtNext, fPixelDifference, fSecondsDifference ); //LOG->Trace( "speed = %f, %f, %f, %f, %f, %f", fSpeed, fYOffsetAtCurrent, fYOffsetAtNext, fSecondsAtCurrent, fSecondsAtNext, fPixelDifference, fSecondsDifference );
m_fBoardOffsetPixels += fPixelDifference; m_fBoardOffsetPixels += fPixelDifference;
wrap( m_fBoardOffsetPixels, m_sprBoard.GetUnzoomedHeight() ); wrap( m_fBoardOffsetPixels, m_sprBoard->GetUnzoomedHeight() );
} }
m_fCurrentBeatLastUpdate = fCurrentBeat; m_fCurrentBeatLastUpdate = fCurrentBeat;
const float fYOffsetCurrent = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate ); const float fYOffsetCurrent = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
@@ -318,23 +315,28 @@ void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanc
// Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers. // Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers.
RectF rect = *m_sprBoard.GetCurrentTextureCoordRect(); Sprite *pSprite = dynamic_cast<Sprite *>( (Actor*)m_sprBoard );
const float fBoardGraphicHeightPixels = m_sprBoard.GetUnzoomedHeight(); if( pSprite == NULL )
RageException::Throw( "Board must be a Sprite" );
RectF rect = *pSprite->GetCurrentTextureCoordRect();
const float fBoardGraphicHeightPixels = pSprite->GetUnzoomedHeight();
float fTexCoordOffset = m_fBoardOffsetPixels / fBoardGraphicHeightPixels; float fTexCoordOffset = m_fBoardOffsetPixels / fBoardGraphicHeightPixels;
{ {
// top half // top half
const float fHeight = iDrawDistanceBeforeTargetsPixels - iDrawDistanceAfterTargetsPixels; const float fHeight = iDrawDistanceBeforeTargetsPixels - iDrawDistanceAfterTargetsPixels;
const float fY = fYPosAt0 - ((iDrawDistanceBeforeTargetsPixels + iDrawDistanceAfterTargetsPixels) / 2.0f); const float fY = fYPosAt0 - ((iDrawDistanceBeforeTargetsPixels + iDrawDistanceAfterTargetsPixels) / 2.0f);
m_sprBoard.ZoomToHeight( fHeight ); pSprite->ZoomToHeight( fHeight );
m_sprBoard.SetY( fY ); pSprite->SetY( fY );
rect.top = -fTexCoordOffset-(iDrawDistanceBeforeTargetsPixels/fBoardGraphicHeightPixels); rect.top = -fTexCoordOffset-(iDrawDistanceBeforeTargetsPixels/fBoardGraphicHeightPixels);
rect.bottom = -fTexCoordOffset+(-iDrawDistanceAfterTargetsPixels/fBoardGraphicHeightPixels); rect.bottom = -fTexCoordOffset+(-iDrawDistanceAfterTargetsPixels/fBoardGraphicHeightPixels);
m_sprBoard.SetCustomTextureRect( rect ); pSprite->SetCustomTextureRect( rect );
float fFadeTop = FADE_BEFORE_TARGETS_PERCENT * iDrawDistanceBeforeTargetsPixels / (iDrawDistanceBeforeTargetsPixels-iDrawDistanceAfterTargetsPixels); float fFadeTop = FADE_BEFORE_TARGETS_PERCENT * iDrawDistanceBeforeTargetsPixels / (iDrawDistanceBeforeTargetsPixels-iDrawDistanceAfterTargetsPixels);
m_sprBoard.SetFadeTop( fFadeTop ); pSprite->SetFadeTop( fFadeTop );
m_sprBoard.Draw(); pSprite->Draw();
} }
} }
+3 -3
View File
@@ -83,11 +83,11 @@ protected:
/* All loaded note displays, mapped by their name. */ /* All loaded note displays, mapped by their name. */
map<RString, NoteDisplayCols *> m_NoteDisplays; map<RString, NoteDisplayCols *> m_NoteDisplays;
NoteDisplayCols *m_pCurDisplay; NoteDisplayCols *m_pCurDisplay;
NoteDisplayCols *m_pDisplays[NUM_PlayerNumber]; NoteDisplayCols *m_pDisplays[NUM_PlayerNumber];
// decorations, mostly used in MODE_EDIT // decorations, mostly used in MODE_EDIT
Sprite m_sprBoard; AutoActor m_sprBoard;
float m_fBoardOffsetPixels; float m_fBoardOffsetPixels;
float m_fCurrentBeatLastUpdate; // -1 on first update float m_fCurrentBeatLastUpdate; // -1 on first update
float m_fYPosCurrentBeatLastUpdate; // -1 on first update float m_fYPosCurrentBeatLastUpdate; // -1 on first update