Handle low-quality banners.
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
*/
|
||||
|
||||
#include "FadingBanner.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "BannerCache.h"
|
||||
#include "song.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
/* XXX: metric */
|
||||
static const float FadeTime = 0.25;
|
||||
|
||||
FadingBanner::FadingBanner()
|
||||
{
|
||||
@@ -26,9 +33,26 @@ void FadingBanner::SetCroppedSize( float fWidth, float fHeight )
|
||||
m_Banner[i].SetCroppedSize( fWidth, fHeight );
|
||||
}
|
||||
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
void FadingBanner::Update( float fDeltaTime )
|
||||
{
|
||||
ActorFrame::Update( fDeltaTime );
|
||||
|
||||
/* Don't fade to the full banner until we finish fading. */
|
||||
float HighQualTime = FadeTime;
|
||||
|
||||
/* Hacky: also don't fade until the music wheel has a chance to settle down. */
|
||||
HighQualTime = max( HighQualTime, 1.0f / PREFSMAN->m_iMusicWheelSwitchSpeed );
|
||||
HighQualTime = max( HighQualTime, THEME->GetMetricF("MusicWheel","SwitchSeconds") );
|
||||
|
||||
if( m_sPendingBanner == "" || m_PendingTimer.PeekDeltaTime() < HighQualTime )
|
||||
return;
|
||||
|
||||
/* Load the high quality banner. */
|
||||
CString banner = m_sPendingBanner;
|
||||
BeforeChange();
|
||||
m_Banner[GetBackIndex()].Load( banner );
|
||||
}
|
||||
|
||||
void FadingBanner::DrawPrimitives()
|
||||
@@ -53,14 +77,38 @@ void FadingBanner::BeforeChange()
|
||||
|
||||
m_Banner[m_iIndexFront].SetDiffuse( RageColor(1,1,1,1) );
|
||||
m_Banner[m_iIndexFront].StopTweening();
|
||||
m_Banner[m_iIndexFront].BeginTweening( 0.25f ); // fade out
|
||||
m_Banner[m_iIndexFront].BeginTweening( FadeTime ); // fade out
|
||||
m_Banner[m_iIndexFront].SetDiffuse( RageColor(1,1,1,0) );
|
||||
|
||||
m_sPendingBanner = "";
|
||||
}
|
||||
|
||||
void FadingBanner::LoadFromSong( Song* pSong )
|
||||
{
|
||||
BeforeChange();
|
||||
m_Banner[GetBackIndex()].LoadFromSong( pSong );
|
||||
|
||||
if( !pSong->HasBanner() ||
|
||||
TEXTUREMAN->IsTextureRegistered( Banner::BannerTex( pSong->GetBannerPath() ) ) )
|
||||
{
|
||||
/* We either don't have a regular banner at all, or we have a banner and
|
||||
* it's cached; just use Banner's logic. */
|
||||
m_Banner[GetBackIndex()].LoadFromSong( pSong );
|
||||
return;
|
||||
}
|
||||
|
||||
/* We have a banner, but it's not loaded. Try to load the low quality version. */
|
||||
RageTextureID ID = BANNERCACHE->LoadCachedSongBanner( pSong->GetBannerPath() );
|
||||
|
||||
if( !TEXTUREMAN->IsTextureRegistered(ID) )
|
||||
{
|
||||
LOG->Warn("Load of reduced banner for '%s' failed", pSong->GetSongDir().c_str() );
|
||||
m_Banner[GetBackIndex()].LoadFromSong( pSong );
|
||||
return;
|
||||
}
|
||||
|
||||
m_Banner[GetBackIndex()].Load( ID );
|
||||
m_sPendingBanner = pSong->GetBannerPath();
|
||||
m_PendingTimer.GetDeltaTime(); /* reset */
|
||||
}
|
||||
|
||||
void FadingBanner::LoadAllMusic()
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "Banner.h"
|
||||
#include "ActorFrame.h"
|
||||
#include "RageTimer.h"
|
||||
|
||||
class FadingBanner : public ActorFrame
|
||||
{
|
||||
@@ -39,6 +40,9 @@ protected:
|
||||
Banner m_Banner[2];
|
||||
int m_iIndexFront;
|
||||
int GetBackIndex() { return m_iIndexFront==0 ? 1 : 0; }
|
||||
|
||||
CString m_sPendingBanner;
|
||||
RageTimer m_PendingTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user