Added SetCustomPosCoords to Sprite.
This commit is contained in:
@@ -1511,6 +1511,8 @@
|
|||||||
<Function name='LoadFromSongBanner'/>
|
<Function name='LoadFromSongBanner'/>
|
||||||
<Function name='SetAllStateDelays'/>
|
<Function name='SetAllStateDelays'/>
|
||||||
<Function name='SetCustomImageRect'/>
|
<Function name='SetCustomImageRect'/>
|
||||||
|
<Function name='SetCustomPosCoords'/>
|
||||||
|
<Function name='StopUsingCustomPosCoords'/>
|
||||||
<Function name='SetEffectMode'/>
|
<Function name='SetEffectMode'/>
|
||||||
<Function name='SetSecondsIntoAnimation'/>
|
<Function name='SetSecondsIntoAnimation'/>
|
||||||
<Function name='SetTexture'/>
|
<Function name='SetTexture'/>
|
||||||
|
|||||||
@@ -4277,6 +4277,13 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Function name='SetCustomImageRect' return='void' arguments='float fLeft, float fTop, float fRight, float fBottom'>
|
<Function name='SetCustomImageRect' return='void' arguments='float fLeft, float fTop, float fRight, float fBottom'>
|
||||||
Sets the custom image rectangle. (Works in image pixel space.)
|
Sets the custom image rectangle. (Works in image pixel space.)
|
||||||
</Function>
|
</Function>
|
||||||
|
<Function name='SetCustomPosCoords' return='void' arguments='float ulx, float uly, float llx, float lly, float lrx, float lry, float urx, float ury'>
|
||||||
|
Sets custom offsets for the corners of the Sprite. Coordinates are paired,
|
||||||
|
corner order is upper left, lower left, lower right, upper right.
|
||||||
|
</Function>
|
||||||
|
<Function name='StopUsingCustomPosCoords' return='void' arguments=''>
|
||||||
|
Turns off the custom pos coords for the sprite.
|
||||||
|
</Function>
|
||||||
<Function name='SetEffectMode' return='void' arguments='EffectMode mode'>
|
<Function name='SetEffectMode' return='void' arguments='EffectMode mode'>
|
||||||
Set the <Link class='ENUM' function='EffectMode' /> to <code>mode</code>.
|
Set the <Link class='ENUM' function='EffectMode' /> to <code>mode</code>.
|
||||||
</Function>
|
</Function>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ Sprite::Sprite()
|
|||||||
m_iCurState = 0;
|
m_iCurState = 0;
|
||||||
m_fSecsIntoState = 0.0f;
|
m_fSecsIntoState = 0.0f;
|
||||||
m_bUsingCustomTexCoords = false;
|
m_bUsingCustomTexCoords = false;
|
||||||
|
m_bUsingCustomPosCoords = false;
|
||||||
m_bSkipNextUpdate = true;
|
m_bSkipNextUpdate = true;
|
||||||
m_EffectMode = EffectMode_Normal;
|
m_EffectMode = EffectMode_Normal;
|
||||||
|
|
||||||
@@ -47,9 +48,11 @@ Sprite::Sprite( const Sprite &cpy ):
|
|||||||
CPY( m_iCurState );
|
CPY( m_iCurState );
|
||||||
CPY( m_fSecsIntoState );
|
CPY( m_fSecsIntoState );
|
||||||
CPY( m_bUsingCustomTexCoords );
|
CPY( m_bUsingCustomTexCoords );
|
||||||
|
CPY( m_bUsingCustomPosCoords );
|
||||||
CPY( m_bSkipNextUpdate );
|
CPY( m_bSkipNextUpdate );
|
||||||
CPY( m_EffectMode );
|
CPY( m_EffectMode );
|
||||||
memcpy( m_CustomTexCoords, cpy.m_CustomTexCoords, sizeof(m_CustomTexCoords) );
|
memcpy( m_CustomTexCoords, cpy.m_CustomTexCoords, sizeof(m_CustomTexCoords) );
|
||||||
|
memcpy( m_CustomPosCoords, cpy.m_CustomPosCoords, sizeof(m_CustomPosCoords) );
|
||||||
CPY( m_fRememberedClipWidth );
|
CPY( m_fRememberedClipWidth );
|
||||||
CPY( m_fRememberedClipHeight );
|
CPY( m_fRememberedClipHeight );
|
||||||
CPY( m_fTexCoordVelocityX );
|
CPY( m_fTexCoordVelocityX );
|
||||||
@@ -474,6 +477,14 @@ void Sprite::DrawTexture( const TweenState *state )
|
|||||||
v[1].p = RageVector3( croppedQuadVerticies.left, croppedQuadVerticies.bottom, 0 ); // bottom left
|
v[1].p = RageVector3( croppedQuadVerticies.left, croppedQuadVerticies.bottom, 0 ); // bottom left
|
||||||
v[2].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.bottom, 0 ); // bottom right
|
v[2].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.bottom, 0 ); // bottom right
|
||||||
v[3].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.top, 0 ); // top right
|
v[3].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.top, 0 ); // top right
|
||||||
|
if( m_bUsingCustomPosCoords )
|
||||||
|
{
|
||||||
|
for( int i=0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
v[i].p.x+= m_CustomPosCoords[i*2];
|
||||||
|
v[i].p.y+= m_CustomPosCoords[(i*2)+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DISPLAY->ClearAllTextures();
|
DISPLAY->ClearAllTextures();
|
||||||
DISPLAY->SetTexture( TextureUnit_1, m_pTexture? m_pTexture->GetTexHandle():0 );
|
DISPLAY->SetTexture( TextureUnit_1, m_pTexture? m_pTexture->GetTexHandle():0 );
|
||||||
@@ -803,6 +814,15 @@ void Sprite::SetCustomImageCoords( float fImageCoords[8] ) // order: top left, b
|
|||||||
SetCustomTextureCoords( fImageCoords );
|
SetCustomTextureCoords( fImageCoords );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sprite::SetCustomPosCoords( float fPosCoords[8] ) // order: top left, bottom left, bottom right, top right
|
||||||
|
{
|
||||||
|
m_bUsingCustomPosCoords= true;
|
||||||
|
for( int i=0; i<8; ++i )
|
||||||
|
{
|
||||||
|
m_CustomPosCoords[i]= fPosCoords[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const RectF *Sprite::GetCurrentTextureCoordRect() const
|
const RectF *Sprite::GetCurrentTextureCoordRect() const
|
||||||
{
|
{
|
||||||
return GetTextureCoordRectForState( m_iCurState );
|
return GetTextureCoordRectForState( m_iCurState );
|
||||||
@@ -839,6 +859,11 @@ void Sprite::StopUsingCustomCoords()
|
|||||||
m_bUsingCustomTexCoords = false;
|
m_bUsingCustomTexCoords = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sprite::StopUsingCustomPosCoords()
|
||||||
|
{
|
||||||
|
m_bUsingCustomPosCoords = false;
|
||||||
|
}
|
||||||
|
|
||||||
void Sprite::SetTexCoordVelocity(float fVelX, float fVelY)
|
void Sprite::SetTexCoordVelocity(float fVelX, float fVelY)
|
||||||
{
|
{
|
||||||
m_fTexCoordVelocityX = fVelX;
|
m_fTexCoordVelocityX = fVelX;
|
||||||
@@ -1035,6 +1060,21 @@ public:
|
|||||||
* Commands that take effect immediately (ignoring the tweening queue): */
|
* Commands that take effect immediately (ignoring the tweening queue): */
|
||||||
static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; }
|
static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; }
|
||||||
static int SetCustomImageRect( T* p, lua_State *L ) { p->SetCustomImageRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; }
|
static int SetCustomImageRect( T* p, lua_State *L ) { p->SetCustomImageRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; }
|
||||||
|
static int SetCustomPosCoords( T* p, lua_State *L )
|
||||||
|
{
|
||||||
|
float coords[8];
|
||||||
|
for( int i=0; i<8; ++i )
|
||||||
|
{
|
||||||
|
coords[i]= FArg(i+1);
|
||||||
|
if( isnan(coords[i]) )
|
||||||
|
{
|
||||||
|
coords[i]= 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p->SetCustomPosCoords(coords);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int StopUsingCustomPosCoords( T* p, lua_State *L ) { p->StopUsingCustomPosCoords(); return 0; }
|
||||||
static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; }
|
static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; }
|
||||||
static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; }
|
static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; }
|
||||||
static int CropTo( T* p, lua_State *L ) { p->CropTo( FArg(1),FArg(2) ); return 0; }
|
static int CropTo( T* p, lua_State *L ) { p->CropTo( FArg(1),FArg(2) ); return 0; }
|
||||||
@@ -1076,6 +1116,8 @@ public:
|
|||||||
ADD_METHOD( LoadBackground );
|
ADD_METHOD( LoadBackground );
|
||||||
ADD_METHOD( customtexturerect );
|
ADD_METHOD( customtexturerect );
|
||||||
ADD_METHOD( SetCustomImageRect );
|
ADD_METHOD( SetCustomImageRect );
|
||||||
|
ADD_METHOD( SetCustomPosCoords );
|
||||||
|
ADD_METHOD( StopUsingCustomPosCoords );
|
||||||
ADD_METHOD( texcoordvelocity );
|
ADD_METHOD( texcoordvelocity );
|
||||||
ADD_METHOD( scaletoclipped );
|
ADD_METHOD( scaletoclipped );
|
||||||
ADD_METHOD( CropTo );
|
ADD_METHOD( CropTo );
|
||||||
|
|||||||
@@ -52,9 +52,11 @@ public:
|
|||||||
void SetCustomTextureCoords( float fTexCoords[8] );
|
void SetCustomTextureCoords( float fTexCoords[8] );
|
||||||
void SetCustomImageRect( RectF rectImageCoords ); // in image pixel space
|
void SetCustomImageRect( RectF rectImageCoords ); // in image pixel space
|
||||||
void SetCustomImageCoords( float fImageCoords[8] );
|
void SetCustomImageCoords( float fImageCoords[8] );
|
||||||
|
void SetCustomPosCoords( float fPosCoords[8] );
|
||||||
const RectF *GetCurrentTextureCoordRect() const;
|
const RectF *GetCurrentTextureCoordRect() const;
|
||||||
const RectF *GetTextureCoordRectForState( int iState ) const;
|
const RectF *GetTextureCoordRectForState( int iState ) const;
|
||||||
void StopUsingCustomCoords();
|
void StopUsingCustomCoords();
|
||||||
|
void StopUsingCustomPosCoords();
|
||||||
void GetActiveTextureCoords(float fTexCoordsOut[8]) const;
|
void GetActiveTextureCoords(float fTexCoordsOut[8]) const;
|
||||||
void StretchTexCoords( float fX, float fY );
|
void StretchTexCoords( float fX, float fY );
|
||||||
void AddImageCoords( float fX, float fY ); // in image pixel space
|
void AddImageCoords( float fX, float fY ); // in image pixel space
|
||||||
@@ -99,6 +101,7 @@ private:
|
|||||||
|
|
||||||
EffectMode m_EffectMode;
|
EffectMode m_EffectMode;
|
||||||
bool m_bUsingCustomTexCoords;
|
bool m_bUsingCustomTexCoords;
|
||||||
|
bool m_bUsingCustomPosCoords;
|
||||||
bool m_bSkipNextUpdate;
|
bool m_bSkipNextUpdate;
|
||||||
/**
|
/**
|
||||||
* @brief Set up the coordinates for the texture.
|
* @brief Set up the coordinates for the texture.
|
||||||
@@ -107,6 +110,16 @@ private:
|
|||||||
* The remaining six are for the (x, y) coordinates for bottom left,
|
* The remaining six are for the (x, y) coordinates for bottom left,
|
||||||
* bottom right, and top right respectively. */
|
* bottom right, and top right respectively. */
|
||||||
float m_CustomTexCoords[8];
|
float m_CustomTexCoords[8];
|
||||||
|
/**
|
||||||
|
* @brief Set up the coordinates for the position.
|
||||||
|
*
|
||||||
|
* These are offsets for the quad the sprite will be drawn to.
|
||||||
|
* The first two are the (x, y) offsets for the top left.
|
||||||
|
* The remaining six are for the (x, y) coordinates for bottom left,
|
||||||
|
* bottom right, and top right respectively.
|
||||||
|
* These are offsets instead of a replacement for m_size to avoid
|
||||||
|
* complicating the cropping code. */
|
||||||
|
float m_CustomPosCoords[8];
|
||||||
|
|
||||||
// Remembered clipped dimensions are applied on Load().
|
// Remembered clipped dimensions are applied on Load().
|
||||||
// -1 means no remembered dimensions;
|
// -1 means no remembered dimensions;
|
||||||
|
|||||||
Reference in New Issue
Block a user