allow two simultaneous fades

This commit is contained in:
Glenn Maynard
2004-10-23 04:04:09 +00:00
parent dfe6b48b70
commit 16e90febbd
2 changed files with 39 additions and 26 deletions
+37 -22
View File
@@ -9,23 +9,30 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "SongManager.h" #include "SongManager.h"
CachedThemeMetricF FADE_SECONDS ("FadingBanner","FadeSeconds"); static CachedThemeMetricF FADE_SECONDS ("FadingBanner","FadeSeconds");
/*
* Allow fading from one banner to another. We can handle two fades at once;
* this is used to fade from an old banner to a low-quality banner to a high-
* quality banner smoothly.
*
* m_iIndexLatest is the latest banner loaded, and the one that we'll end up
* displaying when the fades stop.
*/
FadingBanner::FadingBanner() FadingBanner::FadingBanner()
{ {
FADE_SECONDS.Refresh(); FADE_SECONDS.Refresh();
m_bMovingFast = false; m_bMovingFast = false;
m_bSkipNextBannerUpdate = false; m_bSkipNextBannerUpdate = false;
m_iIndexFront = 0; m_iIndexLatest = 0;
for( int i=0; i<2; i++ ) for( int i=0; i<3; i++ )
this->AddChild( &m_Banner[i] ); this->AddChild( &m_Banner[i] );
} }
void FadingBanner::ScaleToClipped( float fWidth, float fHeight ) void FadingBanner::ScaleToClipped( float fWidth, float fHeight )
{ {
for( int i=0; i<2; i++ ) for( int i=0; i<3; i++ )
m_Banner[i].ScaleToClipped( fWidth, fHeight ); m_Banner[i].ScaleToClipped( fWidth, fHeight );
} }
@@ -39,6 +46,7 @@ void FadingBanner::Update( float fDeltaTime )
{ {
m_Banner[0].Update( fDeltaTime ); m_Banner[0].Update( fDeltaTime );
m_Banner[1].Update( fDeltaTime ); m_Banner[1].Update( fDeltaTime );
m_Banner[2].Update( fDeltaTime );
} }
m_bSkipNextBannerUpdate = false; m_bSkipNextBannerUpdate = false;
@@ -48,27 +56,34 @@ void FadingBanner::DrawPrimitives()
{ {
// draw manually // draw manually
// ActorFrame::DrawPrimitives(); // ActorFrame::DrawPrimitives();
m_Banner[GetBackIndex()].Draw();
m_Banner[m_iIndexFront].Draw(); /* Render the latest banner first. */
for( int i = 0; i < 3; ++i )
{
int index = m_iIndexLatest - i;
wrap( index, 3 );
m_Banner[index].Draw();
}
} }
bool FadingBanner::Load( RageTextureID ID ) bool FadingBanner::Load( RageTextureID ID )
{ {
BeforeChange(); BeforeChange();
bool bRet = m_Banner[GetBackIndex()].Load(ID); bool bRet = m_Banner[m_iIndexLatest].Load(ID);
return bRet; return bRet;
} }
void FadingBanner::BeforeChange() void FadingBanner::BeforeChange()
{ {
m_Banner[m_iIndexFront].SetDiffuse( RageColor(1,1,1,1) ); m_Banner[m_iIndexLatest].SetDiffuse( RageColor(1,1,1,1) );
m_Banner[m_iIndexLatest].StopTweening();
m_Banner[m_iIndexLatest].BeginTweening( FADE_SECONDS ); // fade out
m_Banner[m_iIndexLatest].SetDiffuse( RageColor(1,1,1,0) );
m_iIndexFront = GetBackIndex(); ++m_iIndexLatest;
wrap( m_iIndexLatest, 3 );
m_Banner[m_iIndexFront].SetDiffuse( RageColor(1,1,1,1) ); m_Banner[m_iIndexLatest].SetDiffuse( RageColor(1,1,1,1) );
m_Banner[m_iIndexFront].StopTweening();
m_Banner[m_iIndexFront].BeginTweening( FADE_SECONDS ); // fade out
m_Banner[m_iIndexFront].SetDiffuse( RageColor(1,1,1,0) );
/* We're about to load a banner. It'll probably cause a frame skip or /* We're about to load a banner. It'll probably cause a frame skip or
* two. Skip an update, so the fade-in doesn't skip. */ * two. Skip an update, so the fade-in doesn't skip. */
@@ -80,7 +95,7 @@ void FadingBanner::BeforeChange()
bool FadingBanner::LoadFromCachedBanner( const CString &path ) bool FadingBanner::LoadFromCachedBanner( const CString &path )
{ {
/* If we're already on the given banner, don't fade again. */ /* If we're already on the given banner, don't fade again. */
if( path != "" && m_Banner[GetBackIndex()].GetTexturePath() == path ) if( path != "" && m_Banner[m_iIndexLatest].GetTexturePath() == path )
return false; return false;
if( path == "" ) if( path == "" )
@@ -120,7 +135,7 @@ bool FadingBanner::LoadFromCachedBanner( const CString &path )
} }
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].Load( ID ); m_Banner[m_iIndexLatest].Load( ID );
return bLowRes; return bLowRes;
} }
@@ -135,19 +150,19 @@ void FadingBanner::LoadFromSong( const Song* pSong )
void FadingBanner::LoadAllMusic() void FadingBanner::LoadAllMusic()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadAllMusic(); m_Banner[m_iIndexLatest].LoadAllMusic();
} }
void FadingBanner::LoadSort() void FadingBanner::LoadSort()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadSort(); m_Banner[m_iIndexLatest].LoadSort();
} }
void FadingBanner::LoadMode() void FadingBanner::LoadMode()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadMode(); m_Banner[m_iIndexLatest].LoadMode();
} }
void FadingBanner::LoadFromGroup( CString sGroupName ) void FadingBanner::LoadFromGroup( CString sGroupName )
@@ -164,19 +179,19 @@ void FadingBanner::LoadFromCourse( const Course* pCourse )
void FadingBanner::LoadRoulette() void FadingBanner::LoadRoulette()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadRoulette(); m_Banner[m_iIndexLatest].LoadRoulette();
} }
void FadingBanner::LoadRandom() void FadingBanner::LoadRandom()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadRandom(); m_Banner[m_iIndexLatest].LoadRandom();
} }
void FadingBanner::LoadFallback() void FadingBanner::LoadFallback()
{ {
BeforeChange(); BeforeChange();
m_Banner[GetBackIndex()].LoadFallback(); m_Banner[m_iIndexLatest].LoadFallback();
} }
/* /*
+2 -4
View File
@@ -34,10 +34,8 @@ public:
protected: protected:
void BeforeChange(); void BeforeChange();
Banner m_Banner[3];
Banner m_Banner[2]; int m_iIndexLatest;
int m_iIndexFront;
int GetBackIndex() { return m_iIndexFront==0 ? 1 : 0; }
bool m_bMovingFast; bool m_bMovingFast;
bool m_bSkipNextBannerUpdate; bool m_bSkipNextBannerUpdate;