support loading BGAs from XML
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "RageTextureManager.h"
|
#include "RageTextureManager.h"
|
||||||
#include "SongManager.h"
|
#include "SongManager.h"
|
||||||
#include "Course.h"
|
#include "Course.h"
|
||||||
|
#include "XmlFile.h"
|
||||||
#include "FontCharAliases.h"
|
#include "FontCharAliases.h"
|
||||||
|
|
||||||
#include "arch/Dialog/Dialog.h"
|
#include "arch/Dialog/Dialog.h"
|
||||||
@@ -39,10 +40,12 @@ Actor* LoadFromActorFile( const CString &sIniPath, const CString &sLayer )
|
|||||||
|
|
||||||
Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||||
{
|
{
|
||||||
Actor* pActor = NULL; // fill this in before we return;
|
Actor* pActor = NULL; // fill this in before we return
|
||||||
|
|
||||||
|
CString sType = layer.m_sName;
|
||||||
|
if( sType.empty() )
|
||||||
|
layer.GetAttrValue( "Type", sType );
|
||||||
|
|
||||||
CString sType;
|
|
||||||
layer.GetAttrValue( "Type", sType );
|
|
||||||
CString sFile;
|
CString sFile;
|
||||||
layer.GetAttrValue( "File", sFile );
|
layer.GetAttrValue( "File", sFile );
|
||||||
FixSlashesInPlace( sFile );
|
FixSlashesInPlace( sFile );
|
||||||
@@ -51,6 +54,12 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
{
|
{
|
||||||
pActor = new SongCreditDisplay;
|
pActor = new SongCreditDisplay;
|
||||||
}
|
}
|
||||||
|
else if( sType == "BGAnimation" )
|
||||||
|
{
|
||||||
|
BGAnimation *pBGA = new BGAnimation;
|
||||||
|
pBGA->LoadFromNode( sAniDir, layer );
|
||||||
|
pActor = pBGA;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -274,7 +283,14 @@ Actor* MakeActor( const RageTextureID &ID )
|
|||||||
CString sExt = GetExtension( ID.filename );
|
CString sExt = GetExtension( ID.filename );
|
||||||
sExt.MakeLower();
|
sExt.MakeLower();
|
||||||
|
|
||||||
if( sExt=="actor" )
|
if( sExt=="xml" )
|
||||||
|
{
|
||||||
|
XNode xml;
|
||||||
|
xml.LoadFromFile( ID.filename );
|
||||||
|
CString sDir = Dirname( ID.filename );
|
||||||
|
return LoadFromActorFile( sDir, xml );
|
||||||
|
}
|
||||||
|
else if( sExt=="actor" )
|
||||||
{
|
{
|
||||||
return LoadFromActorFile( ID.filename );
|
return LoadFromActorFile( ID.filename );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ void BGAnimation::Unload()
|
|||||||
DeleteAllChildren();
|
DeleteAllChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimation::LoadFromStaticGraphic( CString sPath )
|
void BGAnimation::LoadFromStaticGraphic( const CString &sPath )
|
||||||
{
|
{
|
||||||
Unload();
|
Unload();
|
||||||
|
|
||||||
@@ -51,11 +51,12 @@ static bool CompareLayerNames( const CString& s1, const CString& s2 )
|
|||||||
return i1 < i2;
|
return i1 < i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLayersFromAniDir( CString sAniDir, vector<Actor*> &layersAddTo, bool Generic )
|
void AddLayersFromAniDir( const CString &_sAniDir, vector<Actor*> &layersAddTo, bool Generic )
|
||||||
{
|
{
|
||||||
if( sAniDir.empty() )
|
if( _sAniDir.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CString sAniDir = _sAniDir;
|
||||||
if( sAniDir.Right(1) != "/" )
|
if( sAniDir.Right(1) != "/" )
|
||||||
sAniDir += "/";
|
sAniDir += "/";
|
||||||
|
|
||||||
@@ -118,13 +119,14 @@ void AddLayersFromAniDir( CString sAniDir, vector<Actor*> &layersAddTo, bool Gen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimation::LoadFromAniDir( CString sAniDir )
|
void BGAnimation::LoadFromAniDir( const CString &_sAniDir )
|
||||||
{
|
{
|
||||||
Unload();
|
Unload();
|
||||||
|
|
||||||
if( sAniDir.empty() )
|
if( _sAniDir.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CString sAniDir = _sAniDir;
|
||||||
if( sAniDir.Right(1) != "/" )
|
if( sAniDir.Right(1) != "/" )
|
||||||
sAniDir += "/";
|
sAniDir += "/";
|
||||||
|
|
||||||
@@ -139,34 +141,19 @@ void BGAnimation::LoadFromAniDir( CString sAniDir )
|
|||||||
|
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.ReadFile( sPathToIni );
|
ini.ReadFile( sPathToIni );
|
||||||
if( !ini.GetValue( "BGAnimation", "LengthSeconds", m_fLengthSeconds ) )
|
|
||||||
{
|
const XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
|
||||||
/* XXX: if m_bGeneric, simply constructing the BG layer won't run "On",
|
XNode dummy;
|
||||||
* so at this point GetMaxTweenTimeLeft is probably 0 */
|
dummy.m_sName = "BGAnimation";
|
||||||
m_fLengthSeconds = this->GetTweenTimeLeft();
|
if( pBGAnimation == NULL )
|
||||||
}
|
pBGAnimation = &dummy;
|
||||||
|
LoadFromNode( sAniDir, *pBGAnimation );
|
||||||
|
|
||||||
bool bUseScroller;
|
bool bUseScroller;
|
||||||
if( ini.GetValue( "BGAnimation", "UseScroller", bUseScroller ) && bUseScroller )
|
if( ini.GetValue( "BGAnimation", "UseScroller", bUseScroller ) && bUseScroller )
|
||||||
{
|
{
|
||||||
ActorScroller::LoadFromIni( ini, "Scroller" );
|
ActorScroller::LoadFromIni( ini, "Scroller" );
|
||||||
}
|
}
|
||||||
|
|
||||||
CString sInitCommand;
|
|
||||||
if( ini.GetValue( "BGAnimation", "InitCommand", sInitCommand ) )
|
|
||||||
{
|
|
||||||
/* There's an InitCommand. Run it now. This can be used to eg. change Z to
|
|
||||||
* modify draw order between BGAs in a Foreground. Most things should be done
|
|
||||||
* in metrics.ini commands, not here. */
|
|
||||||
this->RunCommands( ParseCommands(sInitCommand) );
|
|
||||||
}
|
|
||||||
|
|
||||||
Command cmd;
|
|
||||||
cmd.Load( "PlayCommand,Init" );
|
|
||||||
this->RunCommandOnChildren( cmd );
|
|
||||||
|
|
||||||
if( !m_bGeneric )
|
|
||||||
PlayCommand( "On" );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -198,7 +185,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimation::LoadFromMovie( CString sMoviePath )
|
void BGAnimation::LoadFromMovie( const CString &sMoviePath )
|
||||||
{
|
{
|
||||||
Unload();
|
Unload();
|
||||||
|
|
||||||
@@ -207,7 +194,7 @@ void BGAnimation::LoadFromMovie( CString sMoviePath )
|
|||||||
AddChild( pLayer );
|
AddChild( pLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimation::LoadFromVisualization( CString sVisPath )
|
void BGAnimation::LoadFromVisualization( const CString &sVisPath )
|
||||||
{
|
{
|
||||||
Unload();
|
Unload();
|
||||||
BGAnimationLayer* pLayer;
|
BGAnimationLayer* pLayer;
|
||||||
@@ -224,6 +211,46 @@ void BGAnimation::LoadFromVisualization( CString sVisPath )
|
|||||||
AddChild( pLayer );
|
AddChild( pLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node )
|
||||||
|
{
|
||||||
|
DEBUG_ASSERT( node.m_sName == "BGAnimation" );
|
||||||
|
|
||||||
|
|
||||||
|
if( !node.GetAttrValue( "LengthSeconds", m_fLengthSeconds ) )
|
||||||
|
{
|
||||||
|
/* XXX: if m_bGeneric, simply constructing the BG layer won't run "On",
|
||||||
|
* so at this point GetMaxTweenTimeLeft is probably 0 */
|
||||||
|
m_fLengthSeconds = this->GetTweenTimeLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
CString sInitCommand;
|
||||||
|
if( node.GetAttrValue( "InitCommand", sInitCommand ) )
|
||||||
|
{
|
||||||
|
/* There's an InitCommand. Run it now. This can be used to eg. change Z to
|
||||||
|
* modify draw order between BGAs in a Foreground. Most things should be done
|
||||||
|
* in metrics.ini commands, not here. */
|
||||||
|
this->RunCommands( ParseCommands(sInitCommand) );
|
||||||
|
}
|
||||||
|
|
||||||
|
const XNode* pChildren = node.GetChild("children");
|
||||||
|
if( pChildren )
|
||||||
|
{
|
||||||
|
FOREACH_CONST_Child( pChildren, pChild )
|
||||||
|
{
|
||||||
|
Actor* pChildActor = LoadFromActorFile( sDir, *pChild );
|
||||||
|
AddChild( pChildActor );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Command cmd;
|
||||||
|
cmd.Load( "PlayCommand,Init" );
|
||||||
|
this->RunCommandOnChildren( cmd );
|
||||||
|
|
||||||
|
if( !m_bGeneric )
|
||||||
|
PlayCommand( "On" );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Ben Nordstrom, Chris Danford
|
* (c) 2001-2004 Ben Nordstrom, Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
* is used for many things other than backgrounds. */
|
* is used for many things other than backgrounds. */
|
||||||
#include "ActorScroller.h"
|
#include "ActorScroller.h"
|
||||||
|
|
||||||
|
struct XNode;
|
||||||
|
|
||||||
class BGAnimation : public ActorScroller
|
class BGAnimation : public ActorScroller
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -15,10 +17,11 @@ public:
|
|||||||
|
|
||||||
void Unload();
|
void Unload();
|
||||||
|
|
||||||
void LoadFromStaticGraphic( CString sPath );
|
void LoadFromStaticGraphic( const CString &sPath );
|
||||||
void LoadFromAniDir( CString sAniDir );
|
void LoadFromAniDir( const CString &sAniDir );
|
||||||
void LoadFromMovie( CString sMoviePath );
|
void LoadFromMovie( const CString &sMoviePath );
|
||||||
void LoadFromVisualization( CString sMoviePath );
|
void LoadFromVisualization( const CString &sMoviePath );
|
||||||
|
void LoadFromNode( const CString &sDir, const XNode& node );
|
||||||
|
|
||||||
float GetLengthSeconds() const { return m_fLengthSeconds; }
|
float GetLengthSeconds() const { return m_fLengthSeconds; }
|
||||||
|
|
||||||
|
|||||||
@@ -819,6 +819,7 @@ void BGAnimationLayer::PlayCommand( const CString &sCommandName )
|
|||||||
ActorFrame::PlayCommand( sCommandName );
|
ActorFrame::PlayCommand( sCommandName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Ben Nordstrom, Chris Danford, Glenn Maynard
|
* (c) 2001-2004 Ben Nordstrom, Chris Danford, Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ CString NoteSkinManager::GetPathToFromDir( const CString &sDir, const CString &s
|
|||||||
CStringArray matches; // fill this with the possible files
|
CStringArray matches; // fill this with the possible files
|
||||||
|
|
||||||
GetDirListing( sDir+sFileName+"*.redir", matches, false, true );
|
GetDirListing( sDir+sFileName+"*.redir", matches, false, true );
|
||||||
|
GetDirListing( sDir+sFileName+"*.xml", matches, false, true );
|
||||||
GetDirListing( sDir+sFileName+"*.actor", matches, false, true );
|
GetDirListing( sDir+sFileName+"*.actor", matches, false, true );
|
||||||
GetDirListing( sDir+sFileName+"*.model", matches, false, true );
|
GetDirListing( sDir+sFileName+"*.model", matches, false, true );
|
||||||
GetDirListing( sDir+sFileName+"*.txt", matches, false, true );
|
GetDirListing( sDir+sFileName+"*.txt", matches, false, true );
|
||||||
|
|||||||
@@ -333,10 +333,10 @@ try_element_again:
|
|||||||
|
|
||||||
for( unsigned p = 0; p < asPaths.size(); ++p )
|
for( unsigned p = 0; p < asPaths.size(); ++p )
|
||||||
{
|
{
|
||||||
static const char *masks[NUM_ELEMENT_CATEGORIES][12] = {
|
static const char *masks[NUM_ELEMENT_CATEGORIES][13] = {
|
||||||
{ "", NULL },
|
{ "", NULL },
|
||||||
{ "ini", NULL },
|
{ "ini", NULL },
|
||||||
{ "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", "", NULL},
|
{ "xml", "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", "", NULL},
|
||||||
{ "png", NULL },
|
{ "png", NULL },
|
||||||
{ "mp3", "ogg", "wav", NULL },
|
{ "mp3", "ogg", "wav", NULL },
|
||||||
{ "sm", NULL },
|
{ "sm", NULL },
|
||||||
|
|||||||
Reference in New Issue
Block a user