From f5402584f994d29d0159b5624fe2066f709483cb Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 10 Mar 2003 02:46:01 +0000 Subject: [PATCH] make UseSongBG work for BGAnimations not inside of Background (e.g. on ScreenStage) --- stepmania/src/BGAnimation.cpp | 13 +++++++++---- stepmania/src/BGAnimation.h | 4 ++-- stepmania/src/BGAnimationLayer.cpp | 12 ++++++++++-- stepmania/src/BGAnimationLayer.h | 4 ++-- stepmania/src/Background.cpp | 20 ++++++++++---------- stepmania/src/Background.h | 2 +- stepmania/src/ScreenEvaluation.cpp | 2 +- 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index e1420809bb..b9cc274732 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -17,6 +17,8 @@ #include "IniFile.h" #include "BGAnimationLayer.h" #include "RageUtil.h" +#include "Song.h" +#include "ThemeManager.h" BGAnimation::BGAnimation() @@ -45,7 +47,7 @@ void BGAnimation::LoadFromStaticGraphic( CString sPath ) m_Layers.push_back( pLayer ); } -void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath ) +void BGAnimation::LoadFromAniDir( CString sAniDir ) { Unload(); @@ -71,7 +73,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath ) if( pKey == NULL ) break; BGAnimationLayer* pLayer = new BGAnimationLayer; - pLayer->LoadFromIni( sAniDir, sLayer, sSongBGPath ); + pLayer->LoadFromIni( sAniDir, sLayer ); m_Layers.push_back( pLayer ); } } @@ -101,7 +103,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath ) if( sFName.Left(1) == "_" ) continue; // don't directly load files starting with an underscore BGAnimationLayer* pLayer = new BGAnimationLayer; - pLayer->LoadFromAniLayerFile( asImagePaths[i], sSongBGPath ); + pLayer->LoadFromAniLayerFile( asImagePaths[i] ); m_Layers.push_back( pLayer ); } } @@ -116,11 +118,14 @@ void BGAnimation::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ) m_Layers.push_back( pLayer ); } -void BGAnimation::LoadFromVisualization( CString sVisPath, CString sSongBGPath ) +void BGAnimation::LoadFromVisualization( CString sVisPath ) { Unload(); BGAnimationLayer* pLayer; + Song* pSong = GAMESTATE->m_pCurSong; + CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","Common fallback background"); + pLayer = new BGAnimationLayer; pLayer->LoadFromStaticGraphic( sSongBGPath ); m_Layers.push_back( pLayer ); diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index 7ef95af3f5..8fadbfb0a3 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -28,9 +28,9 @@ public: void Unload(); void LoadFromStaticGraphic( CString sPath ); - void LoadFromAniDir( CString sAniDir, CString sSongBGPath="" ); + void LoadFromAniDir( CString sAniDir ); void LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ); - void LoadFromVisualization( CString sMoviePath, CString sSongBGPath ); + void LoadFromVisualization( CString sMoviePath ); virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index 1bcaffd1ab..045ca40d73 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -20,6 +20,8 @@ #include #include "RageTimer.h" #include "RageLog.h" +#include "Song.h" +#include "ThemeManager.h" inline float GetOffScreenLeft( Actor* pActor ) { return SCREEN_LEFT - pActor->GetZoomedWidth()/2; } @@ -145,8 +147,11 @@ void BGAnimationLayer::LoadFromVisualization( CString sMoviePath ) } -void BGAnimationLayer::LoadFromAniLayerFile( CString sPath, CString sSongBGPath ) +void BGAnimationLayer::LoadFromAniLayerFile( CString sPath ) { + Song* pSong = GAMESTATE->m_pCurSong; + CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","Common fallback background"); + Init(); CString lcPath = sPath; lcPath.MakeLower(); @@ -438,8 +443,11 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath, CString sSongBGPath } -void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer, CString sSongBGPath ) +void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer ) { + Song* pSong = GAMESTATE->m_pCurSong; + CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","Common fallback background"); + Init(); if( sAniDir.Right(1) != "/" ) sAniDir += "/"; diff --git a/stepmania/src/BGAnimationLayer.h b/stepmania/src/BGAnimationLayer.h index 53f339878c..453a9691d8 100644 --- a/stepmania/src/BGAnimationLayer.h +++ b/stepmania/src/BGAnimationLayer.h @@ -27,10 +27,10 @@ public: void Init(); void LoadFromStaticGraphic( CString sPath ); - void LoadFromAniLayerFile( CString sPath, CString sSongBGPath ); + void LoadFromAniLayerFile( CString sPath ); void LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ); void LoadFromVisualization( CString sMoviePath ); - void LoadFromIni( CString sDir, CString sLayer, CString sSongBGPath ); + void LoadFromIni( CString sDir, CString sLayer ); virtual void Update( float fDeltaTime ); virtual void Draw(); diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 823342a907..43a1f9eec0 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -93,7 +93,7 @@ void Background::LoadFromAniDir( CString sAniDir ) m_BGAnimations.push_back( pTempBGA ); } -BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &aniseg, const CString &bgpath) const +BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &aniseg) const { BGAnimation *pTempBGA; @@ -107,7 +107,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise if( !asFiles.empty() ) { pTempBGA = new BGAnimation; - pTempBGA->LoadFromAniDir( asFiles[0], bgpath ); + pTempBGA->LoadFromAniDir( asFiles[0] ); return pTempBGA; } // Look for BG movies in the song dir @@ -132,7 +132,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise if( !asFiles.empty() ) { pTempBGA = new BGAnimation; - pTempBGA->LoadFromAniDir( asFiles[0], bgpath ); + pTempBGA->LoadFromAniDir( asFiles[0] ); return pTempBGA; } @@ -141,7 +141,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise if( !asFiles.empty() ) { pTempBGA = new BGAnimation; - pTempBGA->LoadFromVisualization( asFiles[0], bgpath ); + pTempBGA->LoadFromVisualization( asFiles[0] ); return pTempBGA; } return NULL; @@ -154,7 +154,7 @@ void Background::LoadFromSong( Song* pSong ) const float fXZoom = RECT_BACKGROUND.GetWidth() / (float)SCREEN_WIDTH; const float fYZoom = RECT_BACKGROUND.GetHeight() / (float)SCREEN_HEIGHT; - const CString sSongBackgroundPath = pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","Background fallback"); + CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","Common fallback background"); // // Load the static background that will before notes start and after notes end @@ -162,7 +162,7 @@ void Background::LoadFromSong( Song* pSong ) { BGAnimation *pTempBGA = new BGAnimation; - pTempBGA->LoadFromStaticGraphic( sSongBackgroundPath ); + pTempBGA->LoadFromStaticGraphic( sSongBGPath ); m_BGAnimations.push_back( pTempBGA ); } @@ -178,7 +178,7 @@ void Background::LoadFromSong( Song* pSong ) const BackgroundChange& aniseg = pSong->m_BackgroundChanges[i]; bool bFade = i==0; - BGAnimation *pTempBGA = GetBGA(pSong, aniseg, sSongBackgroundPath); + BGAnimation *pTempBGA = GetBGA(pSong, aniseg); if(pTempBGA != NULL) { @@ -231,12 +231,12 @@ void Background::LoadFromSong( Song* pSong ) { unsigned index = rand() % arrayPossibleMovies.size(); pTempBGA = new BGAnimation; - pTempBGA->LoadFromVisualization( arrayPossibleMovies[index], sSongBackgroundPath ); + pTempBGA->LoadFromVisualization( arrayPossibleMovies[index] ); } else { pTempBGA = new BGAnimation; - pTempBGA->LoadFromStaticGraphic( sSongBackgroundPath ); + pTempBGA->LoadFromStaticGraphic( sSongBGPath ); } m_BGAnimations.push_back( pTempBGA ); } @@ -255,7 +255,7 @@ void Background::LoadFromSong( Song* pSong ) { unsigned index = rand() % arrayPossibleAnims.size(); BGAnimation *pTempBGA = new BGAnimation; - pTempBGA->LoadFromAniDir( arrayPossibleAnims[index], sSongBackgroundPath ); + pTempBGA->LoadFromAniDir( arrayPossibleAnims[index] ); m_BGAnimations.push_back( pTempBGA ); arrayPossibleAnims.erase( arrayPossibleAnims.begin()+index, arrayPossibleAnims.begin()+index+1 ); diff --git a/stepmania/src/Background.h b/stepmania/src/Background.h index eaf7a3ef42..c05bdd2c69 100644 --- a/stepmania/src/Background.h +++ b/stepmania/src/Background.h @@ -54,7 +54,7 @@ public: protected: bool DangerVisible(); - BGAnimation *GetBGA(const Song *pSong, const BackgroundChange &aniseg, const CString &bgpath) const; + BGAnimation *GetBGA(const Song *pSong, const BackgroundChange &aniseg) const; BGAnimation m_BGADanger; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index a3fe74b6be..d5ad47e091 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -166,7 +166,7 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary ) m_BannerWithFrame[0].SetXY( BANNER_X, BANNER_Y ); this->AddChild( &m_BannerWithFrame[0] ); - m_sprStage.Load( THEME->GetPathTo("Graphics","ScreenEvaluation "+GAMESTATE->GetStageText()) ); + m_sprStage.Load( THEME->GetPathTo("Graphics","ScreenEvaluation stage "+GAMESTATE->GetStageText()) ); m_sprStage.SetXY( STAGE_X, STAGE_Y ); this->AddChild( &m_sprStage );