2001-11-03 10:52:42 +00:00
|
|
|
#include "stdafx.h"
|
2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: Banner.h
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-04 19:34:28 +00:00
|
|
|
Desc: The song's banner displayed in SelectSong.
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2001-11-04 19:34:28 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
|
|
|
|
|
#include "Banner.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-05-19 01:59:48 +00:00
|
|
|
#include "SongManager.h"
|
2002-02-03 20:45:08 +00:00
|
|
|
#include "RageBitmapTexture.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-09-05 03:45:07 +00:00
|
|
|
Banner::Banner()
|
|
|
|
|
{
|
|
|
|
|
m_bScrolling = false;
|
|
|
|
|
m_fPercentScrolling = 0;
|
|
|
|
|
|
|
|
|
|
Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-14 01:26:19 +00:00
|
|
|
bool Banner::Load( CString sFilePath, RageTexturePrefs prefs )
|
2002-05-19 01:59:48 +00:00
|
|
|
{
|
|
|
|
|
// note that the defaults are changes for faster loading
|
2002-11-14 01:26:19 +00:00
|
|
|
return CroppedSprite::Load( sFilePath, prefs );
|
2002-05-19 01:59:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void Banner::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
CroppedSprite::Update( fDeltaTime );
|
|
|
|
|
|
|
|
|
|
if( m_bScrolling )
|
|
|
|
|
{
|
|
|
|
|
m_fPercentScrolling += fDeltaTime/2;
|
|
|
|
|
m_fPercentScrolling -= (int)m_fPercentScrolling;
|
2002-05-27 08:23:27 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
const RectF *pTextureRect = m_pTexture->GetTextureCoordRect(0);
|
2002-05-27 08:23:27 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
float fTexCoords[8] =
|
|
|
|
|
{
|
2002-05-27 08:23:27 +00:00
|
|
|
0+m_fPercentScrolling, pTextureRect->bottom, // bottom left
|
|
|
|
|
0+m_fPercentScrolling, pTextureRect->top, // top left
|
|
|
|
|
1+m_fPercentScrolling, pTextureRect->bottom, // bottom right
|
|
|
|
|
1+m_fPercentScrolling, pTextureRect->top, // top right
|
2002-05-19 01:59:48 +00:00
|
|
|
};
|
|
|
|
|
Sprite::SetCustomTextureCoords( fTexCoords );
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-28 10:15:59 +00:00
|
|
|
|
2002-12-16 07:33:32 +00:00
|
|
|
void Banner::SetScrolling( bool bScroll, float Percent)
|
|
|
|
|
{
|
|
|
|
|
m_bScrolling = bScroll;
|
|
|
|
|
m_fPercentScrolling = Percent;
|
|
|
|
|
|
|
|
|
|
/* Set up the texture coord rects for the current state. */
|
|
|
|
|
Update(0);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-29 21:56:14 +00:00
|
|
|
bool Banner::LoadFromSong( Song* pSong ) // NULL means no song
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
2002-05-27 08:23:27 +00:00
|
|
|
m_bScrolling = false;
|
2002-05-19 01:59:48 +00:00
|
|
|
|
2002-03-31 07:55:25 +00:00
|
|
|
Sprite::TurnShadowOff();
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
if( pSong == NULL ) Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
2002-05-19 01:59:48 +00:00
|
|
|
else if( pSong->HasBanner() ) Banner::Load( pSong->GetBannerPath() );
|
2002-08-20 21:00:56 +00:00
|
|
|
else if( PREFSMAN->m_bUseBGIfNoBanner && pSong->HasBackground() ) Banner::Load( pSong->GetBackgroundPath() );
|
2002-08-13 23:26:46 +00:00
|
|
|
else Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
2002-05-19 01:59:48 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Banner::LoadFromGroup( CString sGroupName )
|
|
|
|
|
{
|
2002-07-02 00:27:58 +00:00
|
|
|
m_bScrolling = false;
|
2002-05-19 01:59:48 +00:00
|
|
|
|
|
|
|
|
CString sGroupBannerPath = SONGMAN->GetGroupBannerPath( sGroupName );
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
if( sGroupName == "ALL MUSIC" )
|
|
|
|
|
Banner::Load( THEME->GetPathTo("Graphics","all music banner") );
|
|
|
|
|
else if( sGroupBannerPath != "" )
|
2002-05-19 01:59:48 +00:00
|
|
|
Banner::Load( sGroupBannerPath );
|
|
|
|
|
else
|
2002-09-22 18:18:50 +00:00
|
|
|
Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-03-06 08:25:09 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-14 22:25:22 +00:00
|
|
|
bool Banner::LoadFromCourse( Course* pCourse ) // NULL means no course
|
|
|
|
|
{
|
|
|
|
|
m_bScrolling = false;
|
|
|
|
|
|
|
|
|
|
Sprite::TurnShadowOff();
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
if( pCourse == NULL ) Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
2002-06-14 22:25:22 +00:00
|
|
|
else if( pCourse->m_sBannerPath != "" ) Banner::Load( pCourse->m_sBannerPath );
|
2002-08-13 23:26:46 +00:00
|
|
|
else Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
|
2002-06-14 22:25:22 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
bool Banner::LoadRoulette()
|
|
|
|
|
{
|
2002-11-14 01:26:19 +00:00
|
|
|
RageTexturePrefs prefs;
|
|
|
|
|
prefs.iMipMaps = 0;
|
|
|
|
|
Banner::Load( THEME->GetPathTo("Graphics","select music roulette banner"), prefs );
|
2002-05-19 01:59:48 +00:00
|
|
|
m_bScrolling = true;
|
|
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
return true;
|
2002-05-19 01:59:48 +00:00
|
|
|
}
|