From: <gma...@us...> - 2002-12-30 02:43:55
|
Update of /cvsroot/stepmania/stepmania/src In directory sc8-pr-cvs1:/tmp/cvs-serv5699 Modified Files: Background.cpp Banner.cpp Banner.h BGAnimationLayer.cpp CroppedSprite.cpp CroppedSprite.h Font.cpp ScrollingList.cpp Sprite.cpp Sprite.h Log Message: Textures are now fully ID'd by a single struct. Index: Background.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Background.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- Background.cpp 28 Dec 2002 16:07:18 -0000 1.87 +++ Background.cpp 30 Dec 2002 02:43:51 -0000 1.88 @@ -161,23 +161,8 @@ // - // Tricky! The song background looks terrible unless its loaded with no alpha - // and dithered. Create a dummy sprite that loads the texture with the proper - // hints so we don't have to hack up BGAnimation to handle this special - // case. - // XXX: This assumes the TextureManager doesn't track hints. Also, BGA - // backgrounds (bottom layer) should do this, too, for the same reason. - // We can probably handle this intelligently in the texture loader and get - // rid of bDither completely, but only if there aren't some weird BGAs out - // there that actually use the alpha channel. (In that case, the texture - // loader would have no way of knowing that the image, seeming to use the - // alpha layer, actually doesn't since it's the back-most image. Hmm.) Sprite sprDummy; - RageTexturePrefs prefs; - prefs.bForceReload = true; - prefs.iMipMaps = 1; - prefs.bDither = true; - sprDummy.Load( sSongBackgroundPath, prefs ); + sprDummy.LoadBG( sSongBackgroundPath ); { BGAnimation *pTempBGA = new BGAnimation; Index: Banner.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Banner.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- Banner.cpp 16 Dec 2002 07:33:32 -0000 1.29 +++ Banner.cpp 30 Dec 2002 02:43:52 -0000 1.30 @@ -25,10 +25,10 @@ Banner::Load( THEME->GetPathTo("Graphics","fallback banner") ); } -bool Banner::Load( CString sFilePath, RageTexturePrefs prefs ) +bool Banner::Load( RageTextureID ID ) { // note that the defaults are changes for faster loading - return CroppedSprite::Load( sFilePath, prefs ); + return CroppedSprite::Load( ID ); }; void Banner::Update( float fDeltaTime ) @@ -107,9 +107,9 @@ bool Banner::LoadRoulette() { - RageTexturePrefs prefs; - prefs.iMipMaps = 0; - Banner::Load( THEME->GetPathTo("Graphics","select music roulette banner"), prefs ); + RageTextureID ID(THEME->GetPathTo("Graphics","select music roulette banner")); + ID.iMipMaps = 0; + Banner::Load( ID ); m_bScrolling = true; return true; Index: Banner.h =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Banner.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Banner.h 16 Dec 2002 07:33:32 -0000 1.18 +++ Banner.h 30 Dec 2002 02:43:52 -0000 1.19 @@ -21,8 +21,7 @@ public: Banner(); - virtual bool Load( CString sFilePath, RageTexturePrefs prefs ); - virtual bool Load( CString sFilePath ) { return Load( sFilePath, RageTexturePrefs() ); } + virtual bool Load( RageTextureID ID ); virtual void Update( float fDeltaTime ); Index: BGAnimationLayer.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/BGAnimationLayer.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- BGAnimationLayer.cpp 27 Dec 2002 23:12:51 -0000 1.12 +++ BGAnimationLayer.cpp 30 Dec 2002 02:43:52 -0000 1.13 @@ -59,14 +59,14 @@ void BGAnimationLayer::LoadFromStaticGraphic( CString sPath ) { m_iNumSprites = 1; - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); } void BGAnimationLayer::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ) { m_iNumSprites = 1; - m_Sprites[0].Load( sMoviePath ); + m_Sprites[0].LoadBG( sMoviePath ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); m_Sprites[0].GetTexture()->Play(); ::Sleep( 50 ); // decode a frame so we don't see a black flash at the beginning @@ -79,7 +79,7 @@ void BGAnimationLayer::LoadFromVisualization( CString sMoviePath ) { m_iNumSprites = 1; - m_Sprites[0].Load( sMoviePath ); + m_Sprites[0].LoadBG( sMoviePath ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); m_Sprites[0].SetBlendModeAdd(); } @@ -142,12 +142,12 @@ { case EFFECT_CENTER: m_iNumSprites = 1; - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); m_Sprites[0].SetXY( CENTER_X, CENTER_Y ); break; case EFFECT_STRETCH_STILL: m_iNumSprites = 1; - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); break; case EFFECT_STRETCH_SCROLL_LEFT: @@ -159,9 +159,9 @@ case EFFECT_STRETCH_TWIST: { m_iNumSprites = 1; - RageTexturePrefs prefs; - prefs.bStretch = true; - m_Sprites[0].Load( sPath, prefs ); + RageTextureID ID(sPath); + ID.bStretch = true; + m_Sprites[0].LoadBG( ID ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); m_Sprites[0].SetCustomTextureRect( RectF(0,0,1,1) ); @@ -184,9 +184,9 @@ case EFFECT_STRETCH_SCROLL_H: { m_iNumSprites = 1; - RageTexturePrefs prefs; - prefs.bStretch = true; - m_Sprites[0].Load( sPath, prefs ); + RageTextureID ID(sPath); + ID.bStretch = true; + m_Sprites[0].LoadBG( ID ); m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,0,SCREEN_RIGHT, int(m_Sprites[0].GetUnzoomedHeight())) ); m_Sprites[0].SetCustomTextureRect( RectF(0,0,1,1) ); m_vTexCoordVelocity = RageVector2(+0.5f,0); @@ -195,20 +195,20 @@ break; case EFFECT_STRETCH_SPIN: m_iNumSprites = 1; - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); m_Sprites[0].ScaleToCover( RectI(SCREEN_LEFT-200,SCREEN_TOP-200,SCREEN_RIGHT+200,SCREEN_BOTTOM+200) ); m_fRotationalVelocity = 1; break; case EFFECT_PARTICLES_SPIRAL_OUT: case EFFECT_PARTICLES_SPIRAL_IN: { - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); int iSpriteArea = int( m_Sprites[0].GetUnzoomedWidth()*m_Sprites[0].GetUnzoomedHeight() ); int iMaxArea = SCREEN_WIDTH*SCREEN_HEIGHT; m_iNumSprites = min( iMaxArea / iSpriteArea, MAX_SPRITES ); for( int i=0; i<m_iNumSprites; i++ ) { - m_Sprites[i].Load( sPath ); + m_Sprites[i].LoadBG( sPath ); m_Sprites[i].SetZoom( randomf(0.2f,2) ); m_Sprites[i].SetRotation( randomf(0,PI*2) ); } @@ -220,13 +220,13 @@ case EFFECT_PARTICLES_FLOAT_RIGHT: case EFFECT_PARTICLES_BOUNCE: { - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); int iSpriteArea = int( m_Sprites[0].GetUnzoomedWidth()*m_Sprites[0].GetUnzoomedHeight() ); int iMaxArea = SCREEN_WIDTH*SCREEN_HEIGHT; m_iNumSprites = min( iMaxArea / iSpriteArea, MAX_SPRITES ); for( int i=0; i<m_iNumSprites; i++ ) { - m_Sprites[i].Load( sPath ); + m_Sprites[i].LoadBG( sPath ); m_Sprites[i].SetZoom( 0.7f + 0.6f*i/(float)m_iNumSprites ); m_Sprites[i].SetX( randomf( GetGuardRailLeft(&m_Sprites[i]), GetGuardRailRight(&m_Sprites[i]) ) ); m_Sprites[i].SetY( randomf( GetGuardRailTop(&m_Sprites[i]), GetGuardRailBottom(&m_Sprites[i]) ) ); @@ -249,7 +249,7 @@ case EFFECT_TILE_FLIP_Y: case EFFECT_TILE_PULSE: { - m_Sprites[0].Load( sPath ); + m_Sprites[0].LoadBG( sPath ); int iNumTilesWide = 1+int(SCREEN_WIDTH /m_Sprites[0].GetUnzoomedWidth()); int iNumTilesHigh = 1+int(SCREEN_HEIGHT/m_Sprites[0].GetUnzoomedHeight()); if( m_Effect == EFFECT_TILE_SCROLL_LEFT || @@ -271,7 +271,7 @@ for( int y=0; y<iNumTilesHigh; y++ ) { int i = x+y*iNumTilesWide; - m_Sprites[i].Load( sPath ); + m_Sprites[i].LoadBG( sPath ); m_Sprites[i].SetX( (x+0.5f)*m_Sprites[i].GetUnzoomedWidth() ); m_Sprites[i].SetY( (y+0.5f)*m_Sprites[i].GetUnzoomedHeight() ); } Index: CroppedSprite.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/CroppedSprite.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- CroppedSprite.cpp 14 Nov 2002 01:26:18 -0000 1.11 +++ CroppedSprite.cpp 30 Dec 2002 02:43:52 -0000 1.12 @@ -21,9 +21,9 @@ m_fCropWidth = m_fCropHeight = 100; } -bool CroppedSprite::Load( CString sFilePath, RageTexturePrefs prefs ) +bool CroppedSprite::Load( RageTextureID ID ) { - Sprite::Load( sFilePath, prefs ); + Sprite::Load( ID ); CropToSize( m_fCropWidth, m_fCropHeight ); return true; Index: CroppedSprite.h =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/CroppedSprite.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CroppedSprite.h 16 Nov 2002 08:07:36 -0000 1.7 +++ CroppedSprite.h 30 Dec 2002 02:43:52 -0000 1.8 @@ -21,7 +21,7 @@ CroppedSprite(); virtual ~CroppedSprite() { } - bool Load( CString sFilePath, RageTexturePrefs prefs ); + bool Load( RageTextureID ID ); void SetCroppedSize( float fWidth, float fHeight ); protected: Index: Font.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Font.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Font.cpp 29 Dec 2002 22:55:26 -0000 1.23 +++ Font.cpp 30 Dec 2002 02:43:52 -0000 1.24 @@ -38,7 +38,7 @@ // load texture m_sTexturePath = sASCIITexturePath; m_sTexturePath.MakeLower(); - m_pTexture = TEXTUREMAN->LoadTexture( m_sTexturePath, RageTexturePrefs() ); + m_pTexture = TEXTUREMAN->LoadTexture( m_sTexturePath ); ASSERT( m_pTexture != NULL ); if( m_pTexture->GetNumFrames() != 16*16 ) RageException::Throw( "The font '%s' has only %d frames. All fonts must have 16*16 frames.", m_sTexturePath.GetString() ); @@ -115,7 +115,7 @@ m_sTexturePath.MakeLower(); - m_pTexture = TEXTUREMAN->LoadTexture( m_sTexturePath, RageTexturePrefs() ); + m_pTexture = TEXTUREMAN->LoadTexture( m_sTexturePath ); ASSERT( m_pTexture != NULL ); m_iLineSpacing = m_pTexture->GetSourceFrameHeight(); Index: ScrollingList.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/ScrollingList.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ScrollingList.cpp 10 Dec 2002 23:16:44 -0000 1.9 +++ ScrollingList.cpp 30 Dec 2002 02:43:52 -0000 1.10 @@ -92,8 +92,6 @@ *************************************/ void ScrollingList::Load( const CStringArray& asGraphicPaths ) { - RageTexturePrefs prefs; - Unload(); if(m_iSpriteType == SPRITE_TYPE_SPRITE) { @@ -123,7 +121,7 @@ pNewCSprite->SetCroppedSize( EZ2_BANNER_WIDTH*2, EZ2_BANNER_HEIGHT*2 ); } - pNewCSprite->Load( asGraphicPaths[i], prefs ); + pNewCSprite->Load( asGraphicPaths[i] ); m_apCSprites.push_back( pNewCSprite ); } } Index: Sprite.cpp =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Sprite.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- Sprite.cpp 21 Dec 2002 19:32:38 -0000 1.51 +++ Sprite.cpp 30 Dec 2002 02:43:52 -0000 1.52 @@ -37,9 +37,7 @@ Sprite::~Sprite() { -// LOG->Trace( "Sprite Destructor" ); - - TEXTUREMAN->UnloadTexture( m_sTexturePath ); + UnloadTexture(); } @@ -52,13 +50,13 @@ // Delay0000=1.0 // Frame0001=3 // Delay0000=2.0 -bool Sprite::LoadFromSpriteFile( CString sSpritePath, RageTexturePrefs prefs ) +bool Sprite::LoadFromSpriteFile( RageTextureID ID ) { - LOG->Trace( ssprintf("Sprite::LoadFromSpriteFile(%s)", sSpritePath.GetString()) ); + LOG->Trace( ssprintf("Sprite::LoadFromSpriteFile(%s)", ID.filename.GetString()) ); //Init(); - m_sSpritePath = sSpritePath; + m_sSpritePath = ID.filename; // Split for the directory. We'll need it below @@ -80,14 +78,13 @@ if( sTextureFile == "" ) RageException::Throw( "Error reading value 'Texture' from %s.", m_sSpritePath.GetString() ); - CString sTexturePath = sFontDir + sTextureFile; // save the path of the new texture - - if( !DoesFileExist(sTexturePath) ) - RageException::Throw( "The sprite file '%s' points to a texture '%s' which doesn't exist.", m_sSpritePath.GetString(), sTexturePath.GetString() ); + ID.filename = sFontDir + sTextureFile; // save the path of the real texture + if( !DoesFileExist(ID.filename) ) + RageException::Throw( "The sprite file '%s' points to a texture '%s' which doesn't exist.", m_sSpritePath.GetString(), ID.filename.GetString() ); // Load the texture - LoadFromTexture( sTexturePath, prefs ); + LoadFromTexture( ID ); // Read in frames and delays from the sprite file, // overwriting the states that LoadFromTexture created. @@ -101,7 +98,7 @@ break; if( m_iStateToFrame[i] >= m_pTexture->GetNumFrames() ) RageException::Throw( "In '%s', %s is %d, but the texture %s only has %d frames.", - m_sSpritePath.GetString(), sFrameKey.GetString(), m_iStateToFrame[i], sTexturePath.GetString(), m_pTexture->GetNumFrames() ); + m_sSpritePath.GetString(), sFrameKey.GetString(), m_iStateToFrame[i], ID.filename.GetString(), m_pTexture->GetNumFrames() ); m_fDelay[i] = 0.2f; if( !ini.GetValueF( "Sprite", sDelayKey, m_fDelay[i] ) ) break; @@ -126,19 +123,16 @@ void Sprite::UnloadTexture() { if( m_pTexture != NULL ) // If there was a previous bitmap... - TEXTUREMAN->UnloadTexture( m_sTexturePath ); // Unload it. + TEXTUREMAN->UnloadTexture( m_pTexture ); // Unload it. m_pTexture = NULL; - m_sTexturePath = ""; } -bool Sprite::LoadFromTexture( CString sTexturePath, RageTexturePrefs prefs ) +bool Sprite::LoadFromTexture( RageTextureID ID ) { UnloadTexture(); - m_sTexturePath = sTexturePath; - - m_pTexture = TEXTUREMAN->LoadTexture( m_sTexturePath, prefs ); - assert( m_pTexture != NULL ); + m_pTexture = TEXTUREMAN->LoadTexture( ID ); + ASSERT( m_pTexture != NULL ); // the size of the sprite is the size of the image before it was scaled Sprite::m_size.x = (float)m_pTexture->GetSourceFrameWidth(); Index: Sprite.h =================================================================== RCS file: /cvsroot/stepmania/stepmania/src/Sprite.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Sprite.h 17 Dec 2002 10:39:09 -0000 1.23 +++ Sprite.h 30 Dec 2002 02:43:52 -0000 1.24 @@ -28,14 +28,22 @@ Sprite(); virtual ~Sprite(); - virtual bool Load( CString sFilePath ) { return Load( sFilePath, RageTexturePrefs() ); } - virtual bool Load( CString sFilePath, RageTexturePrefs prefs ) + /* Just a convenience function; load an image that'll be used in the + * background. */ + virtual bool LoadBG( RageTextureID ID ) { - ASSERT( sFilePath != "" ); - if( sFilePath.Right(7) == ".sprite" ) - return LoadFromSpriteFile( sFilePath, prefs ); + ID.iMipMaps = 1; + ID.bDither = true; + return Load(ID); + } + + virtual bool Load( RageTextureID ID ) + { + ASSERT( ID.filename != "" ); + if( ID.filename.Right(7) == ".sprite" ) + return LoadFromSpriteFile( ID ); else - return LoadFromTexture( sFilePath, prefs ); + return LoadFromTexture( ID ); }; void UnloadTexture(); RageTexture* GetTexture() { return m_pTexture; }; @@ -48,8 +56,7 @@ virtual void SetState( int iNewState ); int GetNumStates() { return m_iNumStates; }; - CString GetTexturePath() { return m_sTexturePath; }; - + CString GetTexturePath() { ASSERT(m_pTexture); return m_pTexture->GetID().filename; }; void SetCustomTextureRect( const RectF &new_texcoord_frect ); void SetCustomTextureCoords( float fTexCoords[8] ); @@ -60,14 +67,13 @@ void StopUsingCustomCoords(); protected: - virtual bool LoadFromTexture( CString sTexturePath, RageTexturePrefs prefs ); - virtual bool LoadFromSpriteFile( CString sSpritePath, RageTexturePrefs prefs ); + virtual bool LoadFromTexture( RageTextureID ID ); + virtual bool LoadFromSpriteFile( RageTextureID ID ); CString m_sSpritePath; RageTexture* m_pTexture; bool m_bDrawIfTextureNull; - CString m_sTexturePath; int m_iStateToFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames float m_fDelay[MAX_SPRITE_STATES]; |