00001
00002
00003
#ifndef SPRITE_H
00004
#define SPRITE_H
00005
00006
#include "Actor.h"
00007
#include "RageTextureID.h"
00008
00009
class RageTexture;
00010
00011
00012 #define LUA_Sprite_METHODS( T ) \
00013
LUA_Actor_METHODS( T ) \
00014
00015 \
00016 static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
00017 static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; } \
00018 static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; } \
00019 static int stretchtexcoords( T* p, lua_State *L ) { p->StretchTexCoords( FArg(1),FArg(2) ); return 0; } \
00020
00021
00022
00023 \
00024 static int position( T* p, lua_State *L ) { p->SetPosition(FArg(1)); return 0; } \
00025 static int loop( T* p, lua_State *L ) { p->SetLooping(BArg(1)); return 0; } \
00026 static int rate( T* p, lua_State *L ) { p->SetPlaybackRate(FArg(1)); return 0; } \
00027
00028
#define LUA_Sprite_METHODS_MAP( T ) \
00029
LUA_Actor_METHODS_MAP( T ) \
00030
LUA_METHOD_MAP( T, customtexturerect ) \
00031
LUA_METHOD_MAP( T, texcoordvelocity ) \
00032
LUA_METHOD_MAP( T, scaletoclipped ) \
00033
LUA_METHOD_MAP( T, stretchtexcoords ) \
00034
LUA_METHOD_MAP( T, position ) \
00035 LUA_METHOD_MAP( T, loop ) \
00036
LUA_METHOD_MAP( T, rate ) \
00037
00038
00039
class Sprite:
public Actor
00040 {
00041
public:
00042
Sprite();
00043
virtual ~Sprite();
00044
00045
virtual bool EarlyAbortDraw();
00046
virtual void DrawPrimitives();
00047
virtual void Update(
float fDeltaTime );
00048
00049
virtual void GainFocus(
float fRate,
bool bRewindMovie,
bool bLoop );
00050
virtual void LoseFocus();
00051
00052
void UpdateAnimationState();
00053
00054
00055
static RageTextureID SongBGTexture(
RageTextureID ID );
00056
00057
00058
static RageTextureID SongBannerTexture(
RageTextureID ID );
00059
00060
00061
00062 virtual bool LoadBG(
RageTextureID ID );
00063
virtual bool Load(
RageTextureID ID );
00064
00065
void UnloadTexture();
00066
RageTexture*
GetTexture() {
return m_pTexture; };
00067
00068
virtual void EnableAnimation(
bool bEnable );
00069
00070
virtual int GetNumStates() const;
00071 virtual
void SetState(
int iNewState );
00072 virtual
float GetAnimationLengthSeconds() const;
00073 virtual
void SetSecondsIntoAnimation(
float fSeconds );
00074
00075 CString GetTexturePath() const;
00076
00077
void SetCustomTextureRect( const
RectF &new_texcoord_frect );
00078
void SetCustomTextureCoords(
float fTexCoords[8] );
00079
void SetCustomSourceRect( const
RectF &rectSourceCoords );
00080
void SetCustomImageRect(
RectF rectImageCoords );
00081
void SetCustomImageCoords(
float fImageCoords[8] );
00082 const
RectF *GetCurrentTextureCoordRect() const;
00083
void StopUsingCustomCoords();
00084
void GetActiveTextureCoords(
float fTexCoordsOut[8]) const;
00085
void StretchTexCoords(
float fX,
float fY );
00086
void SetPosition(
float f );
00087 void SetLooping(
bool b );
00088
void SetPlaybackRate(
float f );
00089
00090
00091
void SetTexCoordVelocity(
float fVelX,
float fVelY) {
m_fTexCoordVelocityX = fVelX;
m_fTexCoordVelocityY = fVelY; }
00092
00093
00094
void ScaleToClipped(
float fWidth,
float fHeight );
00095
static bool IsDiagonalBanner(
int iWidth,
int iHeight );
00096
00097
00098
00099
00100
virtual void PushSelf( lua_State *L );
00101
00102
protected:
00103
virtual bool LoadFromTexture(
RageTextureID ID );
00104 virtual bool LoadFromSpriteFile(
RageTextureID ID );
00105
00106 void DrawTexture(
const TweenState *state );
00107
00108 CString m_sSpritePath;
00109
RageTexture*
m_pTexture;
00110 bool m_bDrawIfTextureNull;
00111
00112
struct State
00113 {
00114 int iFrameIndex;
00115 float fDelay;
00116 };
00117 vector<State>
m_States;
00118 int m_iCurState;
00119 float m_fSecsIntoState;
00120
00121
bool m_bUsingCustomTexCoords;
00122
bool m_bSkipNextUpdate;
00123 float m_CustomTexCoords[8];
00124
00125
00126
00127
float m_fRememberedClipWidth,
m_fRememberedClipHeight;
00128
00129
float m_fTexCoordVelocityX;
00130
float m_fTexCoordVelocityY;
00131 };
00132
00133
00134
#endif
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159