make Quad less special. Create a "default" texture object for the
"no texture" properties. This way, loaded sprites always have a texture loaded.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include "global.h"
|
||||
#include "Quad.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "RageTextureManager.h"
|
||||
|
||||
REGISTER_ACTOR_CLASS( Quad )
|
||||
|
||||
|
||||
void Quad::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
Load( TEXTUREMAN->GetDefaultTextureID() );
|
||||
|
||||
// HACK: Bypass Sprite's texture loading. Sprite should really derive from Quad.
|
||||
Actor::LoadFromNode( pNode );
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@
|
||||
class Quad : public Sprite
|
||||
{
|
||||
public:
|
||||
Quad()
|
||||
{
|
||||
SetDrawIfTextureNull( true );
|
||||
}
|
||||
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
virtual Quad *Copy() const;
|
||||
};
|
||||
|
||||
@@ -194,6 +194,9 @@ public:
|
||||
RageSurface* img, // must be in pixfmt
|
||||
bool bGenerateMipMaps
|
||||
) = 0;
|
||||
/* Return a texture handle to the default texture, an opaque, all-white,
|
||||
* immutable texture. Deleting or updating this texture has no effect. */
|
||||
virtual unsigned CreateTextureDefault() = 0;
|
||||
virtual void UpdateTexture(
|
||||
unsigned iTexHandle,
|
||||
RageSurface* img,
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
PixelFormat pixfmt,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps ) { return 1; }
|
||||
unsigned CreateTextureDefault() { return 0; }
|
||||
void UpdateTexture(
|
||||
unsigned iTexHandle,
|
||||
RageSurface* img,
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
PixelFormat pixfmt,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps );
|
||||
unsigned CreateTextureDefault() { return 0; }
|
||||
void UpdateTexture(
|
||||
unsigned iTexHandle,
|
||||
RageSurface* img,
|
||||
|
||||
@@ -89,6 +89,30 @@ void RageTextureManager::RegisterTexture( RageTextureID ID, RageTexture *pTextur
|
||||
m_mapPathToTexture[ID] = pTexture;
|
||||
}
|
||||
|
||||
static const RString g_sDefaultTextureName = "__blank__";
|
||||
RageTextureID RageTextureManager::GetDefaultTextureID()
|
||||
{
|
||||
return RageTextureID( g_sDefaultTextureName );
|
||||
}
|
||||
|
||||
class RageTexture_Default: public RageTexture
|
||||
{
|
||||
public:
|
||||
RageTexture_Default():
|
||||
RageTexture( RageTextureID() )
|
||||
{
|
||||
m_uTexHandle = DISPLAY->CreateTextureDefault();
|
||||
m_iSourceWidth = m_iSourceHeight = 1;
|
||||
m_iTextureWidth = m_iTextureHeight = 1;
|
||||
m_iImageWidth = m_iImageHeight = 1;
|
||||
CreateFrameRects();
|
||||
}
|
||||
unsigned GetTexHandle() const { return m_uTexHandle; }
|
||||
|
||||
private:
|
||||
unsigned m_uTexHandle;
|
||||
};
|
||||
|
||||
// Load and unload textures from disk.
|
||||
RageTexture* RageTextureManager::LoadTextureInternal( RageTextureID ID )
|
||||
{
|
||||
@@ -112,7 +136,9 @@ RageTexture* RageTextureManager::LoadTextureInternal( RageTextureID ID )
|
||||
sExt.MakeLower();
|
||||
|
||||
RageTexture* pTexture;
|
||||
if( sExt == "avi" || sExt == "mpg" || sExt == "mpeg" )
|
||||
if( ID.filename == g_sDefaultTextureName )
|
||||
pTexture = new RageTexture_Default;
|
||||
else if( sExt == "avi" || sExt == "mpg" || sExt == "mpeg" )
|
||||
pTexture = RageMovieTexture::Create( ID );
|
||||
else
|
||||
pTexture = new RageBitmapTexture( ID );
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
void EnableOddDimensionWarning() { m_iNoWarnAboutOddDimensions--; }
|
||||
bool GetOddDimensionWarning() const { return m_iNoWarnAboutOddDimensions == 0; }
|
||||
|
||||
RageTextureID GetDefaultTextureID();
|
||||
|
||||
private:
|
||||
void DeleteTexture( RageTexture *t );
|
||||
enum GCType { screen_changed, delayed_delete };
|
||||
|
||||
@@ -20,7 +20,6 @@ REGISTER_ACTOR_CLASS( Sprite )
|
||||
Sprite::Sprite()
|
||||
{
|
||||
m_pTexture = NULL;
|
||||
m_bDrawIfTextureNull = false;
|
||||
m_iCurState = 0;
|
||||
m_fSecsIntoState = 0.0f;
|
||||
m_bUsingCustomTexCoords = false;
|
||||
@@ -43,7 +42,6 @@ Sprite::Sprite( const Sprite &cpy ):
|
||||
Actor( cpy )
|
||||
{
|
||||
#define CPY(a) a = cpy.a
|
||||
CPY( m_bDrawIfTextureNull );
|
||||
CPY( m_States );
|
||||
CPY( m_iCurState );
|
||||
CPY( m_fSecsIntoState );
|
||||
@@ -557,7 +555,7 @@ void Sprite::DrawTexture( const TweenState *state )
|
||||
|
||||
bool Sprite::EarlyAbortDraw() const
|
||||
{
|
||||
return m_pTexture == NULL && !m_bDrawIfTextureNull;
|
||||
return m_pTexture == NULL;
|
||||
}
|
||||
|
||||
void Sprite::DrawPrimitives()
|
||||
|
||||
@@ -67,16 +67,14 @@ public:
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
void SetDrawIfTextureNull( bool b ) { m_bDrawIfTextureNull = b; }
|
||||
void LoadFromTexture( RageTextureID ID );
|
||||
|
||||
private:
|
||||
void LoadFromTexture( RageTextureID ID );
|
||||
void LoadStatesFromTexture();
|
||||
|
||||
void DrawTexture( const TweenState *state );
|
||||
|
||||
RageTexture* m_pTexture;
|
||||
bool m_bDrawIfTextureNull;
|
||||
|
||||
struct State
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user