Give BGAnimations loaded from AutoActor Actor semantics, not
BGAnimation semantics.
This commit is contained in:
@@ -119,7 +119,7 @@ Actor* MakeActor( RageTextureID ID )
|
||||
/* Do this last, to avoid the IsADirectory in most cases. */
|
||||
else if( IsADirectory(ID.filename) )
|
||||
{
|
||||
BGAnimation *pBGA = new BGAnimation;
|
||||
BGAnimation *pBGA = new BGAnimation( true );
|
||||
pBGA->LoadFromAniDir( ID.filename );
|
||||
return pBGA;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
const int MAX_LAYERS = 1000;
|
||||
|
||||
BGAnimation::BGAnimation()
|
||||
BGAnimation::BGAnimation( bool Generic )
|
||||
{
|
||||
/* See BGAnimationLayer::BGAnimationLayer for explanation. */
|
||||
m_bGeneric = Generic;
|
||||
m_fLengthSeconds = 10;
|
||||
}
|
||||
|
||||
@@ -45,12 +47,12 @@ void BGAnimation::LoadFromStaticGraphic( CString sPath )
|
||||
{
|
||||
Unload();
|
||||
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer( m_bGeneric );
|
||||
pLayer->LoadFromStaticGraphic( sPath );
|
||||
m_Layers.push_back( pLayer );
|
||||
}
|
||||
|
||||
void AddLayersFromAniDir( CString sAniDir, vector<BGAnimationLayer*> &layersAddTo )
|
||||
void AddLayersFromAniDir( CString sAniDir, vector<BGAnimationLayer*> &layersAddTo, bool Generic )
|
||||
{
|
||||
if( sAniDir.empty() )
|
||||
return;
|
||||
@@ -79,12 +81,12 @@ void AddLayersFromAniDir( CString sAniDir, vector<BGAnimationLayer*> &layersAddT
|
||||
// import a whole BGAnimation
|
||||
sImportDir = sAniDir + sImportDir;
|
||||
CollapsePath( sImportDir );
|
||||
AddLayersFromAniDir( sImportDir, layersAddTo );
|
||||
AddLayersFromAniDir( sImportDir, layersAddTo, Generic );
|
||||
}
|
||||
else
|
||||
{
|
||||
// import a single layer
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer( Generic );
|
||||
pLayer->LoadFromIni( sAniDir, sLayer );
|
||||
layersAddTo.push_back( pLayer );
|
||||
}
|
||||
@@ -109,7 +111,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir )
|
||||
if( DoesFileExist(sPathToIni) )
|
||||
{
|
||||
// This is a new style BGAnimation (using .ini)
|
||||
AddLayersFromAniDir( sAniDir, m_Layers ); // TODO: Check for circular load
|
||||
AddLayersFromAniDir( sAniDir, m_Layers, m_bGeneric ); // TODO: Check for circular load
|
||||
|
||||
IniFile ini(sPathToIni);
|
||||
ini.ReadFile();
|
||||
@@ -143,7 +145,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir )
|
||||
const CString sPath = asImagePaths[i];
|
||||
if( Basename(sPath).Left(1) == "_" )
|
||||
continue; // don't directly load files starting with an underscore
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer( m_bGeneric );
|
||||
pLayer->LoadFromAniLayerFile( asImagePaths[i] );
|
||||
m_Layers.push_back( pLayer );
|
||||
}
|
||||
@@ -154,7 +156,7 @@ void BGAnimation::LoadFromMovie( CString sMoviePath )
|
||||
{
|
||||
Unload();
|
||||
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer( m_bGeneric );
|
||||
pLayer->LoadFromMovie( sMoviePath );
|
||||
m_Layers.push_back( pLayer );
|
||||
}
|
||||
@@ -167,11 +169,11 @@ void BGAnimation::LoadFromVisualization( CString sVisPath )
|
||||
const Song* pSong = GAMESTATE->m_pCurSong;
|
||||
CString sSongBGPath = pSong && pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathToG("Common fallback background");
|
||||
|
||||
pLayer = new BGAnimationLayer;
|
||||
pLayer = new BGAnimationLayer( m_bGeneric );
|
||||
pLayer->LoadFromStaticGraphic( sSongBGPath );
|
||||
m_Layers.push_back( pLayer );
|
||||
|
||||
pLayer = new BGAnimationLayer;
|
||||
pLayer = new BGAnimationLayer( m_bGeneric );
|
||||
pLayer->LoadFromVisualization( sVisPath );
|
||||
m_Layers.push_back( pLayer );
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class BGAnimationLayer;
|
||||
class BGAnimation : public ActorFrame
|
||||
{
|
||||
public:
|
||||
BGAnimation();
|
||||
BGAnimation( bool Generic=false );
|
||||
virtual ~BGAnimation();
|
||||
|
||||
void Unload();
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
protected:
|
||||
vector<BGAnimationLayer*> m_Layers;
|
||||
float m_fLengthSeconds;
|
||||
bool m_bGeneric;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -43,8 +43,33 @@ const float SPIRAL_MIN_ZOOM = 0.3f;
|
||||
static const RectI FullScreenRectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM);
|
||||
|
||||
|
||||
BGAnimationLayer::BGAnimationLayer()
|
||||
BGAnimationLayer::BGAnimationLayer( bool Generic )
|
||||
{
|
||||
/* If Generic is false, this is a layer in a real BGA--one that was loaded
|
||||
* by simply constructing a BGAnimation. These normally have a position
|
||||
* of 0,0 (top-left of the screen). Loaded images are given a default position
|
||||
* of 320x240, centered in the screen. Additionally, the "On" command will
|
||||
* be run automatically. Example:
|
||||
*
|
||||
* BGAnimation bga;
|
||||
* bga.Load( path );
|
||||
* this->AddChind( &bga );
|
||||
*
|
||||
* If Generic is true, then we act like any other actor. We assume we don't
|
||||
* know anything about where we're positioned. Loaded images are given a
|
||||
* default position of 0x0. The "On" command is not run; we'll receive that
|
||||
* from the owner through COMMAND(). Example:
|
||||
*
|
||||
* AutoActor image;
|
||||
* image.Load( path );
|
||||
* ON_COMMAND( image );
|
||||
* this->AddChind( &image );
|
||||
*
|
||||
* TYPE_PARTICLES and TYPE_TILES are currently not supported in this mode.
|
||||
*
|
||||
*/
|
||||
m_bGeneric = Generic;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -151,6 +176,9 @@ void BGAnimationLayer::LoadFromVisualization( CString sMoviePath )
|
||||
|
||||
void BGAnimationLayer::LoadFromAniLayerFile( CString sPath )
|
||||
{
|
||||
/* Generic BGAs are new. Animation directories with no INI are old and obsolete.
|
||||
* Don't combine them. */
|
||||
ASSERT( !m_bGeneric );
|
||||
Init();
|
||||
CString lcPath = sPath;
|
||||
lcPath.MakeLower();
|
||||
@@ -563,14 +591,19 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
|
||||
|
||||
Actor* pActor = MakeActor( ID );
|
||||
m_pActors.push_back( pActor );
|
||||
if( Stretch )
|
||||
pActor->StretchTo( FullScreenRectI );
|
||||
else
|
||||
pActor->SetXY( CENTER_X, CENTER_Y );
|
||||
ASSERT( !(m_bGeneric && Stretch) );
|
||||
if( !m_bGeneric )
|
||||
{
|
||||
if( Stretch )
|
||||
pActor->StretchTo( FullScreenRectI );
|
||||
else
|
||||
pActor->SetXY( CENTER_X, CENTER_Y );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_PARTICLES:
|
||||
{
|
||||
ASSERT( !m_bGeneric );
|
||||
for( int i=0; i<m_iNumParticles; i++ )
|
||||
{
|
||||
Actor* pActor = MakeActor( sPath );
|
||||
@@ -592,6 +625,7 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
|
||||
break;
|
||||
case TYPE_TILES:
|
||||
{
|
||||
ASSERT( !m_bGeneric );
|
||||
Sprite s;
|
||||
RageTextureID ID(sPath);
|
||||
ID.bStretch = true;
|
||||
@@ -627,7 +661,8 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
|
||||
m_pActors[i]->SetState( rand()%m_pActors[i]->GetNumStates() );
|
||||
}
|
||||
|
||||
PlayCommand( "On" );
|
||||
if( !m_bGeneric )
|
||||
PlayCommand( "On" );
|
||||
}
|
||||
|
||||
float BGAnimationLayer::GetMaxTweenTimeLeft() const
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
class BGAnimationLayer
|
||||
{
|
||||
public:
|
||||
BGAnimationLayer();
|
||||
BGAnimationLayer( bool Generic );
|
||||
~BGAnimationLayer();
|
||||
void Init();
|
||||
void Unload();
|
||||
@@ -92,6 +92,7 @@ protected:
|
||||
//
|
||||
|
||||
// common stuff
|
||||
bool m_bGeneric;
|
||||
map<CString, CString> m_asCommands;
|
||||
float m_fRepeatCommandEverySeconds; // -1 = no repeat
|
||||
float m_fSecondsUntilNextCommand;
|
||||
|
||||
Reference in New Issue
Block a user