Add texture commands.
This commit is contained in:
+13
-24
@@ -22,7 +22,7 @@
|
|||||||
#include "RageDisplay.h"
|
#include "RageDisplay.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "SDL_utils.h"
|
#include "SDL_utils.h"
|
||||||
#include "arch/ArchHooks/ArchHooks.h"
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
Sprite::Sprite()
|
Sprite::Sprite()
|
||||||
{
|
{
|
||||||
@@ -585,43 +585,32 @@ bool Sprite::IsDiagonalBanner( int iWidth, int iHeight )
|
|||||||
return iWidth >= 100 && abs(iWidth - iHeight) < 2;
|
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 )
|
void Sprite::HandleCommand( const CStringArray &asTokens )
|
||||||
{
|
{
|
||||||
int iMaxIndexAccessed = 0;
|
HandleParams;
|
||||||
|
|
||||||
#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)
|
|
||||||
|
|
||||||
const CString& sName = asTokens[0];
|
const CString& sName = asTokens[0];
|
||||||
|
|
||||||
// Commands that go in the tweening queue:
|
// 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):
|
// Commands that take effect immediately (ignoring the tweening queue):
|
||||||
if( sName=="customtexturerect" ) SetCustomTextureRect( RectF(fParam(1),fParam(2),fParam(3),fParam(4)) );
|
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=="texcoordvelocity" ) SetTexCoordVelocity( fParam(1),fParam(2) );
|
||||||
else if( sName=="scaletoclipped" ) ScaleToClipped( 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
|
else
|
||||||
{
|
{
|
||||||
Actor::HandleCommand( asTokens );
|
Actor::HandleCommand( asTokens );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( iMaxIndexAccessed != (int)asTokens.size()-1 )
|
CheckHandledParams;
|
||||||
{
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user