Files
itgmania212121/stepmania/src/Banner.cpp
T

117 lines
3.0 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;
Banner::Load( THEME->GetPathTo("Graphics","fallback banner") );
}
bool Banner::Load( CString sFilePath, RageTexturePrefs prefs )
2002-05-19 01:59:48 +00:00
{
// note that the defaults are changes for faster loading
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
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);
}
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();
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() );
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 );
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
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();
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 );
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()
{
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
}