Allow setting text of BitmapTexts in Actor files.
This commit is contained in:
+37
-16
@@ -16,15 +16,11 @@
|
|||||||
#include "BitmapText.h"
|
#include "BitmapText.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
|
#include "ThemeManager.h"
|
||||||
|
#include "RageUtil_FileDB.h"
|
||||||
|
|
||||||
|
|
||||||
Actor* MakeActor( CString sPath )
|
static Actor* LoadActor( CString sPath )
|
||||||
{
|
|
||||||
CString sExt = GetExtension(sPath);
|
|
||||||
sExt.MakeLower();
|
|
||||||
|
|
||||||
|
|
||||||
if( sExt=="actor" )
|
|
||||||
{
|
{
|
||||||
// TODO: Check for recursive loading
|
// TODO: Check for recursive loading
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
@@ -39,12 +35,32 @@ Actor* MakeActor( CString sPath )
|
|||||||
|
|
||||||
CString sNewPath = Dirname( sPath ) + sFileName;
|
CString sNewPath = Dirname( sPath ) + sFileName;
|
||||||
|
|
||||||
|
sNewPath = DerefRedir( sNewPath );
|
||||||
|
|
||||||
|
Actor* pActor = NULL;
|
||||||
|
CString text;
|
||||||
|
if( ini.GetValue ( "Actor", "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;
|
||||||
|
ini.GetValue ( "Actor", "AltText", alttext );
|
||||||
|
|
||||||
|
BitmapText* pBitmapText = new BitmapText;
|
||||||
|
pActor = pBitmapText;
|
||||||
|
|
||||||
|
pBitmapText->LoadFromFont( THEME->GetPathToF( sFileName ) );
|
||||||
|
pBitmapText->SetText( text, alttext );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if( !DoesFileExist(sNewPath) )
|
if( !DoesFileExist(sNewPath) )
|
||||||
RageException::Throw( "The actor file '%s' references a file '%s' which doesn't exist.", sPath.c_str(), sNewPath.c_str() );
|
RageException::Throw( "The actor file '%s' references a file '%s' which doesn't exist.", sPath.c_str(), sNewPath.c_str() );
|
||||||
|
|
||||||
sNewPath = DerefRedir( sNewPath );
|
pActor = MakeActor( sNewPath );
|
||||||
|
}
|
||||||
Actor* pActor = MakeActor( sNewPath );
|
|
||||||
|
|
||||||
float f;
|
float f;
|
||||||
if( ini.GetValue ( "Actor", "BaseRotationXDegrees", f ) ) pActor->SetBaseRotationX( f );
|
if( ini.GetValue ( "Actor", "BaseRotationXDegrees", f ) ) pActor->SetBaseRotationX( f );
|
||||||
@@ -56,6 +72,17 @@ Actor* MakeActor( CString sPath )
|
|||||||
|
|
||||||
return pActor;
|
return pActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Actor* MakeActor( CString sPath )
|
||||||
|
{
|
||||||
|
CString sExt = GetExtension(sPath);
|
||||||
|
sExt.MakeLower();
|
||||||
|
|
||||||
|
|
||||||
|
if( sExt=="actor" )
|
||||||
|
{
|
||||||
|
return LoadActor( sPath );
|
||||||
|
}
|
||||||
else if( sExt=="png" ||
|
else if( sExt=="png" ||
|
||||||
sExt=="jpg" ||
|
sExt=="jpg" ||
|
||||||
sExt=="gif" ||
|
sExt=="gif" ||
|
||||||
@@ -69,12 +96,6 @@ Actor* MakeActor( CString sPath )
|
|||||||
pSprite->Load( sPath );
|
pSprite->Load( sPath );
|
||||||
return pSprite;
|
return pSprite;
|
||||||
}
|
}
|
||||||
else if( sExt=="ini" )
|
|
||||||
{
|
|
||||||
BitmapText* pBitmapText = new BitmapText;
|
|
||||||
pBitmapText->LoadFromFont( sPath );
|
|
||||||
return pBitmapText;
|
|
||||||
}
|
|
||||||
else if( sExt=="txt" )
|
else if( sExt=="txt" )
|
||||||
{
|
{
|
||||||
Model* pModel = new Model;
|
Model* pModel = new Model;
|
||||||
|
|||||||
Reference in New Issue
Block a user