Move actor command parsing helpers into ActorUtil.
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "IniFile.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "RageUtil_FileDB.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageLog.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
|
||||
static Actor* LoadActor( CString sPath )
|
||||
@@ -37,6 +40,15 @@ static Actor* LoadActor( CString sPath )
|
||||
|
||||
sNewPath = DerefRedir( sNewPath );
|
||||
|
||||
/* XXX: How to handle translations? Maybe we should have one metrics section,
|
||||
* "Text", eg:
|
||||
*
|
||||
* [Text]
|
||||
* SoundVolume=Sound Volume
|
||||
* TextItem=Hello
|
||||
*
|
||||
* and allow "$TextItem$" in .actors to reference that.
|
||||
*/
|
||||
Actor* pActor = NULL;
|
||||
CString text;
|
||||
if( ini.GetValue ( "Actor", "Text", text ) )
|
||||
@@ -107,3 +119,11 @@ Actor* MakeActor( CString sPath )
|
||||
sPath.c_str(), sExt.c_str() );
|
||||
}
|
||||
|
||||
void IncorrectActorParametersWarning( const CStringArray &asTokens, int iMaxIndexAccessed, int size )
|
||||
{
|
||||
const CString sError = ssprintf( "Actor::HandleCommand: Wrong number of parameters in command '%s'. Expected %d but there are %d.",
|
||||
join(",",asTokens).c_str(), iMaxIndexAccessed+1, size );
|
||||
LOG->Warn( sError );
|
||||
if( DISPLAY->IsWindowed() )
|
||||
HOOKS->MessageBoxOK( sError );
|
||||
}
|
||||
|
||||
@@ -91,6 +91,22 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/* Actor command parsing helpers. */
|
||||
#define HandleParams int iMaxIndexAccessed = 0;
|
||||
#define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed))
|
||||
#define fParam(i) ((float)atof(sParam(i)))
|
||||
#define iParam(i) (atoi(sParam(i)))
|
||||
#define bParam(i) (iParam(i)!=0)
|
||||
#define CheckHandledParams if( iMaxIndexAccessed != (int)asTokens.size()-1 ) { IncorrectActorParametersWarning( asTokens, iMaxIndexAccessed, asTokens.size() ); }
|
||||
void IncorrectActorParametersWarning( const CStringArray &asTokens, int iMaxIndexAccessed, int size );
|
||||
inline CString GetParam( const CStringArray& sParams, int iIndex, int& iMaxIndexAccessed )
|
||||
{
|
||||
iMaxIndexAccessed = max( iIndex, iMaxIndexAccessed );
|
||||
if( iIndex < int(sParams.size()) )
|
||||
return sParams[iIndex];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user