2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-01-20 09:13:43 +00:00
|
|
|
#include "Background.h"
|
|
|
|
|
#include "RageUtil.h"
|
2002-05-01 19:14:55 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-07-27 19:29:51 +00:00
|
|
|
#include "RageException.h"
|
|
|
|
|
#include "RageTimer.h"
|
2003-03-24 20:57:19 +00:00
|
|
|
#include "RageLog.h"
|
2003-07-09 20:28:07 +00:00
|
|
|
#include "RageTextureManager.h"
|
2002-08-18 16:19:26 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2003-03-16 00:05:23 +00:00
|
|
|
#include "NoteTypes.h"
|
2003-08-29 09:41:11 +00:00
|
|
|
#include "Steps.h"
|
2003-06-27 08:06:22 +00:00
|
|
|
#include "DancingCharacters.h"
|
2003-07-22 07:47:27 +00:00
|
|
|
#include "arch/arch.h"
|
2003-08-31 07:28:19 +00:00
|
|
|
#include "BeginnerHelper.h"
|
2003-12-31 21:03:14 +00:00
|
|
|
#include "StageStats.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2002-01-20 09:13:43 +00:00
|
|
|
|
2004-01-23 02:23:11 +00:00
|
|
|
#include <set>
|
|
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
|
2002-10-10 04:11:30 +00:00
|
|
|
const float FADE_SECONDS = 1.0f;
|
|
|
|
|
|
2004-04-02 00:13:47 +00:00
|
|
|
#define LEFT_EDGE THEME->GetMetricF("Background","LeftEdge")
|
|
|
|
|
#define TOP_EDGE THEME->GetMetricF("Background","TopEdge")
|
|
|
|
|
#define RIGHT_EDGE THEME->GetMetricF("Background","RightEdge")
|
|
|
|
|
#define BOTTOM_EDGE THEME->GetMetricF("Background","BottomEdge")
|
2003-12-07 20:29:42 +00:00
|
|
|
CachedThemeMetricB BLINK_DANGER_ALL("Background","BlinkDangerAll");
|
2003-12-07 21:40:00 +00:00
|
|
|
CachedThemeMetricB DANGER_ALL_IS_OPAQUE("Background","DangerAllIsOpaque");
|
2004-04-19 20:28:10 +00:00
|
|
|
#define BRIGHTNESS_FADE_COMMAND THEME->GetMetric("Background","BrightnessFadeCommand")
|
2004-04-02 00:13:47 +00:00
|
|
|
#define RECT_BACKGROUND RectF(LEFT_EDGE,TOP_EDGE,RIGHT_EDGE,BOTTOM_EDGE)
|
2002-07-11 19:02:26 +00:00
|
|
|
|
2004-04-02 00:13:47 +00:00
|
|
|
static float g_fBackgroundCenterWidth = 40;
|
2003-03-16 00:05:23 +00:00
|
|
|
const CString STATIC_BACKGROUND = "static background";
|
2002-01-20 09:13:43 +00:00
|
|
|
|
|
|
|
|
Background::Background()
|
|
|
|
|
{
|
2003-12-07 20:29:42 +00:00
|
|
|
BLINK_DANGER_ALL.Refresh();
|
2003-12-07 21:40:00 +00:00
|
|
|
DANGER_ALL_IS_OPAQUE.Refresh();
|
2003-12-07 20:29:42 +00:00
|
|
|
|
2003-04-14 04:10:01 +00:00
|
|
|
m_iCurBGChangeIndex = -1;
|
2003-04-13 00:44:50 +00:00
|
|
|
m_pCurrentBGA = NULL;
|
2002-10-10 04:11:30 +00:00
|
|
|
m_pFadingBGA = NULL;
|
|
|
|
|
m_fSecsLeftInFade = 0;
|
2002-01-20 09:13:43 +00:00
|
|
|
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DangerAll.LoadFromAniDir( THEME->GetPathToB("ScreenGameplay danger all") );
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DangerPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay danger p%d",p+1)) );
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DeadPlayer[p].LoadFromAniDir( THEME->GetPathToB(ssprintf("ScreenGameplay dead p%d",p+1)) );
|
2002-06-24 22:20:51 +00:00
|
|
|
|
2003-06-27 08:06:22 +00:00
|
|
|
bool bOneOrMoreChars = false;
|
2003-08-29 09:41:11 +00:00
|
|
|
bool bShowingBeginnerHelper = false;
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-09-04 07:21:31 +00:00
|
|
|
{
|
|
|
|
|
if( !GAMESTATE->IsHumanPlayer(p) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
bOneOrMoreChars = true;
|
|
|
|
|
// Disable dancing characters if BH will be showing.
|
|
|
|
|
if( PREFSMAN->m_bShowBeginnerHelper && BeginnerHelper::CanUse() &&
|
2004-05-24 06:12:17 +00:00
|
|
|
GAMESTATE->m_pCurSteps[p] && GAMESTATE->m_pCurSteps[p]->GetDifficulty() == DIFFICULTY_BEGINNER )
|
2003-09-04 07:21:31 +00:00
|
|
|
bShowingBeginnerHelper = true;
|
|
|
|
|
}
|
2003-08-29 09:41:11 +00:00
|
|
|
|
|
|
|
|
if( bOneOrMoreChars && !bShowingBeginnerHelper )
|
2003-06-27 08:06:22 +00:00
|
|
|
m_pDancingCharacters = new DancingCharacters;
|
|
|
|
|
else
|
|
|
|
|
m_pDancingCharacters = NULL;
|
2004-04-02 00:13:47 +00:00
|
|
|
|
2004-04-19 20:28:10 +00:00
|
|
|
m_quadBorder[0].StretchTo( RectF(SCREEN_LEFT,SCREEN_TOP,LEFT_EDGE,SCREEN_BOTTOM) );
|
|
|
|
|
m_quadBorder[0].SetDiffuse( RageColor(0,0,0,1) );
|
|
|
|
|
m_quadBorder[1].StretchTo( RectF(LEFT_EDGE,SCREEN_TOP,RIGHT_EDGE,TOP_EDGE) );
|
|
|
|
|
m_quadBorder[1].SetDiffuse( RageColor(0,0,0,1) );
|
|
|
|
|
m_quadBorder[2].StretchTo( RectF(RIGHT_EDGE,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
|
|
|
|
m_quadBorder[2].SetDiffuse( RageColor(0,0,0,1) );
|
|
|
|
|
m_quadBorder[3].StretchTo( RectF(LEFT_EDGE,BOTTOM_EDGE,RIGHT_EDGE,SCREEN_BOTTOM) );
|
|
|
|
|
m_quadBorder[3].SetDiffuse( RageColor(0,0,0,1) );
|
|
|
|
|
|
|
|
|
|
this->AddChild( &m_quadBorder[0] );
|
|
|
|
|
this->AddChild( &m_quadBorder[1] );
|
|
|
|
|
this->AddChild( &m_quadBorder[2] );
|
|
|
|
|
this->AddChild( &m_quadBorder[3] );
|
|
|
|
|
|
2004-04-02 00:13:47 +00:00
|
|
|
this->AddChild( &m_Brightness );
|
2002-07-11 19:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Background::~Background()
|
2002-08-18 16:19:26 +00:00
|
|
|
{
|
|
|
|
|
Unload();
|
2003-06-27 09:05:51 +00:00
|
|
|
delete m_pDancingCharacters;
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Background::Unload()
|
2002-07-11 19:02:26 +00:00
|
|
|
{
|
2003-03-16 00:05:23 +00:00
|
|
|
for( map<CString,BGAnimation*>::iterator iter = m_BGAnimations.begin();
|
|
|
|
|
iter != m_BGAnimations.end();
|
|
|
|
|
iter++ )
|
|
|
|
|
delete iter->second;
|
2002-10-24 20:15:24 +00:00
|
|
|
m_BGAnimations.clear();
|
2004-01-23 05:44:15 +00:00
|
|
|
m_RandomBGAnimations.clear();
|
2003-03-16 00:05:23 +00:00
|
|
|
m_aBGChanges.clear();
|
2004-01-23 05:44:15 +00:00
|
|
|
|
2003-04-13 00:44:50 +00:00
|
|
|
m_pCurrentBGA = NULL;
|
|
|
|
|
m_pFadingBGA = NULL;
|
2004-01-23 06:51:15 +00:00
|
|
|
m_pSong = NULL;
|
2003-08-19 07:42:09 +00:00
|
|
|
m_fSecsLeftInFade = 0;
|
2004-01-24 19:05:54 +00:00
|
|
|
m_iCurBGChangeIndex = -1;
|
2004-01-23 06:51:15 +00:00
|
|
|
m_fLastMusicSeconds = -9999;
|
2002-06-23 02:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-24 02:55:32 +00:00
|
|
|
void Background::LoadFromAniDir( CString sAniDir )
|
|
|
|
|
{
|
|
|
|
|
Unload();
|
|
|
|
|
|
2003-07-21 18:44:04 +00:00
|
|
|
if( PREFSMAN->m_fBGBrightness == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-09-29 05:06:18 +00:00
|
|
|
BGAnimation* pTempBGA;
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2002-09-24 02:55:32 +00:00
|
|
|
pTempBGA->LoadFromAniDir( sAniDir );
|
2003-03-16 00:05:23 +00:00
|
|
|
m_BGAnimations[STATIC_BACKGROUND] = pTempBGA;
|
2003-08-19 07:42:09 +00:00
|
|
|
m_aBGChanges.push_back( BackgroundChange(-1000, STATIC_BACKGROUND) );
|
2002-09-24 02:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
BGAnimation *Background::CreateSongBGA( CString sBGName ) const
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
BGAnimation *pTempBGA;
|
|
|
|
|
|
|
|
|
|
// Using aniseg.m_sBGName, search for the corresponding animation.
|
|
|
|
|
// Look in this order: movies in song dir, BGAnims in song dir
|
|
|
|
|
// movies in RandomMovies dir, BGAnims in BGAnimsDir.
|
|
|
|
|
CStringArray asFiles;
|
|
|
|
|
|
2002-12-28 16:07:19 +00:00
|
|
|
// Look for BGAnims in the song dir
|
2004-01-23 06:51:15 +00:00
|
|
|
GetDirListing( m_pSong->GetSongDir()+sBGName, asFiles, true, true );
|
2002-10-31 02:46:42 +00:00
|
|
|
if( !asFiles.empty() )
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2003-03-10 02:46:01 +00:00
|
|
|
pTempBGA->LoadFromAniDir( asFiles[0] );
|
2002-10-30 19:55:19 +00:00
|
|
|
return pTempBGA;
|
|
|
|
|
}
|
2003-04-13 23:22:27 +00:00
|
|
|
// Look for BG movies or static graphics in the song dir
|
2004-01-23 06:51:15 +00:00
|
|
|
GetDirListing( m_pSong->GetSongDir()+sBGName, asFiles, false, true );
|
2002-10-31 02:46:42 +00:00
|
|
|
if( !asFiles.empty() )
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2003-10-29 20:46:37 +00:00
|
|
|
const CString sExt = GetExtension( asFiles[0]) ;
|
2003-04-13 23:22:27 +00:00
|
|
|
if( sExt.CompareNoCase("avi")==0 ||
|
|
|
|
|
sExt.CompareNoCase("mpg")==0 ||
|
|
|
|
|
sExt.CompareNoCase("mpeg")==0 )
|
2003-04-14 04:10:01 +00:00
|
|
|
pTempBGA->LoadFromMovie( asFiles[0] );
|
2003-04-13 23:22:27 +00:00
|
|
|
else
|
|
|
|
|
pTempBGA->LoadFromStaticGraphic( asFiles[0] );
|
2002-10-30 19:55:19 +00:00
|
|
|
return pTempBGA;
|
|
|
|
|
}
|
|
|
|
|
// Look for movies in the RandomMovies dir
|
2003-03-16 00:05:23 +00:00
|
|
|
GetDirListing( RANDOMMOVIES_DIR+sBGName, asFiles, false, true );
|
2002-10-31 02:46:42 +00:00
|
|
|
if( !asFiles.empty() )
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2003-04-14 04:10:01 +00:00
|
|
|
pTempBGA->LoadFromMovie( asFiles[0] );
|
2002-10-30 19:55:19 +00:00
|
|
|
return pTempBGA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Look for BGAnims in the BGAnims dir
|
2003-03-16 00:05:23 +00:00
|
|
|
GetDirListing( BG_ANIMS_DIR+sBGName, asFiles, true, true );
|
2002-10-31 02:46:42 +00:00
|
|
|
if( !asFiles.empty() )
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2003-03-10 02:46:01 +00:00
|
|
|
pTempBGA->LoadFromAniDir( asFiles[0] );
|
2002-10-30 19:55:19 +00:00
|
|
|
return pTempBGA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Look for BGAnims in the BGAnims dir
|
2003-03-16 00:05:23 +00:00
|
|
|
GetDirListing( VISUALIZATIONS_DIR+sBGName, asFiles, false, true );
|
2002-10-31 02:46:42 +00:00
|
|
|
if( !asFiles.empty() )
|
2002-10-30 19:55:19 +00:00
|
|
|
{
|
|
|
|
|
pTempBGA = new BGAnimation;
|
2003-03-10 02:46:01 +00:00
|
|
|
pTempBGA->LoadFromVisualization( asFiles[0] );
|
2002-10-30 19:55:19 +00:00
|
|
|
return pTempBGA;
|
|
|
|
|
}
|
2003-03-16 00:05:23 +00:00
|
|
|
|
|
|
|
|
// There is no background by this name.
|
2002-10-30 19:55:19 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-23 02:23:11 +00:00
|
|
|
CString Background::CreateRandomBGA()
|
2003-03-16 00:05:23 +00:00
|
|
|
{
|
2004-01-23 02:23:11 +00:00
|
|
|
if( PREFSMAN->m_BackgroundMode == PrefsManager::BGMODE_OFF )
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
/* If we already have enough random BGAs loaded, use them round-robin. */
|
|
|
|
|
if( (int) m_RandomBGAnimations.size() >= PREFSMAN->m_iNumBackgrounds )
|
|
|
|
|
{
|
|
|
|
|
/* XXX: every time we fully loop, shuffle, so we don't play the same sequence
|
|
|
|
|
* over and over; and nudge the shuffle so the next one won't be a repeat */
|
|
|
|
|
const CString first = m_RandomBGAnimations.front();
|
|
|
|
|
m_RandomBGAnimations.push_back( m_RandomBGAnimations.front() );
|
|
|
|
|
m_RandomBGAnimations.pop_front();
|
|
|
|
|
return first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CStringArray arrayPaths;
|
2003-03-16 00:05:23 +00:00
|
|
|
switch( PREFSMAN->m_BackgroundMode )
|
|
|
|
|
{
|
|
|
|
|
default:
|
2004-01-23 02:23:11 +00:00
|
|
|
FAIL_M( ssprintf("Invalid BackgroundMode: %i", PREFSMAN->m_BackgroundMode) );
|
|
|
|
|
break;
|
2004-04-10 00:47:52 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
case PrefsManager::BGMODE_ANIMATIONS:
|
2004-04-10 00:47:52 +00:00
|
|
|
GetDirListing( BG_ANIMS_DIR+"*", arrayPaths, true, true );
|
|
|
|
|
break;
|
|
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
case PrefsManager::BGMODE_MOVIEVIS:
|
2004-01-23 02:23:11 +00:00
|
|
|
GetDirListing( VISUALIZATIONS_DIR + "*.avi", arrayPaths, false, true );
|
|
|
|
|
GetDirListing( VISUALIZATIONS_DIR + "*.mpg", arrayPaths, false, true );
|
|
|
|
|
GetDirListing( VISUALIZATIONS_DIR + "*.mpeg", arrayPaths, false, true );
|
2003-03-16 00:05:23 +00:00
|
|
|
break;
|
2004-01-23 02:23:11 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
case PrefsManager::BGMODE_RANDOMMOVIES:
|
2004-01-23 02:23:11 +00:00
|
|
|
GetDirListing( RANDOMMOVIES_DIR + "*.avi", arrayPaths, false, true );
|
|
|
|
|
GetDirListing( RANDOMMOVIES_DIR + "*.mpg", arrayPaths, false, true );
|
|
|
|
|
GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", arrayPaths, false, true );
|
2003-03-16 00:05:23 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2004-01-23 02:23:11 +00:00
|
|
|
|
2004-04-10 00:47:52 +00:00
|
|
|
// strip out "cvs"
|
|
|
|
|
for( int j=arrayPaths.size()-1; j>=0; j-- )
|
|
|
|
|
if( !Basename(arrayPaths[j]).CompareNoCase("cvs") )
|
|
|
|
|
arrayPaths.erase( arrayPaths.begin()+j, arrayPaths.begin()+j+1 );
|
|
|
|
|
|
2004-01-23 02:23:11 +00:00
|
|
|
if( arrayPaths.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
random_shuffle( arrayPaths.begin(), arrayPaths.end() );
|
|
|
|
|
|
|
|
|
|
/* Find the first file in arrayPaths we havn't already loaded. */
|
|
|
|
|
CString file;
|
|
|
|
|
{
|
|
|
|
|
set<CString> loaded;
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i = 0; i < m_RandomBGAnimations.size(); ++i )
|
|
|
|
|
loaded.insert( m_RandomBGAnimations[i] );
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
while( i < arrayPaths.size() && loaded.find( arrayPaths[i] ) != loaded.end() )
|
|
|
|
|
++i;
|
|
|
|
|
if( i == arrayPaths.size() )
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
file = arrayPaths[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BGAnimation *ret = new BGAnimation;
|
|
|
|
|
switch( PREFSMAN->m_BackgroundMode )
|
|
|
|
|
{
|
|
|
|
|
case PrefsManager::BGMODE_ANIMATIONS: ret->LoadFromAniDir( file ); break;
|
|
|
|
|
case PrefsManager::BGMODE_MOVIEVIS: ret->LoadFromVisualization( file ); break;
|
|
|
|
|
case PrefsManager::BGMODE_RANDOMMOVIES: ret->LoadFromMovie( file ); break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_BGAnimations[file] = ret;
|
|
|
|
|
m_RandomBGAnimations.push_back( file );
|
|
|
|
|
return file;
|
2003-03-16 00:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-23 03:53:23 +00:00
|
|
|
void Background::LoadFromRandom( float fFirstBeat, float fLastBeat, const TimingData &timing )
|
|
|
|
|
{
|
|
|
|
|
// change BG every 4 bars
|
|
|
|
|
for( float f=fFirstBeat; f<fLastBeat; f+=BEATS_PER_MEASURE*4 )
|
|
|
|
|
{
|
|
|
|
|
// Don't fade. It causes frame rate dip, especially on
|
|
|
|
|
// slower machines.
|
|
|
|
|
bool bFade = false;
|
|
|
|
|
//bool bFade = PREFSMAN->m_BackgroundMode==PrefsManager::BGMODE_RANDOMMOVIES ||
|
|
|
|
|
// PREFSMAN->m_BackgroundMode==PrefsManager::BGMODE_MOVIEVIS;
|
|
|
|
|
|
|
|
|
|
CString sBGName = CreateRandomBGA();
|
|
|
|
|
if( sBGName != "" )
|
|
|
|
|
m_aBGChanges.push_back( BackgroundChange(f,sBGName,1.f,bFade) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// change BG every BPM change that is at the beginning of a measure
|
|
|
|
|
for( unsigned i=0; i<timing.m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const BPMSegment& bpmseg = timing.m_BPMSegments[i];
|
|
|
|
|
|
|
|
|
|
if( fmodf(bpmseg.m_fStartBeat, (float)BEATS_PER_MEASURE) != 0 )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
if( bpmseg.m_fStartBeat < fFirstBeat || bpmseg.m_fStartBeat > fLastBeat )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
CString sBGName = CreateRandomBGA();
|
|
|
|
|
if( sBGName != "" )
|
|
|
|
|
m_aBGChanges.push_back( BackgroundChange(bpmseg.m_fStartBeat,sBGName) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
void Background::LoadFromSong( const Song* pSong )
|
2002-01-20 09:13:43 +00:00
|
|
|
{
|
2002-08-21 04:11:21 +00:00
|
|
|
Unload();
|
2002-07-11 19:02:26 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
m_pSong = pSong;
|
|
|
|
|
|
2003-07-21 18:44:04 +00:00
|
|
|
if( PREFSMAN->m_fBGBrightness == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
2004-02-05 21:59:26 +00:00
|
|
|
/* Song backgrounds (even just background stills) can get very big; never keep them
|
|
|
|
|
* in memory. */
|
2004-03-26 10:15:18 +00:00
|
|
|
RageTextureID::TexPolicy OldPolicy = TEXTUREMAN->GetDefaultTexturePolicy();
|
|
|
|
|
TEXTUREMAN->SetDefaultTexturePolicy( RageTextureID::TEX_VOLATILE );
|
2004-02-05 21:59:26 +00:00
|
|
|
|
2003-07-09 20:28:07 +00:00
|
|
|
TEXTUREMAN->DisableOddDimensionWarning();
|
|
|
|
|
|
2002-12-17 06:25:03 +00:00
|
|
|
const float fXZoom = RECT_BACKGROUND.GetWidth() / (float)SCREEN_WIDTH;
|
|
|
|
|
const float fYZoom = RECT_BACKGROUND.GetHeight() / (float)SCREEN_HEIGHT;
|
2002-08-28 22:42:40 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathToG("Common fallback background");
|
2002-08-25 05:07:47 +00:00
|
|
|
|
2004-02-13 08:13:21 +00:00
|
|
|
// Load the static background that will show before notes start and after notes end
|
2002-10-25 07:35:07 +00:00
|
|
|
{
|
|
|
|
|
BGAnimation *pTempBGA = new BGAnimation;
|
2003-03-10 02:46:01 +00:00
|
|
|
pTempBGA->LoadFromStaticGraphic( sSongBGPath );
|
2003-03-16 00:05:23 +00:00
|
|
|
m_BGAnimations[STATIC_BACKGROUND] = pTempBGA;
|
2002-10-25 07:35:07 +00:00
|
|
|
}
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
|
|
|
|
|
// start off showing the static song background
|
|
|
|
|
m_aBGChanges.push_back( BackgroundChange(-10000,STATIC_BACKGROUND) );
|
|
|
|
|
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
if( pSong->HasBGChanges() )
|
|
|
|
|
{
|
|
|
|
|
// Load all song-specified backgrounds
|
2002-10-31 02:46:42 +00:00
|
|
|
for( unsigned i=0; i<pSong->m_BackgroundChanges.size(); i++ )
|
2002-07-11 19:02:26 +00:00
|
|
|
{
|
2003-04-14 04:10:01 +00:00
|
|
|
BackgroundChange change = pSong->m_BackgroundChanges[i];
|
2004-01-23 02:23:11 +00:00
|
|
|
CString &sBGName = change.m_sBGName;
|
2003-03-16 00:05:23 +00:00
|
|
|
|
|
|
|
|
bool bIsAlreadyLoaded = m_BGAnimations.find(sBGName) != m_BGAnimations.end();
|
2002-10-24 01:51:01 +00:00
|
|
|
|
2004-02-02 22:32:05 +00:00
|
|
|
if( sBGName.CompareNoCase("-random-") && !bIsAlreadyLoaded )
|
2002-10-25 07:35:07 +00:00
|
|
|
{
|
2004-01-23 06:51:15 +00:00
|
|
|
BGAnimation *pTempBGA = CreateSongBGA( sBGName );
|
2003-03-16 00:05:23 +00:00
|
|
|
if( pTempBGA )
|
|
|
|
|
m_BGAnimations[sBGName] = pTempBGA;
|
|
|
|
|
else // the background was not found. Use a random one instead
|
2004-01-23 02:23:11 +00:00
|
|
|
{
|
|
|
|
|
sBGName = CreateRandomBGA();
|
|
|
|
|
if( sBGName == "" )
|
2003-03-16 07:20:37 +00:00
|
|
|
sBGName = STATIC_BACKGROUND;
|
2004-01-23 02:23:11 +00:00
|
|
|
}
|
2002-10-25 07:35:07 +00:00
|
|
|
}
|
2003-03-16 00:05:23 +00:00
|
|
|
|
2003-04-14 04:10:01 +00:00
|
|
|
m_aBGChanges.push_back( change );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
else // pSong doesn't have an animation plan
|
|
|
|
|
{
|
2004-01-23 03:53:23 +00:00
|
|
|
LoadFromRandom( pSong->m_fFirstBeat, pSong->m_fLastBeat, pSong->m_Timing );
|
2002-09-07 05:53:24 +00:00
|
|
|
|
2004-08-12 06:34:17 +00:00
|
|
|
// end showing the static song background
|
|
|
|
|
m_aBGChanges.push_back( BackgroundChange(pSong->m_fLastBeat,STATIC_BACKGROUND) );
|
|
|
|
|
}
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2002-09-07 05:53:24 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
// sort segments
|
|
|
|
|
SortBackgroundChangesArray( m_aBGChanges );
|
|
|
|
|
|
2004-01-23 04:14:06 +00:00
|
|
|
// Look for the filename "Random", and replace the segment with LoadFromRandom.
|
|
|
|
|
unsigned i = 0;
|
|
|
|
|
for( i=0; i<m_aBGChanges.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
BackgroundChange &change = m_aBGChanges[i];
|
2004-01-23 04:22:34 +00:00
|
|
|
if( change.m_sBGName.CompareNoCase("-random-") )
|
2004-01-23 04:14:06 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const float fStartBeat = change.m_fStartBeat;
|
|
|
|
|
const float fLastBeat = (i+1 < m_aBGChanges.size())? m_aBGChanges[i+1].m_fStartBeat: 99999;
|
|
|
|
|
|
|
|
|
|
m_aBGChanges.erase( m_aBGChanges.begin()+i );
|
|
|
|
|
--i;
|
|
|
|
|
|
|
|
|
|
LoadFromRandom( fStartBeat, fLastBeat, pSong->m_Timing );
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-24 19:05:54 +00:00
|
|
|
// At this point, we shouldn't have any BGChanges to "". "" is an invalid name.
|
2004-01-23 04:14:06 +00:00
|
|
|
for( i=0; i<m_aBGChanges.size(); i++ )
|
2004-01-24 19:05:54 +00:00
|
|
|
ASSERT( !m_aBGChanges[i].m_sBGName.empty() );
|
|
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
|
2004-01-24 19:05:54 +00:00
|
|
|
// Re-sort.
|
|
|
|
|
SortBackgroundChangesArray( m_aBGChanges );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2003-03-16 00:05:23 +00:00
|
|
|
for( map<CString,BGAnimation*>::iterator iter = m_BGAnimations.begin();
|
|
|
|
|
iter != m_BGAnimations.end();
|
|
|
|
|
iter++ )
|
2002-08-28 22:42:40 +00:00
|
|
|
{
|
2003-03-16 00:05:23 +00:00
|
|
|
iter->second->SetXY( (float)LEFT_EDGE, (float)TOP_EDGE );
|
|
|
|
|
iter->second->SetZoomX( fXZoom );
|
|
|
|
|
iter->second->SetZoomY( fYZoom );
|
2002-08-28 22:42:40 +00:00
|
|
|
}
|
2002-09-09 05:22:02 +00:00
|
|
|
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DangerAll.SetXY( (float)LEFT_EDGE, (float)TOP_EDGE );
|
|
|
|
|
m_DangerAll.SetZoomX( fXZoom );
|
|
|
|
|
m_DangerAll.SetZoomY( fYZoom );
|
|
|
|
|
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-12-07 20:29:42 +00:00
|
|
|
{
|
|
|
|
|
m_DangerPlayer[p].SetXY( (float)LEFT_EDGE, (float)TOP_EDGE );
|
|
|
|
|
m_DangerPlayer[p].SetZoomX( fXZoom );
|
|
|
|
|
m_DangerPlayer[p].SetZoomY( fYZoom );
|
|
|
|
|
|
|
|
|
|
m_DeadPlayer[p].SetXY( (float)LEFT_EDGE, (float)TOP_EDGE );
|
|
|
|
|
m_DeadPlayer[p].SetZoomX( fXZoom );
|
|
|
|
|
m_DeadPlayer[p].SetZoomY( fYZoom );
|
|
|
|
|
}
|
2003-07-09 20:28:07 +00:00
|
|
|
|
|
|
|
|
TEXTUREMAN->EnableOddDimensionWarning();
|
2003-08-23 19:58:46 +00:00
|
|
|
|
2003-08-29 09:41:11 +00:00
|
|
|
if( m_pDancingCharacters )
|
|
|
|
|
m_pDancingCharacters->LoadNextSong();
|
2004-02-05 21:59:26 +00:00
|
|
|
|
|
|
|
|
TEXTUREMAN->SetDefaultTexturePolicy( OldPolicy );
|
2002-01-20 09:13:43 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-24 19:05:54 +00:00
|
|
|
int Background::FindBGSegmentForBeat( float fBeat ) const
|
2004-01-23 06:51:15 +00:00
|
|
|
{
|
2004-02-13 08:13:21 +00:00
|
|
|
if( m_aBGChanges.empty() )
|
|
|
|
|
return -1;
|
|
|
|
|
if( fBeat < m_aBGChanges[0].m_fStartBeat )
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
// assumption: m_aBGChanges are sorted by m_fStartBeat
|
2004-09-21 07:53:39 +00:00
|
|
|
int i;
|
|
|
|
|
for( i=m_aBGChanges.size()-1; i>=0; i-- )
|
2004-02-13 08:13:21 +00:00
|
|
|
{
|
|
|
|
|
if( fBeat >= m_aBGChanges[i].m_fStartBeat )
|
2004-01-23 06:51:15 +00:00
|
|
|
return i;
|
2004-02-13 08:13:21 +00:00
|
|
|
}
|
2004-01-23 06:51:15 +00:00
|
|
|
|
2004-02-13 08:13:21 +00:00
|
|
|
return i;
|
2004-01-23 06:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the BG segment has changed, move focus to it. Send Update() calls. */
|
|
|
|
|
void Background::UpdateCurBGChange( float fCurrentTime )
|
2002-01-20 09:13:43 +00:00
|
|
|
{
|
2004-01-29 05:20:27 +00:00
|
|
|
ASSERT( fCurrentTime != GameState::MUSIC_SECONDS_INVALID );
|
2002-01-20 09:13:43 +00:00
|
|
|
|
2003-09-23 19:26:36 +00:00
|
|
|
if( m_aBGChanges.size() == 0 )
|
|
|
|
|
return;
|
2003-02-07 23:49:38 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
float fBeat, fBPS;
|
|
|
|
|
bool bFreeze;
|
|
|
|
|
m_pSong->m_Timing.GetBeatAndBPSFromElapsedTime( fCurrentTime, fBeat, fBPS, bFreeze );
|
2003-04-13 00:44:50 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
/* Calls to Update() should *not* be scaled by music rate; fCurrentTime is. Undo it. */
|
|
|
|
|
const float fRate = GAMESTATE->m_SongOptions.m_fMusicRate;
|
2002-06-24 22:20:51 +00:00
|
|
|
|
2004-01-24 19:05:54 +00:00
|
|
|
// Find the BGSegment we're in
|
|
|
|
|
const int i = FindBGSegmentForBeat( fBeat );
|
|
|
|
|
|
|
|
|
|
if( i != -1 && i != m_iCurBGChangeIndex ) // we're changing backgrounds
|
2004-01-23 06:51:15 +00:00
|
|
|
{
|
2004-03-17 05:06:49 +00:00
|
|
|
LOG->Trace( "old bga %d -> new bga %d, %f, %f", m_iCurBGChangeIndex, i, m_aBGChanges[i].m_fStartBeat, fBeat );
|
2003-04-14 04:10:01 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
m_iCurBGChangeIndex = i;
|
2003-04-14 04:10:01 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
const BackgroundChange& change = m_aBGChanges[i];
|
2003-04-14 04:10:01 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
BGAnimation* pOld = m_pCurrentBGA;
|
2002-10-10 04:11:30 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
if( change.m_bFadeLast )
|
|
|
|
|
m_pFadingBGA = m_pCurrentBGA;
|
|
|
|
|
else
|
|
|
|
|
m_pFadingBGA = NULL;
|
|
|
|
|
|
|
|
|
|
m_pCurrentBGA = m_BGAnimations[ change.m_sBGName ];
|
|
|
|
|
|
|
|
|
|
if( pOld )
|
2004-08-22 02:16:31 +00:00
|
|
|
pOld->LoseFocus();
|
2004-01-23 06:51:15 +00:00
|
|
|
if( m_pCurrentBGA )
|
2004-08-22 02:16:31 +00:00
|
|
|
m_pCurrentBGA->GainFocus( change.m_fRate, change.m_bRewindMovie, change.m_bLoop );
|
2004-01-23 06:51:15 +00:00
|
|
|
|
|
|
|
|
m_fSecsLeftInFade = m_pFadingBGA!=NULL ? FADE_SECONDS : 0;
|
2003-04-14 04:10:01 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
/* How much time of this BGA have we skipped? (This happens with SetSeconds.) */
|
|
|
|
|
const float fStartSecond = m_pSong->m_Timing.GetElapsedTimeFromBeat( change.m_fStartBeat );
|
2003-04-14 04:10:01 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
/* This is affected by the music rate. */
|
|
|
|
|
float fDeltaTime = fCurrentTime - fStartSecond;
|
|
|
|
|
fDeltaTime /= fRate;
|
|
|
|
|
if( m_pCurrentBGA )
|
2004-04-25 04:42:36 +00:00
|
|
|
m_pCurrentBGA->Update( max( fDeltaTime, 0 ) );
|
2004-01-23 06:51:15 +00:00
|
|
|
}
|
2004-01-24 19:05:54 +00:00
|
|
|
else // we're not changing backgrounds
|
2004-01-23 06:51:15 +00:00
|
|
|
{
|
|
|
|
|
/* This is affected by the music rate. */
|
|
|
|
|
float fDeltaTime = fCurrentTime - m_fLastMusicSeconds;
|
|
|
|
|
fDeltaTime /= fRate;
|
|
|
|
|
if( m_pCurrentBGA )
|
2004-04-25 04:42:36 +00:00
|
|
|
m_pCurrentBGA->Update( max( fDeltaTime, 0 ) );
|
2004-01-23 06:51:15 +00:00
|
|
|
}
|
2002-07-31 22:37:58 +00:00
|
|
|
|
2004-01-23 06:51:15 +00:00
|
|
|
float fDeltaTime = fCurrentTime - m_fLastMusicSeconds;
|
|
|
|
|
fDeltaTime /= fRate;
|
|
|
|
|
if( m_pFadingBGA )
|
2004-04-25 04:42:36 +00:00
|
|
|
m_pFadingBGA->Update( max( fCurrentTime - m_fLastMusicSeconds, 0 ) );
|
2004-01-23 06:51:15 +00:00
|
|
|
m_fLastMusicSeconds = fCurrentTime;
|
2003-09-23 19:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Background::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
|
|
|
|
|
2003-12-07 20:29:42 +00:00
|
|
|
if( IsDangerAllVisible() )
|
2003-09-23 19:26:36 +00:00
|
|
|
{
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DangerAll.Update( fDeltaTime );
|
2002-08-18 16:19:26 +00:00
|
|
|
}
|
2003-09-23 19:26:36 +00:00
|
|
|
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-12-07 20:29:42 +00:00
|
|
|
{
|
|
|
|
|
if( IsDangerPlayerVisible((PlayerNumber)p) )
|
|
|
|
|
m_DangerPlayer[p].Update( fDeltaTime );
|
|
|
|
|
|
|
|
|
|
if( IsDeadPlayerVisible((PlayerNumber)p) )
|
|
|
|
|
m_DeadPlayer[p].Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Always update the current background, even when m_DangerAll is being displayed.
|
2003-09-23 19:26:36 +00:00
|
|
|
* Otherwise, we'll stop updating movies during danger (which may stop them from
|
|
|
|
|
* playing), and we won't start clips at the right time, which will throw backgrounds
|
|
|
|
|
* off sync. */
|
2004-01-23 06:51:15 +00:00
|
|
|
UpdateCurBGChange( GAMESTATE->m_fMusicSeconds );
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2003-09-23 19:26:36 +00:00
|
|
|
if( m_pFadingBGA )
|
|
|
|
|
{
|
|
|
|
|
m_pFadingBGA->Update( fDeltaTime );
|
|
|
|
|
m_fSecsLeftInFade -= fDeltaTime;
|
|
|
|
|
float fPercentOpaque = m_fSecsLeftInFade / FADE_SECONDS;
|
|
|
|
|
m_pFadingBGA->SetDiffuse( RageColor(1,1,1,fPercentOpaque) );
|
|
|
|
|
if( fPercentOpaque <= 0 )
|
2004-07-12 21:21:56 +00:00
|
|
|
{
|
|
|
|
|
/* Reset its diffuse color, in case we reuse it. */
|
|
|
|
|
m_pFadingBGA->SetDiffuse( RageColor(1,1,1,1) );
|
2003-09-23 19:26:36 +00:00
|
|
|
m_pFadingBGA = NULL;
|
2004-07-12 21:21:56 +00:00
|
|
|
}
|
2003-09-23 19:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-27 08:06:22 +00:00
|
|
|
if( m_pDancingCharacters )
|
|
|
|
|
m_pDancingCharacters->Update( fDeltaTime );
|
2002-01-20 09:13:43 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
void Background::DrawPrimitives()
|
2002-01-20 09:13:43 +00:00
|
|
|
{
|
2003-07-21 18:44:04 +00:00
|
|
|
if( PREFSMAN->m_fBGBrightness == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-12-07 20:29:42 +00:00
|
|
|
if( IsDangerAllVisible() )
|
2002-01-20 09:13:43 +00:00
|
|
|
{
|
2003-08-26 07:44:22 +00:00
|
|
|
// Since this only shows when DANGER is visible, it will flash red on it's own accord :)
|
2003-08-27 03:14:04 +00:00
|
|
|
if( m_pDancingCharacters )
|
|
|
|
|
m_pDancingCharacters->m_bDrawDangerLight = true;
|
2003-12-07 20:29:42 +00:00
|
|
|
m_DangerAll.Draw();
|
2002-01-20 09:13:43 +00:00
|
|
|
}
|
2003-12-07 21:40:00 +00:00
|
|
|
|
|
|
|
|
if( !IsDangerAllVisible() || !DANGER_ALL_IS_OPAQUE )
|
2003-04-13 00:44:50 +00:00
|
|
|
{
|
2003-08-27 03:14:04 +00:00
|
|
|
if( m_pDancingCharacters )
|
|
|
|
|
m_pDancingCharacters->m_bDrawDangerLight = false;
|
2003-04-13 00:44:50 +00:00
|
|
|
if( m_pCurrentBGA )
|
|
|
|
|
m_pCurrentBGA->Draw();
|
2002-10-10 04:11:30 +00:00
|
|
|
if( m_pFadingBGA )
|
|
|
|
|
m_pFadingBGA->Draw();
|
2003-12-07 20:29:42 +00:00
|
|
|
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-12-07 20:29:42 +00:00
|
|
|
{
|
|
|
|
|
if( IsDangerPlayerVisible((PlayerNumber)p) )
|
|
|
|
|
m_DangerPlayer[p].Draw();
|
|
|
|
|
if( IsDeadPlayerVisible((PlayerNumber)p) )
|
|
|
|
|
m_DeadPlayer[p].Draw();
|
|
|
|
|
}
|
2002-01-20 09:13:43 +00:00
|
|
|
}
|
2002-08-18 16:19:26 +00:00
|
|
|
|
2003-06-27 08:06:22 +00:00
|
|
|
if( m_pDancingCharacters )
|
|
|
|
|
m_pDancingCharacters->Draw();
|
2003-05-05 04:43:11 +00:00
|
|
|
|
2004-04-02 00:13:47 +00:00
|
|
|
ActorFrame::DrawPrimitives();
|
2002-01-20 09:13:43 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-07 20:29:42 +00:00
|
|
|
bool Background::IsDangerAllVisible()
|
|
|
|
|
{
|
|
|
|
|
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_OFF )
|
|
|
|
|
return false;
|
|
|
|
|
if( !PREFSMAN->m_bShowDanger )
|
|
|
|
|
return false;
|
|
|
|
|
|
2003-12-31 21:03:14 +00:00
|
|
|
/* Don't show it if everyone is already failing: it's already too late and it's
|
|
|
|
|
* annoying for it to show for the entire duration of a song. */
|
|
|
|
|
if( g_CurStageStats.AllFailedEarlier() )
|
2003-12-07 20:29:42 +00:00
|
|
|
return false;
|
2003-12-31 21:03:14 +00:00
|
|
|
|
|
|
|
|
if( !GAMESTATE->AllAreInDangerOrWorse() )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if( BLINK_DANGER_ALL )
|
|
|
|
|
return (RageTimer::GetTimeSinceStart() - (int)RageTimer::GetTimeSinceStart()) < 0.5f;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
2003-12-07 20:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Background::IsDangerPlayerVisible( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_OFF )
|
|
|
|
|
return false;
|
|
|
|
|
if( !PREFSMAN->m_bShowDanger )
|
|
|
|
|
return false;
|
|
|
|
|
return GAMESTATE->m_HealthState[pn] == GameState::DANGER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Background::IsDeadPlayerVisible( PlayerNumber pn )
|
2002-06-24 22:20:51 +00:00
|
|
|
{
|
2003-12-07 20:29:42 +00:00
|
|
|
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_OFF )
|
|
|
|
|
return false;
|
|
|
|
|
return GAMESTATE->m_HealthState[pn] == GameState::DEAD;
|
2002-07-11 19:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-02 00:13:47 +00:00
|
|
|
BrightnessOverlay::BrightnessOverlay()
|
|
|
|
|
{
|
|
|
|
|
float fQuadWidth = (RIGHT_EDGE-LEFT_EDGE)/2;
|
|
|
|
|
fQuadWidth -= g_fBackgroundCenterWidth/2;
|
|
|
|
|
|
|
|
|
|
m_quadBGBrightness[0].StretchTo( RectF(LEFT_EDGE,TOP_EDGE,LEFT_EDGE+fQuadWidth,BOTTOM_EDGE) );
|
|
|
|
|
m_quadBGBrightnessFade.StretchTo( RectF(LEFT_EDGE+fQuadWidth,TOP_EDGE,RIGHT_EDGE-fQuadWidth,BOTTOM_EDGE) );
|
|
|
|
|
m_quadBGBrightness[1].StretchTo( RectF(RIGHT_EDGE-fQuadWidth,TOP_EDGE,RIGHT_EDGE,BOTTOM_EDGE) );
|
|
|
|
|
|
|
|
|
|
this->AddChild( &m_quadBGBrightness[0] );
|
|
|
|
|
this->AddChild( &m_quadBGBrightness[1] );
|
|
|
|
|
this->AddChild( &m_quadBGBrightnessFade );
|
|
|
|
|
|
2004-04-19 20:28:10 +00:00
|
|
|
SetActualBrightness();
|
2004-04-02 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BrightnessOverlay::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
2004-04-08 00:18:13 +00:00
|
|
|
/* If we're actually playing, then we're past fades, etc; update the background
|
|
|
|
|
* brightness to follow Cover. */
|
|
|
|
|
if( GAMESTATE->m_bPastHereWeGo )
|
2004-04-19 20:28:10 +00:00
|
|
|
SetActualBrightness();
|
2004-04-02 00:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-19 20:28:10 +00:00
|
|
|
void BrightnessOverlay::SetActualBrightness()
|
2002-07-11 19:02:26 +00:00
|
|
|
{
|
2004-04-02 00:13:47 +00:00
|
|
|
float fLeftBrightness = 1-GAMESTATE->m_PlayerOptions[PLAYER_1].m_fCover;
|
|
|
|
|
float fRightBrightness = 1-GAMESTATE->m_PlayerOptions[PLAYER_2].m_fCover;
|
|
|
|
|
|
|
|
|
|
fLeftBrightness *= PREFSMAN->m_fBGBrightness;
|
|
|
|
|
fRightBrightness *= PREFSMAN->m_fBGBrightness;
|
|
|
|
|
|
|
|
|
|
if( !GAMESTATE->IsHumanPlayer(PLAYER_1) )
|
|
|
|
|
fLeftBrightness = fRightBrightness;
|
|
|
|
|
if( !GAMESTATE->IsHumanPlayer(PLAYER_2) )
|
|
|
|
|
fRightBrightness = fLeftBrightness;
|
|
|
|
|
|
|
|
|
|
RageColor LeftColor( 0,0,0,1-fLeftBrightness );
|
|
|
|
|
RageColor RightColor( 0,0,0,1-fRightBrightness );
|
|
|
|
|
|
|
|
|
|
m_quadBGBrightness[PLAYER_1].SetDiffuse( LeftColor );
|
|
|
|
|
m_quadBGBrightness[PLAYER_2].SetDiffuse( RightColor );
|
|
|
|
|
m_quadBGBrightnessFade.SetDiffuseLeftEdge( LeftColor );
|
|
|
|
|
m_quadBGBrightnessFade.SetDiffuseRightEdge( RightColor );
|
2002-07-11 19:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-08 00:18:13 +00:00
|
|
|
void BrightnessOverlay::Set( float fBrightness )
|
2002-07-11 19:02:26 +00:00
|
|
|
{
|
2004-04-02 00:13:47 +00:00
|
|
|
FOREACH_PlayerNumber(pn)
|
2004-04-08 00:18:13 +00:00
|
|
|
m_quadBGBrightness[pn].SetDiffuse( RageColor(0,0,0,1-fBrightness) );
|
|
|
|
|
m_quadBGBrightnessFade.SetDiffuse( RageColor(0,0,0,1-fBrightness) );
|
2004-04-02 00:13:47 +00:00
|
|
|
}
|
2002-07-11 19:02:26 +00:00
|
|
|
|
2004-04-08 00:18:13 +00:00
|
|
|
void BrightnessOverlay::FadeToActualBrightness()
|
2004-04-02 00:13:47 +00:00
|
|
|
{
|
2004-04-19 20:28:10 +00:00
|
|
|
this->RunCommandOnChildren( BRIGHTNESS_FADE_COMMAND );
|
|
|
|
|
SetActualBrightness();
|
2002-06-24 22:20:51 +00:00
|
|
|
}
|
2004-06-08 00:08:04 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford, Ben Nordstrom
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|