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 );
|
||||
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" )
|
||||
{
|
||||
pActor = new SongCreditDisplay;
|
||||
@@ -61,9 +74,8 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||
pBGA->LoadFromNode( sAniDir, layer );
|
||||
pActor = pBGA;
|
||||
}
|
||||
else
|
||||
else if( sType == "BitmapText" )
|
||||
{
|
||||
|
||||
/* XXX: How to handle translations? Maybe we should have one metrics section,
|
||||
* "Text", eg:
|
||||
*
|
||||
@@ -73,36 +85,34 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||
*
|
||||
* 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,
|
||||
* 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
|
||||
* theme font dirs, too. */
|
||||
CString alttext;
|
||||
layer.GetAttrValue("AltText", alttext );
|
||||
text.Replace( "::", "\n" );
|
||||
alttext.Replace( "::", "\n" );
|
||||
CString sAlttext;
|
||||
layer.GetAttrValue("AltText", sAlttext );
|
||||
|
||||
FontCharAliases::ReplaceMarkers( text );
|
||||
FontCharAliases::ReplaceMarkers( alttext );
|
||||
// Keep the special treatment of text string sync'd with the same treatments
|
||||
// in ThemeManager.
|
||||
sText.Replace( "::", "\n" );
|
||||
sAlttext.Replace( "::", "\n" );
|
||||
|
||||
FontCharAliases::ReplaceMarkers( sText );
|
||||
FontCharAliases::ReplaceMarkers( sAlttext );
|
||||
|
||||
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->SetText( text, alttext );
|
||||
pBitmapText->SetText( sText, sAlttext );
|
||||
pActor = pBitmapText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sFile.CompareNoCase("songbackground")==0 )
|
||||
else if( sType == "SongBackground" )
|
||||
{
|
||||
Song *pSong = GAMESTATE->m_pCurSong;
|
||||
if( pSong && pSong->HasBackground() )
|
||||
@@ -117,7 +127,7 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||
pSprite->LoadBG( sFile );
|
||||
pActor = pSprite;
|
||||
}
|
||||
else if( sFile.CompareNoCase("songbanner")==0 )
|
||||
else if( sType == "SongBanner" )
|
||||
{
|
||||
Song *pSong = GAMESTATE->m_pCurSong;
|
||||
if( pSong == NULL )
|
||||
@@ -150,7 +160,7 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||
|
||||
TEXTUREMAN->EnableOddDimensionWarning();
|
||||
}
|
||||
else if( sFile.CompareNoCase("coursebanner")==0 )
|
||||
else if( sType == "CourseBanner" )
|
||||
{
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
if( pCourse == NULL )
|
||||
@@ -180,9 +190,16 @@ Actor* LoadFromActorFile( const CString& sAniDir, const XNode& layer )
|
||||
pActor = pSprite;
|
||||
TEXTUREMAN->EnableOddDimensionWarning();
|
||||
}
|
||||
else
|
||||
else // sType is empty or garbage (e.g. "1" // 0==Sprite")
|
||||
{
|
||||
// automatically figure out the type
|
||||
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
|
||||
* be overridden by the theme. */
|
||||
CString sNewPath = sAniDir+sFile;
|
||||
@@ -240,8 +257,7 @@ retry:
|
||||
|
||||
pActor = MakeActor( sNewPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float f;
|
||||
if( layer.GetAttrValue( "BaseRotationXDegrees", f ) ) pActor->SetBaseRotationX( f );
|
||||
|
||||
Reference in New Issue
Block a user