cleanup ugly nested conditionals
This commit is contained in:
+42
-26
@@ -51,6 +51,19 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
layer.GetAttrValue( "File", sFile );
|
layer.GetAttrValue( "File", sFile );
|
||||||
FixSlashesInPlace( sFile );
|
FixSlashesInPlace( sFile );
|
||||||
|
|
||||||
|
CString sText;
|
||||||
|
bool bHasText = layer.GetAttrValue( "Text", sText );
|
||||||
|
|
||||||
|
// backward compatibility hacks
|
||||||
|
if( bHasText )
|
||||||
|
sType = "BitmapText";
|
||||||
|
else if( sFile.CompareNoCase("songbackground") == 0 )
|
||||||
|
sType = "SongBackground";
|
||||||
|
else if( sFile.CompareNoCase("songbanner") == 0 )
|
||||||
|
sType = "SongBanner";
|
||||||
|
else if( sFile.CompareNoCase("coursebanner") == 0 )
|
||||||
|
sType = "CourseBanner";
|
||||||
|
|
||||||
if( sType == "SongCreditDisplay" )
|
if( sType == "SongCreditDisplay" )
|
||||||
{
|
{
|
||||||
pActor = new SongCreditDisplay;
|
pActor = new SongCreditDisplay;
|
||||||
@@ -61,9 +74,8 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
pBGA->LoadFromNode( sAniDir, layer );
|
pBGA->LoadFromNode( sAniDir, layer );
|
||||||
pActor = pBGA;
|
pActor = pBGA;
|
||||||
}
|
}
|
||||||
else
|
else if( sType == "BitmapText" )
|
||||||
{
|
{
|
||||||
|
|
||||||
/* XXX: How to handle translations? Maybe we should have one metrics section,
|
/* XXX: How to handle translations? Maybe we should have one metrics section,
|
||||||
* "Text", eg:
|
* "Text", eg:
|
||||||
*
|
*
|
||||||
@@ -73,36 +85,34 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
*
|
*
|
||||||
* and allow "$TextItem$" in .actors to reference that.
|
* and allow "$TextItem$" in .actors to reference that.
|
||||||
*/
|
*/
|
||||||
/* Be careful: if sFile is "", and we don't check it, then we can end up recursively
|
|
||||||
* loading the BGAnimationLayer that we're in. */
|
|
||||||
if( sFile == "" )
|
|
||||||
RageException::Throw( "The actor file in '%s' is missing the File argument",
|
|
||||||
sAniDir.c_str() );
|
|
||||||
|
|
||||||
CString text;
|
|
||||||
if( layer.GetAttrValue("Text", text) )
|
|
||||||
{
|
|
||||||
/* It's a BitmapText. Note that we could do the actual text setting with metrics,
|
/* It's a BitmapText. Note that we could do the actual text setting with metrics,
|
||||||
* by adding "text" and "alttext" commands, but right now metrics can't contain
|
* by adding "text" and "alttext" commands, but right now metrics can't contain
|
||||||
* commas or semicolons. It's useful to be able to refer to fonts in the real
|
* commas or semicolons. It's useful to be able to refer to fonts in the real
|
||||||
* theme font dirs, too. */
|
* theme font dirs, too. */
|
||||||
CString alttext;
|
CString sAlttext;
|
||||||
layer.GetAttrValue("AltText", alttext );
|
layer.GetAttrValue("AltText", sAlttext );
|
||||||
text.Replace( "::", "\n" );
|
|
||||||
alttext.Replace( "::", "\n" );
|
|
||||||
|
|
||||||
FontCharAliases::ReplaceMarkers( text );
|
// Keep the special treatment of text string sync'd with the same treatments
|
||||||
FontCharAliases::ReplaceMarkers( alttext );
|
// in ThemeManager.
|
||||||
|
sText.Replace( "::", "\n" );
|
||||||
|
sAlttext.Replace( "::", "\n" );
|
||||||
|
|
||||||
|
FontCharAliases::ReplaceMarkers( sText );
|
||||||
|
FontCharAliases::ReplaceMarkers( sAlttext );
|
||||||
|
|
||||||
BitmapText* pBitmapText = new BitmapText;
|
BitmapText* pBitmapText = new BitmapText;
|
||||||
|
|
||||||
|
/* Be careful: if sFile is "", and we don't check it, then we can end up recursively
|
||||||
|
* loading the BGAnimationLayer that we're in. */
|
||||||
|
if( sFile == "" )
|
||||||
|
RageException::Throw( "A BitmapText in '%s' is missing the File attribute",
|
||||||
|
sAniDir.c_str() );
|
||||||
|
|
||||||
pBitmapText->LoadFromFont( THEME->GetPathToF( sFile ) );
|
pBitmapText->LoadFromFont( THEME->GetPathToF( sFile ) );
|
||||||
pBitmapText->SetText( text, alttext );
|
pBitmapText->SetText( sText, sAlttext );
|
||||||
pActor = pBitmapText;
|
pActor = pBitmapText;
|
||||||
}
|
}
|
||||||
else
|
else if( sType == "SongBackground" )
|
||||||
{
|
|
||||||
if( sFile.CompareNoCase("songbackground")==0 )
|
|
||||||
{
|
{
|
||||||
Song *pSong = GAMESTATE->m_pCurSong;
|
Song *pSong = GAMESTATE->m_pCurSong;
|
||||||
if( pSong && pSong->HasBackground() )
|
if( pSong && pSong->HasBackground() )
|
||||||
@@ -117,7 +127,7 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
pSprite->LoadBG( sFile );
|
pSprite->LoadBG( sFile );
|
||||||
pActor = pSprite;
|
pActor = pSprite;
|
||||||
}
|
}
|
||||||
else if( sFile.CompareNoCase("songbanner")==0 )
|
else if( sType == "SongBanner" )
|
||||||
{
|
{
|
||||||
Song *pSong = GAMESTATE->m_pCurSong;
|
Song *pSong = GAMESTATE->m_pCurSong;
|
||||||
if( pSong == NULL )
|
if( pSong == NULL )
|
||||||
@@ -150,7 +160,7 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
|
|
||||||
TEXTUREMAN->EnableOddDimensionWarning();
|
TEXTUREMAN->EnableOddDimensionWarning();
|
||||||
}
|
}
|
||||||
else if( sFile.CompareNoCase("coursebanner")==0 )
|
else if( sType == "CourseBanner" )
|
||||||
{
|
{
|
||||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||||
if( pCourse == NULL )
|
if( pCourse == NULL )
|
||||||
@@ -180,9 +190,16 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
|||||||
pActor = pSprite;
|
pActor = pSprite;
|
||||||
TEXTUREMAN->EnableOddDimensionWarning();
|
TEXTUREMAN->EnableOddDimensionWarning();
|
||||||
}
|
}
|
||||||
else
|
else // sType is empty or garbage (e.g. "1" // 0==Sprite")
|
||||||
{
|
{
|
||||||
|
// automatically figure out the type
|
||||||
retry:
|
retry:
|
||||||
|
/* Be careful: if sFile is "", and we don't check it, then we can end up recursively
|
||||||
|
* loading the BGAnimationLayer that we're in. */
|
||||||
|
if( sFile == "" )
|
||||||
|
RageException::Throw( "The actor file in '%s' is missing the File attribute",
|
||||||
|
sAniDir.c_str() );
|
||||||
|
|
||||||
/* XXX: We need to do a theme search, since the file we're loading might
|
/* XXX: We need to do a theme search, since the file we're loading might
|
||||||
* be overridden by the theme. */
|
* be overridden by the theme. */
|
||||||
CString sNewPath = sAniDir+sFile;
|
CString sNewPath = sAniDir+sFile;
|
||||||
@@ -240,8 +257,7 @@ retry:
|
|||||||
|
|
||||||
pActor = MakeActor( sNewPath );
|
pActor = MakeActor( sNewPath );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float f;
|
float f;
|
||||||
if( layer.GetAttrValue( "BaseRotationXDegrees", f ) ) pActor->SetBaseRotationX( f );
|
if( layer.GetAttrValue( "BaseRotationXDegrees", f ) ) pActor->SetBaseRotationX( f );
|
||||||
|
|||||||
Reference in New Issue
Block a user