Add texture commands.

This commit is contained in:
Glenn Maynard
2003-10-30 21:58:18 +00:00
parent 124707961c
commit c311bff4a4
+13 -24
View File
@@ -22,7 +22,7 @@
#include "RageDisplay.h"
#include "GameConstantsAndTypes.h"
#include "SDL_utils.h"
#include "arch/ArchHooks/ArchHooks.h"
#include "ActorUtil.h"
Sprite::Sprite()
{
@@ -585,43 +585,32 @@ bool Sprite::IsDiagonalBanner( int iWidth, int iHeight )
return iWidth >= 100 && abs(iWidth - iHeight) < 2;
}
inline CString GetParam( const CStringArray& sParams, int iIndex, int& iMaxIndexAccessed )
{
iMaxIndexAccessed = max( iIndex, iMaxIndexAccessed );
if( iIndex < int(sParams.size()) )
return sParams[iIndex];
else
return "";
}
void Sprite::HandleCommand( const CStringArray &asTokens )
{
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)
HandleParams;
const CString& sName = asTokens[0];
// Commands that go in the tweening queue:
/* Add left/right/top/bottom for alpha if needed. */
// Commands that take effect immediately (ignoring the tweening queue):
if( sName=="customtexturerect" ) SetCustomTextureRect( RectF(fParam(1),fParam(2),fParam(3),fParam(4)) );
else if( sName=="texcoordvelocity" ) SetTexCoordVelocity( fParam(1),fParam(2) );
else if( sName=="scaletoclipped" ) ScaleToClipped( fParam(1),fParam(2) );
/* Texture commands; these could be moved to RageTexture* (even though that's
* not an Actor) if these are needed for other things that use textures.
* We'd need to break the command helpers into a separate function; RageTexture
* shouldn't depend on Actor. */
else if( sName=="position" ) GetTexture()->SetPosition( fParam(1) );
else if( sName=="loop" ) GetTexture()->SetLooping( bParam(1) );
else if( sName=="play" ) GetTexture()->Play();
else if( sName=="pause" ) GetTexture()->Pause();
else if( sName=="rate" ) GetTexture()->SetPlaybackRate( fParam(1) );
else
{
Actor::HandleCommand( asTokens );
return;
}
if( iMaxIndexAccessed != (int)asTokens.size()-1 )
{
CString sError = ssprintf( "Actor::HandleCommand: Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).c_str(), iMaxIndexAccessed+1, (int)asTokens.size() );
LOG->Warn( sError );
if( DISPLAY->IsWindowed() )
HOOKS->MessageBoxOK( sError );
}
CheckHandledParams;
}