2004-06-08 00:47:17 +00:00
|
|
|
/* Sprite - A bitmap Actor that animates and moves around. */
|
|
|
|
|
|
2002-11-16 08:07:38 +00:00
|
|
|
#ifndef SPRITE_H
|
|
|
|
|
#define SPRITE_H
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
#include "Actor.h"
|
2003-11-07 20:55:30 +00:00
|
|
|
#include "RageTextureID.h"
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2003-11-07 20:55:30 +00:00
|
|
|
class RageTexture;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
class Sprite: public Actor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Sprite();
|
2005-07-15 04:16:31 +00:00
|
|
|
Sprite( const Sprite &cpy );
|
2001-11-03 10:52:42 +00:00
|
|
|
virtual ~Sprite();
|
|
|
|
|
|
2006-10-09 08:24:10 +00:00
|
|
|
void LoadFromNode( const XNode* pNode );
|
2006-10-20 00:17:51 +00:00
|
|
|
virtual Sprite *Copy() const;
|
2005-04-30 07:49:14 +00:00
|
|
|
|
2005-08-25 00:57:53 +00:00
|
|
|
virtual bool EarlyAbortDraw() const;
|
2002-05-19 01:59:48 +00:00
|
|
|
virtual void DrawPrimitives();
|
2001-12-11 11:25:37 +00:00
|
|
|
virtual void Update( float fDeltaTime );
|
2004-10-18 04:20:44 +00:00
|
|
|
|
2003-12-22 10:30:10 +00:00
|
|
|
void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2004-03-26 07:50:33 +00:00
|
|
|
/* Adjust texture properties for song backgrounds. */
|
|
|
|
|
static RageTextureID SongBGTexture( RageTextureID ID );
|
|
|
|
|
|
|
|
|
|
/* Adjust texture properties for song banners. */
|
|
|
|
|
static RageTextureID SongBannerTexture( RageTextureID ID );
|
|
|
|
|
|
2005-10-11 02:15:27 +00:00
|
|
|
virtual void Load( RageTextureID ID );
|
2007-02-13 23:34:51 +00:00
|
|
|
void SetTexture( RageTexture *pTexture );
|
2003-03-23 18:52:18 +00:00
|
|
|
|
|
|
|
|
void UnloadTexture();
|
|
|
|
|
RageTexture* GetTexture() { return m_pTexture; };
|
|
|
|
|
|
|
|
|
|
virtual void EnableAnimation( bool bEnable );
|
2004-08-09 00:46:42 +00:00
|
|
|
|
|
|
|
|
virtual int GetNumStates() const;
|
2002-03-30 20:00:13 +00:00
|
|
|
virtual void SetState( int iNewState );
|
2004-08-09 00:46:42 +00:00
|
|
|
virtual float GetAnimationLengthSeconds() const;
|
2003-12-22 10:30:10 +00:00
|
|
|
virtual void SetSecondsIntoAnimation( float fSeconds );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString GetTexturePath() const;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2003-06-23 04:49:28 +00:00
|
|
|
void SetCustomTextureRect( const RectF &new_texcoord_frect );
|
|
|
|
|
void SetCustomTextureCoords( float fTexCoords[8] );
|
|
|
|
|
void SetCustomImageRect( RectF rectImageCoords ); // in image pixel space
|
|
|
|
|
void SetCustomImageCoords( float fImageCoords[8] );
|
|
|
|
|
const RectF *GetCurrentTextureCoordRect() const;
|
2007-02-13 06:46:24 +00:00
|
|
|
const RectF *GetTextureCoordRectForState( int iState ) const;
|
2002-03-31 07:55:25 +00:00
|
|
|
void StopUsingCustomCoords();
|
2003-07-03 06:38:57 +00:00
|
|
|
void GetActiveTextureCoords(float fTexCoordsOut[8]) const;
|
2003-10-30 22:56:45 +00:00
|
|
|
void StretchTexCoords( float fX, float fY );
|
2006-07-29 00:16:57 +00:00
|
|
|
void AddImageCoords( float fX, float fY ); // in image pixel space
|
2007-03-20 07:43:47 +00:00
|
|
|
void SetEffectMode( EffectMode em ) { m_EffectMode = em; }
|
2003-07-03 06:38:57 +00:00
|
|
|
|
2005-12-03 07:44:59 +00:00
|
|
|
void SetTexCoordVelocity(float fVelX, float fVelY);
|
2003-07-03 06:38:57 +00:00
|
|
|
// Scale the Sprite maintaining the aspect ratio so that it fits
|
|
|
|
|
// within (fWidth,fHeight) and is clipped to (fWidth,fHeight).
|
|
|
|
|
void ScaleToClipped( float fWidth, float fHeight );
|
|
|
|
|
static bool IsDiagonalBanner( int iWidth, int iHeight );
|
2003-06-23 04:49:28 +00:00
|
|
|
|
2005-01-26 11:21:43 +00:00
|
|
|
//
|
|
|
|
|
// Commands
|
|
|
|
|
//
|
|
|
|
|
virtual void PushSelf( lua_State *L );
|
2003-04-21 02:45:00 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
protected:
|
2007-02-13 07:39:49 +00:00
|
|
|
void LoadFromTexture( RageTextureID ID );
|
2007-02-13 06:40:14 +00:00
|
|
|
|
|
|
|
|
private:
|
2007-02-13 06:34:29 +00:00
|
|
|
void LoadStatesFromTexture();
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-11-08 19:38:38 +00:00
|
|
|
void DrawTexture( const TweenState *state );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
RageTexture* m_pTexture;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2003-05-22 05:28:37 +00:00
|
|
|
struct State
|
|
|
|
|
{
|
2007-02-08 20:38:16 +00:00
|
|
|
RectF rect;
|
2003-05-22 05:28:37 +00:00
|
|
|
float fDelay; // "seconds to show"
|
|
|
|
|
};
|
|
|
|
|
vector<State> m_States;
|
2002-03-30 20:00:13 +00:00
|
|
|
int m_iCurState;
|
2001-11-28 20:26:45 +00:00
|
|
|
float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2007-03-20 07:43:47 +00:00
|
|
|
EffectMode m_EffectMode;
|
2001-12-28 10:15:59 +00:00
|
|
|
bool m_bUsingCustomTexCoords;
|
2004-10-18 04:20:44 +00:00
|
|
|
bool m_bSkipNextUpdate;
|
2006-02-10 01:56:23 +00:00
|
|
|
float m_CustomTexCoords[8]; // (x,y) * 4: top left, bottom left, bottom right, top right
|
2003-07-03 06:38:57 +00:00
|
|
|
|
|
|
|
|
// Remembered clipped dimensions are applied on Load().
|
|
|
|
|
// -1 means no remembered dimensions;
|
|
|
|
|
float m_fRememberedClipWidth, m_fRememberedClipHeight;
|
|
|
|
|
|
|
|
|
|
float m_fTexCoordVelocityX;
|
|
|
|
|
float m_fTexCoordVelocityY;
|
2001-11-03 10:52:42 +00:00
|
|
|
};
|
2002-11-16 08:07:38 +00:00
|
|
|
|
|
|
|
|
#endif
|
2004-06-08 00:47:17 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|