From 44a27f646f5ca29186495fb65f89e21dc4651adb Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 10 Sep 2002 08:21:55 +0000 Subject: [PATCH] Fixed popping notes problem with V, Colors and more. Fixed background movie synch. --- stepmania/src/Background.cpp | 5 +- stepmania/src/NoteField.cpp | 7 +- stepmania/src/ScreenEdit.cpp | 6 +- stepmania/src/ScreenEvaluation.cpp | 108 ++++++++++++++-------------- stepmania/src/ScreenGameplay.cpp | 20 ++++-- stepmania/src/ScreenSelectMusic.cpp | 10 +-- 6 files changed, 88 insertions(+), 68 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index e42dcc2967..2c766941ef 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -305,7 +305,10 @@ void Background::LoadFromSong( Song* pSong ) /* If we have only 2, only generate a single animation segment for for the * whole song. Otherwise, if it's a movie., it'll loop every four bars; we * want it to play continuously. */ - const float fFirstBeat = (m_BackgroundMode==MODE_MOVIE_BG) ? 0 : pSong->m_fFirstBeat; + float fMusicStartBeat, fBPS; + bool bFreeze; + pSong->GetBeatAndBPSFromElapsedTime( -pSong->m_fBeat0OffsetInSeconds, fMusicStartBeat, fBPS, bFreeze ); + const float fFirstBeat = (m_BackgroundMode==MODE_MOVIE_BG) ? fMusicStartBeat : pSong->m_fFirstBeat; const float fLastBeat = pSong->m_fLastBeat; if( m_BackgroundAnimations.GetSize() == 2) { diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index d6e0db011f..36259ec3e8 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -20,6 +20,7 @@ #include "GameState.h" #include "RageException.h" #include "RageTimer.h" +#include "RageLog.h" const float HOLD_NOTE_BITS_PER_BEAT = 6; @@ -150,16 +151,16 @@ void NoteField::DrawPrimitives() { //LOG->Trace( "NoteField::DrawPrimitives()" ); - float fSongBeat = max( 0, GAMESTATE->m_fSongBeat ); + const float fSongBeat = GAMESTATE->m_fSongBeat; const float fBeatsToDrawBehind = m_iPixelsToDrawBehind * (1/(float)ARROW_SIZE) * (1/GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fArrowScrollSpeed); const float fBeatsToDrawAhead = m_iPixelsToDrawAhead * (1/(float)ARROW_SIZE) * (1/GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fArrowScrollSpeed); const float fFirstBeatToDraw = max( 0, fSongBeat - fBeatsToDrawBehind ); - const float fLastBeatToDraw = fSongBeat + fBeatsToDrawAhead; + const float fLastBeatToDraw = max( 0, fSongBeat + fBeatsToDrawAhead ); const int iFirstIndexToDraw = BeatToNoteRow(fFirstBeatToDraw); const int iLastIndexToDraw = BeatToNoteRow(fLastBeatToDraw); - //LOG->Trace( "Drawing elements %d through %d", iIndexFirstArrowToDraw, iIndexLastArrowToDraw ); + LOG->Trace( "Drawing elements %d through %d", iFirstIndexToDraw, iLastIndexToDraw ); if( GAMESTATE->m_bEditing ) { diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 9d1970bd3b..6b2dcf2114 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -293,6 +293,8 @@ ScreenEdit::~ScreenEdit() void ScreenEdit::Update( float fDeltaTime ) { + m_soundMusic.Update( fDeltaTime ); + float fPositionSeconds = m_soundMusic.GetPositionSeconds(); float fSongBeat, fBPS; bool bFreeze; @@ -848,8 +850,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_rectRecordBack.SetTweenDiffuse( D3DXCOLOR(0,0,0,0.8f) ); GAMESTATE->m_fSongBeat = m_NoteFieldEdit.m_fBeginMarker - 4; // give a 1 measure lead-in - float fElapsedSeconds = max( 0, m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) ); - m_soundMusic.SetPositionSeconds( fElapsedSeconds ); + const float fStartSeconds = m_pSong->GetElapsedTimeFromBeat( GAMESTATE->m_fSongBeat ); + m_soundMusic.SetPositionSeconds( fStartSeconds ); m_soundMusic.Play(); m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); } diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 97df4f1ae8..8bd5eca6dc 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -349,59 +349,6 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) m_bTryExtraStage = false; - ////////////////////////// - // Init non-ResultMode specific displays - ////////////////////////// - for( l=0; lGetPathTo("Graphics","evaluation judge labels") ); - m_sprJudgeLabels[l].StopAnimating(); - m_sprJudgeLabels[l].SetState( l ); - m_sprJudgeLabels[l].SetXY( JUDGE_LABELS_X, JUDGE_Y(l) ); - m_sprJudgeLabels[l].SetZoom( 1.0f ); - this->AddChild( &m_sprJudgeLabels[l] ); - } - - m_sprScoreLabel.Load( THEME->GetPathTo("Graphics","evaluation score labels") ); - m_sprScoreLabel.SetState( m_ResultMode==RM_ONI ? 1 : 0 ); - m_sprScoreLabel.StopAnimating(); - m_sprScoreLabel.SetXY( SCORE_LABELS_X, SCORE_Y ); - m_sprScoreLabel.SetZoom( 1.0f ); - this->AddChild( &m_sprScoreLabel ); - - - for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) - continue; // skip - - for( l=0; lGetPathTo("Graphics","evaluation score numbers 7x2"), "01234 :56789%." ); - m_textJudgeNumbers[l][p].TurnShadowOff(); - m_textJudgeNumbers[l][p].SetXY( JUDGE_X(p,l), JUDGE_Y(l) ); - m_textJudgeNumbers[l][p].SetZoom( 0.7f ); - m_textJudgeNumbers[l][p].SetDiffuse( PlayerToColor(p) ); - this->AddChild( &m_textJudgeNumbers[l][p] ); - } - - m_textJudgeNumbers[0][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_PERFECT]) ); - m_textJudgeNumbers[1][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_GREAT]) ); - m_textJudgeNumbers[2][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_GOOD]) ); - m_textJudgeNumbers[3][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_BOO]) ); - m_textJudgeNumbers[4][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_MISS]) ); - m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", iHoldNoteScores[p][HNS_OK]) ); - m_textJudgeNumbers[6][p].SetText( ssprintf("%4d", iMaxCombo[p]) ); - - - if( m_ResultMode==RM_ONI ) - m_ScoreDisplay[p].SetText( SecondsToTime(GAMESTATE->GetPlayerSurviveTime( (PlayerNumber)p )) ); - else - m_ScoreDisplay[p].SetScore( fScore[p] ); - } - - ///////////////////////////////// // Init ResultMode-specific displays ///////////////////////////////// @@ -531,6 +478,61 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) } } + ////////////////////////// + // Init non-ResultMode specific displays. + // Do this after Result-specific displays so that the text will draw on top of + // the bonus frame. + ////////////////////////// + for( l=0; lGetPathTo("Graphics","evaluation judge labels") ); + m_sprJudgeLabels[l].StopAnimating(); + m_sprJudgeLabels[l].SetState( l ); + m_sprJudgeLabels[l].SetXY( JUDGE_LABELS_X, JUDGE_Y(l) ); + m_sprJudgeLabels[l].SetZoom( 1.0f ); + this->AddChild( &m_sprJudgeLabels[l] ); + } + + m_sprScoreLabel.Load( THEME->GetPathTo("Graphics","evaluation score labels") ); + m_sprScoreLabel.SetState( m_ResultMode==RM_ONI ? 1 : 0 ); + m_sprScoreLabel.StopAnimating(); + m_sprScoreLabel.SetXY( SCORE_LABELS_X, SCORE_Y ); + m_sprScoreLabel.SetZoom( 1.0f ); + this->AddChild( &m_sprScoreLabel ); + + + for( p=0; pIsPlayerEnabled( (PlayerNumber)p ) ) + continue; // skip + + for( l=0; lGetPathTo("Graphics","evaluation score numbers 7x2"), "01234 :56789%." ); + m_textJudgeNumbers[l][p].TurnShadowOff(); + m_textJudgeNumbers[l][p].SetXY( JUDGE_X(p,l), JUDGE_Y(l) ); + m_textJudgeNumbers[l][p].SetZoom( 0.7f ); + m_textJudgeNumbers[l][p].SetDiffuse( PlayerToColor(p) ); + this->AddChild( &m_textJudgeNumbers[l][p] ); + } + + m_textJudgeNumbers[0][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_PERFECT]) ); + m_textJudgeNumbers[1][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_GREAT]) ); + m_textJudgeNumbers[2][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_GOOD]) ); + m_textJudgeNumbers[3][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_BOO]) ); + m_textJudgeNumbers[4][p].SetText( ssprintf("%4d", iTapNoteScores[p][TNS_MISS]) ); + m_textJudgeNumbers[5][p].SetText( ssprintf("%4d", iHoldNoteScores[p][HNS_OK]) ); + m_textJudgeNumbers[6][p].SetText( ssprintf("%4d", iMaxCombo[p]) ); + + + if( m_ResultMode==RM_ONI ) + m_ScoreDisplay[p].SetText( SecondsToTime(GAMESTATE->GetPlayerSurviveTime( (PlayerNumber)p )) ); + else + m_ScoreDisplay[p].SetScore( fScore[p] ); + } + + bool bOneHasNewRecord = false; for( p=0; pm_pCurSong->GetMusicPath(), true ); // enable accurate sync - float fStartSeconds = min( 0, -4+GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat(GAMESTATE->m_pCurSong->m_fFirstBeat) ); - m_soundMusic.SetPositionSeconds( fStartSeconds ); + const float fFirstBeat = GAMESTATE->m_pCurSong->m_fFirstBeat; + const float fFirstSecond = GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat( fFirstBeat ); + const float fStartSecond = min( 0, fFirstSecond-4 ); + m_soundMusic.SetPositionSeconds( fStartSecond ); m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); if( !bFirstLoad ) m_soundMusic.Play(); @@ -608,17 +610,27 @@ void ScreenGameplay::Update( float fDeltaTime ) GAMESTATE->m_fSongBeat = fSongBeat; GAMESTATE->m_fCurBPS = fBPS; GAMESTATE->m_bFreeze = bFreeze; + +// printf( "m_fSongBeat = %f\n", GAMESTATE->m_fSongBeat ); - /* Before the music starts, we have no song position, so set it toto +/* + * Before the music starts, we have no song position, so set it toto * -1; if we leave it alone we'll get 0, which will cause movies to start * playing before the music starts. * * We really should be setting the beat to negative numbers before the song * starts, leading up to 0, but we need a separate time source to do that. - * XXX: do this once we have a new sound infrastructure. */ + * XXX: do this once we have a new sound infrastructure. if(!m_soundMusic.IsPlaying()) GAMESTATE->m_fSongBeat = -1; + + Chris: Actually, RageSoundStream has a "fake" second counter built into + it. If you set its position to a negative second and call Update() on it, + it will count up as if was playing music. + +*/ + // LOG->Trace( "GAMESTATE->m_fMusicSeconds = %f", GAMESTATE->m_fMusicSeconds ); diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index bac13a5175..845bcf1a1c 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -303,11 +303,11 @@ void ScreenSelectMusic::TweenOffScreen() { int i; - m_sprBannerFrame.FadeOff( 0, "bounce left", TWEEN_TIME ); - m_Banner.FadeOff( 0, "bounce left", TWEEN_TIME ); - m_BPMDisplay.FadeOff( 0, "bounce left", TWEEN_TIME ); - m_textStage.FadeOff( 0, "bounce left", TWEEN_TIME ); - m_sprCDTitle.FadeOff( 0, "bounce left", TWEEN_TIME ); + m_sprBannerFrame.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); + m_Banner.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); + m_BPMDisplay.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); + m_textStage.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); + m_sprCDTitle.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); for( int p=0; p