From c74333eeb5259b2935aa74788a2ea0ec9631c5ff Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 4 Aug 2003 00:04:28 +0000 Subject: [PATCH] Add support for 0% and negative background rates. This isn't supported by many codecs though... --- stepmania/src/BGAnimationLayer.cpp | 10 ++++++++-- stepmania/src/Background.cpp | 11 ++++------- stepmania/src/ScreenEdit.cpp | 2 +- stepmania/src/ScreenMiniMenu.h | 4 ++-- .../src/arch/MovieTexture/MovieTexture_DShow.cpp | 16 ++++++++++++++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index ab543e486d..4eecc94bfd 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -964,13 +964,19 @@ void BGAnimationLayer::GainingFocus( float fRate, bool bRewindMovie, bool bLoop // FIXME: Very dangerous. How could we handle this better? Sprite* pSprite = (Sprite*)m_pActors[0]; - pSprite->GetTexture()->SetPlaybackRate(fRate); + + // + // The order of these actions is important. + // At this point, the movie is probably paused (by LosingFocus()). + // Play the movie, then set the playback rate (which can + // potentially pause the movie again). + // if( bRewindMovie ) pSprite->GetTexture()->SetPosition( 0 ); pSprite->GetTexture()->SetLooping(bLoop); - // if movie texture, pause and play movie so we don't waste CPU cycles decoding frames that won't be shown pSprite->GetTexture()->Play(); + pSprite->GetTexture()->SetPlaybackRate(fRate); for( unsigned i=0; iCommand( m_sOnCommand ); diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index a6f6d9640a..0fc3958268 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -414,13 +414,10 @@ void Background::Update( float fDeltaTime ) m_pCurrentBGA = m_BGAnimations[ change.m_sBGName ]; - if( pOld != m_pCurrentBGA ) - { - if( pOld ) - pOld->LosingFocus(); - if( m_pCurrentBGA ) - m_pCurrentBGA->GainingFocus( change.m_fRate, change.m_bRewindMovie, change.m_bLoop ); - } + if( pOld ) + pOld->LosingFocus(); + if( m_pCurrentBGA ) + m_pCurrentBGA->GainingFocus( change.m_fRate, change.m_bRewindMovie, change.m_bLoop ); m_fSecsLeftInFade = m_pFadingBGA!=NULL ? FADE_SECONDS : 0; } diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 11a7adee0a..2e0b9f5a33 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -193,7 +193,7 @@ Menu g_EditSongInfo Menu g_BGChange ( "Background Change", - MenuRow( "Rate (applies to new adds)", true, 5, "50%","60%","70%","80%","90%","100%","110%","120%","130%","140%","150%","160%","170%","180%","190%","200%" ), + MenuRow( "Rate (applies to new adds)", true, 15, "-100%","-80%","-60%","-40%","-20%","0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%","120%","140%","160%","180%","200%" ), MenuRow( "Fade Last (applies to new adds)", true, 0, "NO","YES" ), MenuRow( "Rewind Movie (applies to new adds)", true, 0, "NO","YES" ), MenuRow( "Loop (applies to new adds)", true, 1, "NO","YES" ), diff --git a/stepmania/src/ScreenMiniMenu.h b/stepmania/src/ScreenMiniMenu.h index 6e37992b6e..c98b5955dd 100644 --- a/stepmania/src/ScreenMiniMenu.h +++ b/stepmania/src/ScreenMiniMenu.h @@ -33,13 +33,13 @@ struct MenuRow defaultChoice = 0; } - MenuRow( const char * n, bool e, int d=0, const char * c0=NULL, const char * c1=NULL, const char * c2=NULL, const char * c3=NULL, const char * c4=NULL, const char * c5=NULL, const char * c6=NULL, const char * c7=NULL, const char * c8=NULL, const char * c9=NULL, const char * c10=NULL, const char * c11=NULL, const char * c12=NULL, const char * c13=NULL, const char * c14=NULL, const char * c15=NULL, const char * c16=NULL, const char * c17=NULL, const char * c18=NULL, const char * c19=NULL ) + MenuRow( const char * n, bool e, int d=0, const char * c0=NULL, const char * c1=NULL, const char * c2=NULL, const char * c3=NULL, const char * c4=NULL, const char * c5=NULL, const char * c6=NULL, const char * c7=NULL, const char * c8=NULL, const char * c9=NULL, const char * c10=NULL, const char * c11=NULL, const char * c12=NULL, const char * c13=NULL, const char * c14=NULL, const char * c15=NULL, const char * c16=NULL, const char * c17=NULL, const char * c18=NULL, const char * c19=NULL, const char * c20=NULL, const char * c21=NULL, const char * c22=NULL, const char * c23=NULL, const char * c24=NULL ) { name = n; enabled = e; defaultChoice = d; #define PUSH( c ) if(c!=NULL) choices.push_back(c); - PUSH(c0);PUSH(c1);PUSH(c2);PUSH(c3);PUSH(c4);PUSH(c5);PUSH(c6);PUSH(c7);PUSH(c8);PUSH(c9);PUSH(c10);PUSH(c11);PUSH(c12);PUSH(c13);PUSH(c14);PUSH(c15);PUSH(c16);PUSH(c17);PUSH(c18);PUSH(c19); + PUSH(c0);PUSH(c1);PUSH(c2);PUSH(c3);PUSH(c4);PUSH(c5);PUSH(c6);PUSH(c7);PUSH(c8);PUSH(c9);PUSH(c10);PUSH(c11);PUSH(c12);PUSH(c13);PUSH(c14);PUSH(c15);PUSH(c16);PUSH(c17);PUSH(c18);PUSH(c19);PUSH(c20);PUSH(c21);PUSH(c22);PUSH(c23);PUSH(c24); #undef PUSH // printf( "choices.size = %u", choices.size() ); } diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp index 8957ad337b..45aed27e90 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -453,13 +453,25 @@ void MovieTexture_DShow::SetPosition( float fSeconds ) void MovieTexture_DShow::SetPlaybackRate( float fRate ) { + if( fRate == 0 ) + { + this->Pause(); + return; + } + SkipUpdates(); CComPtr pMP; - m_pGB.QueryInterface(&pMP); - pMP->put_Rate(fRate); + m_pGB.QueryInterface(&pMP); + HRESULT hr = pMP->put_Rate(fRate); // fails on many codecs StopSkippingUpdates(); + + if( FAILED(hr) ) + { + this->Pause(); + return; + } } bool MovieTexture_DShow::IsPlaying() const