Files
itgmania212121/stepmania/src/Banner.cpp
T

116 lines
2.7 KiB
C++
Raw Normal View History

2001-11-03 10:52:42 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: Banner.h
2001-11-03 10:52:42 +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-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"
#include "RageBitmapTexture.h"
#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;
2003-01-02 01:39:58 +00:00
LoadFallback();
2002-09-05 03:45:07 +00:00
}
bool Banner::Load( RageTextureID ID )
2002-05-19 01:59:48 +00:00
{
2003-02-12 22:50:21 +00:00
/* Song banners often have HOT PINK color keys. */
ID.bHotPinkColorKey = true;
return CroppedSprite::Load( ID );
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
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
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);
}
2003-01-02 01:39:58 +00:00
void Banner::LoadFromSong( Song* pSong ) // NULL means no song
2001-11-03 10:52:42 +00:00
{
2002-03-31 07:55:25 +00:00
Sprite::TurnShadowOff();
2003-01-02 01:39:58 +00:00
if( pSong == NULL ) LoadFallback();
2003-02-12 22:50:21 +00:00
else if( pSong->HasBanner() ) Load( pSong->GetBannerPath() );
2003-01-02 01:39:58 +00:00
else if( PREFSMAN->m_bUseBGIfNoBanner && pSong->HasBackground() ) Load( pSong->GetBackgroundPath() );
else LoadFallback();
2003-02-12 22:54:22 +00:00
m_bScrolling = false;
2002-05-19 01:59:48 +00:00
}
2003-01-02 01:39:58 +00:00
void Banner::LoadFromGroup( CString sGroupName )
2002-05-19 01:59:48 +00:00
{
CString sGroupBannerPath = SONGMAN->GetGroupBannerPath( sGroupName );
if( sGroupName == "ALL MUSIC" )
2003-01-02 01:39:58 +00:00
Load( THEME->GetPathTo("Graphics","all music banner") );
else if( sGroupBannerPath != "" )
2003-01-02 01:39:58 +00:00
Load( sGroupBannerPath );
2002-05-19 01:59:48 +00:00
else
2003-01-02 01:39:58 +00:00
LoadFallback();
2003-02-12 22:54:22 +00:00
m_bScrolling = false;
2002-03-06 08:25:09 +00:00
}
2003-01-02 01:39:58 +00:00
void Banner::LoadFromCourse( Course* pCourse ) // NULL means no course
2002-06-14 22:25:22 +00:00
{
Sprite::TurnShadowOff();
2003-01-02 01:39:58 +00:00
if( pCourse == NULL ) LoadFallback();
else if( pCourse->m_sBannerPath != "" ) Load( pCourse->m_sBannerPath );
else LoadFallback();
2003-02-12 22:54:22 +00:00
m_bScrolling = false;
2003-01-02 01:39:58 +00:00
}
2002-06-14 22:25:22 +00:00
2003-01-02 01:39:58 +00:00
void Banner::LoadFallback()
{
Load( THEME->GetPathTo("Graphics","fallback banner") );
2002-06-14 22:25:22 +00:00
}
2003-01-02 01:39:58 +00:00
void Banner::LoadRoulette()
2002-05-19 01:59:48 +00:00
{
RageTextureID ID(THEME->GetPathTo("Graphics","select music roulette banner"));
ID.iMipMaps = 0;
2003-01-02 01:39:58 +00:00
Load( ID );
2002-05-19 01:59:48 +00:00
m_bScrolling = true;
}