Rewrote texture loading actor and sprite

This commit is contained in:
Chris Danford
2001-11-25 04:31:44 +00:00
parent c52c818881
commit c679ec7956
24 changed files with 511 additions and 446 deletions
+8 -8
View File
@@ -125,21 +125,21 @@ void Actor::SetTweenColor( D3DXCOLOR c ) { m_end_color = c; }
void Actor::ScaleTo( LPRECT pRect, StretchType st ) void Actor::ScaleTo( LPRECT pRect, StretchType st )
{ {
// width and height of rectangle // width and height of rectangle
int rect_width = RECTWIDTH(*pRect); float rect_width = RECTWIDTH(*pRect);
int rect_height = RECTHEIGHT(*pRect); float rect_height = RECTHEIGHT(*pRect);
// center of the rectangle // center of the rectangle
int rect_cx = pRect->left + rect_width/2; float rect_cx = pRect->left + rect_width/2;
int rect_cy = pRect->top + rect_height/2; float rect_cy = pRect->top + rect_height/2;
// zoom factor needed to scale the Actor to fill the rectangle // zoom factor needed to scale the Actor to fill the rectangle
FLOAT fNewZoomX = (FLOAT)fabs(rect_width / m_size.x); float fNewZoomX = (float)fabs(rect_width / m_size.x);
FLOAT fNewZoomY = (FLOAT)fabs(rect_height / m_size.y); float fNewZoomY = (float)fabs(rect_height / m_size.y);
if( rect_width < 0 ) SetRotationY( D3DX_PI ); if( rect_width < 0 ) SetRotationY( D3DX_PI );
if( rect_height < 0 ) SetRotationX( D3DX_PI ); if( rect_height < 0 ) SetRotationX( D3DX_PI );
FLOAT fNewZoom; float fNewZoom;
switch( st ) switch( st )
{ {
case cover: case cover:
@@ -150,7 +150,7 @@ void Actor::ScaleTo( LPRECT pRect, StretchType st )
break; break;
} }
SetXY( (FLOAT)rect_cx, (FLOAT)rect_cy ); SetXY( rect_cx, rect_cy );
SetZoom( fNewZoom ); SetZoom( fNewZoom );
} }
+36 -36
View File
@@ -31,56 +31,56 @@ public:
virtual void Invalidate() {}; virtual void Invalidate() {};
virtual void Draw() PURE; virtual void Draw() PURE;
virtual void Update( const FLOAT &fDeltaTime ); virtual void Update( const float &fDeltaTime );
virtual FLOAT GetX() { return m_pos.x; }; virtual float GetX() { return m_pos.x; };
virtual FLOAT GetY() { return m_pos.y; }; virtual float GetY() { return m_pos.y; };
virtual void SetX( FLOAT x ) { m_pos.x = x; m_TweenType = no_tween; }; virtual void SetX( float x ) { m_pos.x = x; m_TweenType = no_tween; };
virtual void SetY( FLOAT y ) { m_pos.y = y; m_TweenType = no_tween; }; virtual void SetY( float y ) { m_pos.y = y; m_TweenType = no_tween; };
virtual void SetXY( FLOAT x, FLOAT y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; }; virtual void SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; };
// height and width vary depending on zoom // height and width vary depending on zoom
virtual FLOAT GetZoomedWidth() { return m_size.x * m_scale.x; } virtual float GetZoomedWidth() { return m_size.x * m_scale.x; }
virtual FLOAT GetZoomedHeight() { return m_size.y * m_scale.y; } virtual float GetZoomedHeight() { return m_size.y * m_scale.y; }
virtual void SetWidth( FLOAT width ){ m_size.x = width; } virtual void SetWidth( float width ){ m_size.x = width; }
virtual void SetHeight( FLOAT height ){ m_size.y = height; } virtual void SetHeight( float height ){ m_size.y = height; }
virtual FLOAT GetZoom() { return m_scale.x; } virtual float GetZoom() { return m_scale.x; }
virtual void SetZoom( FLOAT zoom ) { m_scale.x = zoom; m_scale.y = zoom; } virtual void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; }
virtual FLOAT GetRotation() { return m_rotation.z; } virtual float GetRotation() { return m_rotation.z; }
virtual void SetRotation( FLOAT rot ) { m_rotation.z = rot; } virtual void SetRotation( float rot ) { m_rotation.z = rot; }
virtual FLOAT GetRotationX() { return m_rotation.x; } virtual float GetRotationX() { return m_rotation.x; }
virtual void SetRotationX( FLOAT rot ) { m_rotation.x = rot; } virtual void SetRotationX( float rot ) { m_rotation.x = rot; }
virtual FLOAT GetRotationY() { return m_rotation.y; } virtual float GetRotationY() { return m_rotation.y; }
virtual void SetRotationY( FLOAT rot ) { m_rotation.y = rot; } virtual void SetRotationY( float rot ) { m_rotation.y = rot; }
virtual void SetColor( D3DXCOLOR newColor ) { m_color = newColor; }; virtual void SetColor( D3DXCOLOR newColor ) { m_color = newColor; };
virtual D3DXCOLOR GetColor() { return m_color; }; virtual D3DXCOLOR GetColor() { return m_color; };
virtual void TweenTo( FLOAT time, virtual void TweenTo( float time,
FLOAT x, FLOAT y, float x, float y,
FLOAT zoom = 1.0, float zoom = 1.0,
FLOAT rot = 0.0, float rot = 0.0,
D3DXCOLOR col = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ), D3DXCOLOR col = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ),
TweenType tt = tween_linear ); TweenType tt = tween_linear );
virtual void BeginTweening( FLOAT time, TweenType tt = tween_linear ); virtual void BeginTweening( float time, TweenType tt = tween_linear );
virtual void SetTweenX( FLOAT x ); virtual void SetTweenX( float x );
virtual void SetTweenY( FLOAT y ); virtual void SetTweenY( float y );
virtual void SetTweenXY( FLOAT x, FLOAT y ); virtual void SetTweenXY( float x, float y );
virtual void SetTweenZoom( FLOAT zoom ); virtual void SetTweenZoom( float zoom );
virtual void SetTweenRotationX( FLOAT r ); virtual void SetTweenRotationX( float r );
virtual void SetTweenRotationY( FLOAT r ); virtual void SetTweenRotationY( float r );
virtual void SetTweenRotationZ( FLOAT r ); virtual void SetTweenRotationZ( float r );
virtual void SetTweenColor( D3DXCOLOR c ); virtual void SetTweenColor( D3DXCOLOR c );
// NOTE: GetEdge functions don't consider rotation // NOTE: GetEdge functions don't consider rotation
virtual FLOAT GetLeftEdge() { return m_pos.x - GetZoomedWidth()/2.0f; }; virtual float GetLeftEdge() { return m_pos.x - GetZoomedWidth()/2.0f; };
virtual FLOAT GetRightEdge() { return m_pos.x + GetZoomedWidth()/2.0f; }; virtual float GetRightEdge() { return m_pos.x + GetZoomedWidth()/2.0f; };
virtual FLOAT GetTopEdge() { return m_pos.y - GetZoomedHeight()/2.0f; }; virtual float GetTopEdge() { return m_pos.y - GetZoomedHeight()/2.0f; };
virtual FLOAT GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; }; virtual float GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; };
enum StretchType { fit_inside, cover }; enum StretchType { fit_inside, cover };
@@ -108,8 +108,8 @@ protected:
// counters for tweening // counters for tweening
TweenType m_TweenType; TweenType m_TweenType;
FLOAT m_fTweenTime; // seconds between Start and End positions/zooms float m_fTweenTime; // seconds between Start and End positions/zooms
FLOAT m_fTimeIntoTween; // how long we have been tweening for float m_fTimeIntoTween; // how long we have been tweening for
}; };
+1 -1
View File
@@ -30,7 +30,7 @@ void Background::LoadFromSong( Song& song )
m_sprVis.LoadFromTexture( sVisDir + sVisualizationPaths[iIndexRandom] ); m_sprVis.LoadFromTexture( sVisDir + sVisualizationPaths[iIndexRandom] );
m_sprVis.StretchTo( CRect(0,0,640,480) ); m_sprVis.StretchTo( CRect(0,0,640,480) );
m_sprVis.SetBlendMode( TRUE ); // m_sprVis.SetBlendMode( TRUE );
//m_sprVis.SetColor( D3DXCOLOR(1,1,1,0.5f) ); //m_sprVis.SetColor( D3DXCOLOR(1,1,1,0.5f) );
} }
} }
+32 -34
View File
@@ -15,53 +15,51 @@
BOOL Banner::LoadFromSong( Song &song ) bool Banner::LoadFromSong( Song &song )
{ {
BOOL bResult = Sprite::LoadFromTexture( song.GetBannerPath() ); Sprite::LoadFromTexture( song.GetBannerPath() );
if( bResult )
{
int iImageWidth = this->GetZoomedWidth();
int iImageHeight = this->GetZoomedHeight();
int iCorrectedBannerWidth = BANNER_WIDTH / m_pTexture->GetWidthCorrectionRatio(); float fSourceWidth = (float)m_pTexture->GetSourceWidth();
int iCorrectedBannerHeight = BANNER_HEIGHT / m_pTexture->GetHeightCorrectionRatio(); float fSourceHeight = (float)m_pTexture->GetSourceHeight();
// first find the correct zoom // first find the correct zoom
Sprite::ScaleToCover( CRect(0, 0, Sprite::ScaleToCover( CRect(0, 0,
iCorrectedBannerWidth, BANNER_WIDTH,
iCorrectedBannerHeight ) BANNER_HEIGHT )
); );
float fFinalZoom = this->GetZoom();
FLOAT fFinalZoom = this->GetZoom();
// find which dimension is larger // find which dimension is larger
BOOL bYDimIsLarger = this->GetZoomedHeight() > iCorrectedBannerHeight; bool bXDimNeedsToBeCropped = GetZoomedWidth() > BANNER_WIDTH;
// BOOL bYDimIsLarger = this->GetZoomedHeight() > BANNER_HEIGHT;
// now crop it if( bXDimNeedsToBeCropped ) // crop X
if( !bYDimIsLarger ) // crop X
{ {
int iScreenPixelsToCrop = (this->GetZoomedWidth() - iCorrectedBannerWidth) / 2; float fPercentageToCutOff = (this->GetZoomedWidth() - BANNER_WIDTH) / this->GetZoomedWidth();
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom ); float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
RECT rectNewSrc;
::SetRect( &rectNewSrc, iImagePixelsToCrop, // generate a rectangle with new texture coordinates
FRECT frectNewSrc( fPercentageToCutOffEachSide,
0, 0,
iImageWidth - iImagePixelsToCrop, 1 - fPercentageToCutOffEachSide,
iImageHeight ); 1 );
Sprite::SetCustomSrcRect( rectNewSrc ); Sprite::SetCustomSrcRect( frectNewSrc );
} }
else // crop Y else // crop Y
{ {
int iScreenPixelsToCrop = (this->GetZoomedHeight() - iCorrectedBannerHeight) / 2; float fPercentageToCutOff = (this->GetZoomedHeight() - BANNER_HEIGHT) / this->GetZoomedHeight();
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom ); float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
RECT rectNewSrc;
::SetRect( &rectNewSrc, 0,
iImagePixelsToCrop,
iImageWidth,
iImageHeight - iImagePixelsToCrop );
Sprite::SetCustomSrcRect( rectNewSrc );
}
}
return TRUE; // generate a rectangle with new texture coordinates
FRECT frectNewSrc( 0,
fPercentageToCutOffEachSide,
1,
1 - fPercentageToCutOffEachSide );
Sprite::SetCustomSrcRect( frectNewSrc );
}
SetWidth( BANNER_WIDTH );
SetHeight( BANNER_HEIGHT );
SetZoom( 1 );
return true;
} }
+3 -6
View File
@@ -16,18 +16,15 @@
#include "Song.h" #include "Song.h"
#define COMMON_BANNER_TEXTURE_WIDTH 384 const float BANNER_WIDTH = 192; // from the source art of DDR
#define COMMON_BANNER_TEXTURE_HEIGHT 110 const float BANNER_HEIGHT = 55;
#define BANNER_WIDTH (COMMON_BANNER_TEXTURE_WIDTH/2)
#define BANNER_HEIGHT (COMMON_BANNER_TEXTURE_HEIGHT / 2)
class Banner : public Sprite class Banner : public Sprite
{ {
public: public:
BOOL LoadFromSong( Song &song); bool LoadFromSong( Song &song);
}; };
+42 -71
View File
@@ -17,97 +17,68 @@
BitmapText::BitmapText() BitmapText::BitmapText()
{ {
m_pFont = NULL;
m_colorTop = D3DXCOLOR(1,1,1,1);
m_colorBottom = D3DXCOLOR(1,1,1,1);
} }
BitmapText::~BitmapText()
BOOL BitmapText::LoadFromFontFile( CString sFontFilePath )
{ {
RageLog( "BitmapText::LoadFromFontFile(%s)", sFontFilePath ); delete m_pFont;
}
m_sFontFilePath = sFontFilePath; bool BitmapText::LoadFromFontName( CString sFontName )
{
RageLog( "BitmapText::LoadFromFontName(%s)", sFontName );
// read font file SAFE_DELETE( m_pFont ); // delete old font (if any)
IniFile ini;
ini.SetPath( m_sFontFilePath );
if( !ini.ReadFile() )
RageError( ssprintf("Error opening Font file: %s.", m_sFontFilePath) );
CString sTexturePath = ini.GetValue( "Font", "Texture" ); m_sFontName = sFontName; // save font name
if( sTexturePath == "" )
RageError( ssprintf("Error reading value 'Texture' from %s.", m_sFontFilePath) );
this->LoadFromTexture( sTexturePath ); m_pFont= new CBitmapFont( SCREEN->GetD3D(), SCREEN->GetDevice() );
m_pFont->Load( BL_BITMAP, ssprintf("Fonts/%s.png",sFontName) );
// fill in our map from characters to frame no m_pFont->Load( BL_SIZES, ssprintf("Fonts/%s.dat",sFontName) );
CString sCharacters = ini.GetValue( "Font", "Characters" );
if( sCharacters == "" )
RageError( ssprintf("Error reading value 'Characters' from %s.", m_sFontFilePath) );
for( int i=0; i<sCharacters.GetLength(); i++ )
{
TCHAR c = sCharacters[i];
m_mapCharToFrameNo[c] = i;
}
// Validate that the number of characters we read in is the same as
// the number of frames in the texture.
if( sCharacters.GetLength() != (int)this->GetNumStates() )
RageError( ssprintf("The Font %s specifies %d characters, but the Texture has %d frames.",
m_sFontFilePath, sCharacters.GetLength(), (int)this->GetNumStates()) );
ResetWidthAndHeight();
return TRUE; return TRUE;
} }
void BitmapText::SetText( CString sText )
{
m_sText = sText;
ResetWidthAndHeight();
}
void BitmapText::Draw() void BitmapText::Draw()
{ {
//RageLog( "BitmapText::Draw()" ); RECT rect = m_pFont->GetTextRect(m_sText, 0, 0);
// UGLY!!!! float text_width = RECTWIDTH( rect );
float text_height = RECTHEIGHT( rect );
TCHAR c;
UINT uFrameNo;
int iNumChars = m_sText.GetLength();
int iLeftEdge = this->GetLeftEdge();
int iOriginalCenterX = (int)this->GetX();
FLOAT fOriginalWidth = m_size.x;
int iFrameWidth = (int)( m_pTexture->GetImageFrameWidth() * this->GetZoom() ); LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice();
m_size.x = (FLOAT)iFrameWidth;
// draw each character in the string // calculate transforms
for( int i=0; i<iNumChars; i++ ) D3DXMATRIX matWorld, matTemp;
{ D3DXMatrixIdentity( &matWorld ); // initialize world
c = m_sText[i]; //D3DXMatrixScaling( &matTemp, m_size.x, m_size.y, 1 ); // scale to the native height and width
//matWorld *= matTemp;
D3DXMatrixScaling( &matTemp, m_scale.x, m_scale.y, 1 ); // add in the zoom
matWorld *= matTemp;
D3DXMatrixRotationYawPitchRoll( &matTemp, m_rotation.y, m_rotation.x, m_rotation.z ); // add in the rotation
matWorld *= matTemp;
D3DXMatrixTranslation( &matTemp, m_pos.x, m_pos.y, 0 ); // add in the translation
matWorld *= matTemp;
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
// Get what frame in the animation this character is. D3DXMATRIX matView;
if( !m_mapCharToFrameNo.Lookup(c, uFrameNo) ) D3DXMatrixIdentity( &matView );
uFrameNo = 0; pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
this->SetState( uFrameNo ); D3DXMATRIX matProj;
this->SetX( (int)(iLeftEdge + iFrameWidth*(i+0.5f)) ); D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -100, 100 );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
Sprite::Draw(); m_pFont->BeginDraw();
} m_pFont->DrawTextEx(m_sText, -text_width/2, -text_height/2, m_colorTop, m_colorBottom, 1.0f);
//m_pFont->DrawTextEx("Cool Effects!", 50, 80, 0xffffff00, 0xffff0000, 2.0f);
//m_pFont->DrawTextEx("Cool Effects!", 50, 120, 0x1100ffff, 0x8800ffff, 2.0f);
m_pFont->EndDraw();
///////////////////////////////////////////////////////////////////////////////
this->SetX( iOriginalCenterX );
m_size.x = fOriginalWidth;
} }
void BitmapText::ResetWidthAndHeight()
{
m_size.x = (FLOAT)m_pTexture->GetImageFrameWidth() * m_sText.GetLength();
m_size.y = (FLOAT)m_pTexture->GetImageFrameHeight();
}
+13 -9
View File
@@ -16,28 +16,32 @@
#include "Sprite.h" #include "Sprite.h"
#include "BitmapText.h" #include "BitmapText.h"
#include "BitmapFont.h"
class BitmapText : public Sprite class BitmapText : public Actor
{ {
public: public:
BitmapText(); BitmapText();
// virtual ~BitmapText(); ~BitmapText();
BOOL LoadFromFontFile( CString sFontFilePath ); bool LoadFromFontName( CString sFontName );
void SetText( CString sText ); void SetText( CString sText ) { m_sText = sText; };
CString GetText() { return m_sText; }; CString GetText() { return m_sText; };
void SetTopColor( D3DXCOLOR new_color ) { m_colorTop = new_color; };
void SetBottomColor( D3DXCOLOR new_color ) { m_colorBottom = new_color; };
void SetColor( D3DXCOLOR new_color ) { SetTopColor(new_color); SetBottomColor(new_color); };
virtual void Draw(); virtual void Draw();
protected: protected:
void ResetWidthAndHeight(); CString m_sFontName;
CBitmapFont* m_pFont;
CString m_sFontFilePath;
CString m_sText; // the string that the font is displaying CString m_sText; // the string that the font is displaying
//Sprite m_Sprite; // holder for the graphic D3DXCOLOR m_colorTop;
CMap<TCHAR, TCHAR&, UINT, UINT&> m_mapCharToFrameNo; D3DXCOLOR m_colorBottom;
}; };
+5 -5
View File
@@ -126,17 +126,17 @@ int IniFile::GetNumKeys()
return keys.GetSize(); return keys.GetSize();
} }
//returns a refernce to the key for direct modification //returns a pointer to the key for direct modification
CMapStringToString& IniFile::GetKeyRef( CString keyname ) CMapStringToString* IniFile::GetKeyPointer( CString keyname )
{ {
int keynum = FindKey(keyname); int keynum = FindKey(keyname);
if (keynum == -1) if (keynum == -1)
return keys[0]; return NULL;
else else
return keys[keynum]; return &keys[keynum];
} }
//returns number of values stored for specified key, or -1 if key found //returns number of values stored for specified key, or -1 if key not found
int IniFile::GetNumValues(CString keyname) int IniFile::GetNumValues(CString keyname)
{ {
int keynum = FindKey(keyname); int keynum = FindKey(keyname);
+2 -2
View File
@@ -79,8 +79,8 @@ public:
//returns number of keys currently in the ini //returns number of keys currently in the ini
int GetNumKeys(); int GetNumKeys();
//returns a refernce to the key for direct modification //returns a pointer to the key for direct modification
CMapStringToString& GetKeyRef( CString keyname ); CMapStringToString* GetKeyPointer( CString keyname );
//returns number of values stored for specified key //returns number of values stored for specified key
int GetNumValues( CString keyname ); int GetNumValues( CString keyname );
+2 -2
View File
@@ -201,7 +201,7 @@ Player::Player()
// combo // combo
m_bComboVisible = FALSE; m_bComboVisible = FALSE;
m_sprCombo.LoadFromSpriteFile( COMBO_SPRITE ); m_sprCombo.LoadFromSpriteFile( COMBO_SPRITE );
m_textComboNum.LoadFromFontFile( FONT_COMBO ); m_textComboNum.LoadFromFontName( "Arial Bold" );
m_textComboNum.SetText( "" ); m_textComboNum.SetText( "" );
// life meter // life meter
@@ -210,7 +210,7 @@ Player::Player()
// score // score
m_sprScoreFrame.LoadFromTexture( SCORE_FRAME_TEXTURE ); m_sprScoreFrame.LoadFromTexture( SCORE_FRAME_TEXTURE );
m_textScoreNum.LoadFromFontFile( FONT_SCORE ); m_textScoreNum.LoadFromFontName( "Arial Bold" );
m_textScoreNum.SetText( " " ); m_textScoreNum.SetText( " " );
+10 -32
View File
@@ -61,26 +61,6 @@ VOID RageBitmapTexture::Create()
D3DXIMAGE_INFO ddii; D3DXIMAGE_INFO ddii;
// get image information
D3DXIMAGE_INFO info;
if( FAILED( hr = D3DXGetImageInfoFromFile(m_sFilePath,&info) ) ) {
RageErrorHr( ssprintf("D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath), hr );
}
D3DCAPS8 devCaps;
m_pd3dDevice->GetDeviceCaps( &devCaps );
// check to see if the image will fit or if it needs to be scaled to 256
DWORD filterType = D3DX_FILTER_NONE;
RageLog( "info.Width = %d, info.Height = %d, devCaps.MaxTextureWidth = %d, devCaps.MaxTextureHeight = %d",
info.Width, info.Height, devCaps.MaxTextureWidth, devCaps.MaxTextureHeight );
if( info.Width > devCaps.MaxTextureWidth ||
info.Height > devCaps.MaxTextureHeight )
{
filterType = D3DX_DEFAULT;
}
// load texture // load texture
if (FAILED (hr = D3DXCreateTextureFromFileEx( if (FAILED (hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, m_pd3dDevice,
@@ -88,34 +68,32 @@ VOID RageBitmapTexture::Create()
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, D3DX_DEFAULT,
0, 0,
D3DFMT_A4R4G4B4, //D3DFMT_UNKNOWN, // get format from source D3DFMT_A4R4G4B4, // this is our preferred format
D3DPOOL_MANAGED, D3DPOOL_MANAGED,
filterType, // don't blow up the image to the texure size D3DX_DEFAULT,
filterType, D3DX_DEFAULT,
0, // no color key 0, // no color key
&ddii, &ddii,
NULL, // no palette NULL, // no palette
&m_pd3dTexture ) ) ) &m_pd3dTexture ) ) )
RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr ); RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr );
// save the source image's width and height
m_uSourceWidth = ddii.Width;
m_uSourceHeight= ddii.Height;
m_uImageWidth = ddii.Width;
m_uImageHeight= ddii.Height; //RageLog( "info.Width = %d, info.Height = %d, devCaps.MaxTextureWidth = %d, devCaps.MaxTextureHeight = %d",
// info.Width, info.Height, devCaps.MaxTextureWidth, devCaps.MaxTextureHeight );
// D3DXCreateTexture can silently change the parameters on us
D3DSURFACE_DESC ddsd; D3DSURFACE_DESC ddsd;
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) ) if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
RageErrorHr( "Could not get level Description of D3DX texture!", hr ); RageErrorHr( "Could not get level Description of D3DX texture!", hr );
// save information about the texture
m_uTextureWidth = ddsd.Width; m_uTextureWidth = ddsd.Width;
m_uTextureHeight = ddsd.Height; m_uTextureHeight = ddsd.Height;
m_TextureFormat = ddsd.Format; m_TextureFormat = ddsd.Format;
// if (m_TextureFormat != D3DFMT_A8R8G8B8 &&
// m_TextureFormat != D3DFMT_A1R5G5B5) {
// DXTRACE_ERR(TEXT("Texture is format we can't handle! Format = 0x%x"), m_TextureFormat);
// return E_FAIL;
// }
} }
+10 -10
View File
@@ -21,15 +21,15 @@
// Includes // Includes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <windows.h> #include <windows.h>
#include <dinput.h>
#include "RageInput.h" #include "RageInput.h"
#include <dinput.h>
#include "RageUtil.h" #include "RageUtil.h"
LPRageInput INPUT = NULL; LPRageInput INPUT = NULL;
BOOL RageRawInput::LookupChar( TCHAR &char_out ) const BOOL DeviceInput::LookupChar( TCHAR &char_out ) const
{ {
switch( button ) switch( button )
{ {
@@ -103,7 +103,7 @@ BOOL RageRawInput::LookupChar( TCHAR &char_out ) const
} }
CString RageRawInput::GetDescription() const CString DeviceInput::GetDescription() const
{ {
CString sReturn; CString sReturn;
@@ -486,7 +486,7 @@ VOID RageInput::Release()
} }
HRESULT RageInput::GetRawInput( RageRawInputList &listRawInput ) HRESULT RageInput::GetDeviceInputs( DeviceInputArray &listDeviceInputs )
{ {
// macros for reading DI state structures // macros for reading DI state structures
#define IS_PRESSED(b) (b & 0x80) #define IS_PRESSED(b) (b & 0x80)
@@ -536,7 +536,7 @@ HRESULT RageInput::GetRawInput( RageRawInputList &listRawInput )
{ {
// check if key is depressed this update and was not depressed last update // check if key is depressed this update and was not depressed last update
if( IS_PRESSED( m_keys[k] ) && !IS_PRESSED( m_oldKeys[k] ) ) if( IS_PRESSED( m_keys[k] ) && !IS_PRESSED( m_oldKeys[k] ) )
listRawInput.AddTail( RageRawInput( DEVICE_KEYBOARD, 1, k, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_KEYBOARD, 1, k, FALSE ) );
} }
@@ -618,25 +618,25 @@ HRESULT RageInput::GetRawInput( RageRawInputList &listRawInput )
// check if key is depressed this update and was not depressed last update // check if key is depressed this update and was not depressed last update
if( IS_LEFT( m_joyState[i].lX ) && if( IS_LEFT( m_joyState[i].lX ) &&
!IS_LEFT( m_oldJoyState[i].lX ) ) !IS_LEFT( m_oldJoyState[i].lX ) )
listRawInput.AddTail( RageRawInput( DEVICE_JOYSTICK, i+1, JOY_LEFT, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_JOYSTICK, i+1, JOY_LEFT, FALSE ) );
if( IS_RIGHT( m_joyState[i].lX ) && if( IS_RIGHT( m_joyState[i].lX ) &&
!IS_RIGHT( m_oldJoyState[i].lX ) ) !IS_RIGHT( m_oldJoyState[i].lX ) )
listRawInput.AddTail( RageRawInput( DEVICE_JOYSTICK, i+1, JOY_RIGHT, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_JOYSTICK, i+1, JOY_RIGHT, FALSE ) );
if( IS_UP( m_joyState[i].lY ) && if( IS_UP( m_joyState[i].lY ) &&
!IS_UP( m_oldJoyState[i].lY ) ) !IS_UP( m_oldJoyState[i].lY ) )
listRawInput.AddTail( RageRawInput( DEVICE_JOYSTICK, i+1, JOY_UP, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_JOYSTICK, i+1, JOY_UP, FALSE ) );
if( IS_DOWN( m_joyState[i].lY ) && if( IS_DOWN( m_joyState[i].lY ) &&
!IS_DOWN( m_oldJoyState[i].lY ) ) !IS_DOWN( m_oldJoyState[i].lY ) )
listRawInput.AddTail( RageRawInput( DEVICE_JOYSTICK, i+1, JOY_DOWN, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_JOYSTICK, i+1, JOY_DOWN, FALSE ) );
for( BYTE b=0; b<10; b++ ) for( BYTE b=0; b<10; b++ )
{ {
if( IS_PRESSED(m_joyState[i].rgbButtons[b]) && !IS_PRESSED(m_oldJoyState[i].rgbButtons[b]) ) if( IS_PRESSED(m_joyState[i].rgbButtons[b]) && !IS_PRESSED(m_oldJoyState[i].rgbButtons[b]) )
listRawInput.AddTail( RageRawInput( DEVICE_JOYSTICK, i+1, b+1, FALSE ) ); listDeviceInputs.Add( DeviceInput( DEVICE_JOYSTICK, i+1, b+1, FALSE ) );
} }
} }
} }
+11 -9
View File
@@ -20,7 +20,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#define NUM_JOYSTICKS 4 const int NUM_JOYSTICKS = 4;
// button byte codes for directional pad // button byte codes for directional pad
#define JOY_LEFT 101 #define JOY_LEFT 101
@@ -35,11 +35,11 @@
#define DEVICE_JOYSTICK 2 #define DEVICE_JOYSTICK 2
class RageRawInput class DeviceInput
{ {
public: public:
RageRawInput() { device = device_no = button = just_pressed = 0; }; DeviceInput() { device = device_no = button = just_pressed = 0; };
RageRawInput( BYTE device, DeviceInput( BYTE device,
BYTE device_no, BYTE device_no,
BYTE button, BYTE button,
BYTE just_pressed ) BYTE just_pressed )
@@ -49,20 +49,22 @@ public:
this->button = button; this->button = button;
this->just_pressed = just_pressed; this->just_pressed = just_pressed;
}; };
RageRawInput( CString sEncoding )
CString GetEncoding() const { return ssprintf("%u-%u-%u", device, device_no, button); };
void FillFromEncoding( CString sEncoding )
{ {
CStringArray a; CStringArray a;
split( sEncoding, "-", a); split( sEncoding, "-", a);
ASSERT( a.GetSize() == 3 );
this->device = atoi( a[0] ); this->device = atoi( a[0] );
this->device_no = atoi( a[1] ); this->device_no = atoi( a[1] );
this->button = atoi( a[2] ); this->button = atoi( a[2] );
}; };
CString Encode() { return ssprintf("%u-%u-%u", device, device_no, button); };
BOOL LookupChar( TCHAR &char_out ) const; BOOL LookupChar( TCHAR &char_out ) const;
CString GetDescription() const; CString GetDescription() const;
BOOL IsBlank() { return device == DEVICE_NONE; }; bool IsBlank() const { return device == DEVICE_NONE; };
BYTE device; BYTE device;
BYTE device_no; BYTE device_no;
@@ -72,7 +74,7 @@ public:
typedef CList<RageRawInput, RageRawInput&> RageRawInputList; typedef CArray<DeviceInput, DeviceInput&> DeviceInputArray;
class RageInput class RageInput
@@ -118,7 +120,7 @@ public:
// Release all DirectInput Resources // Release all DirectInput Resources
VOID Release(); VOID Release();
// Get our Devices State // Get our Devices State
HRESULT GetRawInput( RageRawInputList &listRawInput ); HRESULT GetDeviceInputs( DeviceInputArray &listDeviceInputs );
LPDIRECTINPUT8 GetDirectInput() { return m_pDI; } LPDIRECTINPUT8 GetDirectInput() { return m_pDI; }
LPDIRECTINPUTDEVICE8 GetMouseDevice() { return m_pMouse; } LPDIRECTINPUTDEVICE8 GetMouseDevice() { return m_pMouse; }
+5 -4
View File
@@ -344,9 +344,10 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer()
m_pGB.QueryInterface(&m_pMP); m_pGB.QueryInterface(&m_pMP);
m_pGB.QueryInterface(&m_pME); m_pGB.QueryInterface(&m_pME);
// The graph is built, now get the set the output video width and height // The graph is built, now get the set the output video width and height.
m_uImageWidth = m_pCTR->GetVidWidth(); // The source and image width will always be the same since we can't scale the video
m_uImageHeight = m_pCTR->GetVidHeight(); m_uSourceWidth = m_pCTR->GetVidWidth();
m_uSourceHeight = m_pCTR->GetVidHeight();
return S_OK; return S_OK;
@@ -360,7 +361,7 @@ HRESULT RageMovieTexture::CreateD3DTexture()
// Create the texture that maps to this media type // Create the texture that maps to this media type
////////////////////////////////////////////////// //////////////////////////////////////////////////
if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice, if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice,
m_uImageWidth, m_uImageHeight, m_uSourceHeight, m_uSourceHeight,
1, 0, 1, 0,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture ) ) ) D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture ) ) )
RageErrorHr( "Could not create the D3DX texture!", hr ); RageErrorHr( "Could not create the D3DX texture!", hr );
+24 -45
View File
@@ -21,18 +21,14 @@
// RageTexture constructor // RageTexture constructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) : RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
m_uImageWidth( 0 ), m_uSourceWidth( 0 ),
m_uImageHeight( 0 ), m_uSourceHeight( 0 ),
m_uTextureWidth( 0 ), m_uTextureWidth( 0 ),
m_uTextureHeight( 0 ), m_uTextureHeight( 0 ),
m_uFramesWide( 1 ), m_uFramesWide( 1 ),
m_uFramesHigh( 1 ), m_uFramesHigh( 1 ),
m_uImageFrameWidth( 0 ), m_uSourceFrameWidth( 0 ),
m_uImageFrameHeight( 0 ), m_uSourceFrameHeight( 0 )
m_uTextureFrameWidth( 0 ),
m_uTextureFrameHeight( 0 ),
m_fWidthCorrectionRatio( 1 ),
m_fHeightCorrectionRatio( 1 )
{ {
// RageLog( "RageTexture::RageTexture()" ); // RageLog( "RageTexture::RageTexture()" );
@@ -56,48 +52,31 @@ RageTexture::~RageTexture()
VOID RageTexture::CreateFrameRects() VOID RageTexture::CreateFrameRects()
{ {
GetFrameDimensionsFromFileName( m_sFilePath, m_uFramesWide, m_uFramesHigh ); GetFrameDimensionsFromFileName( m_sFilePath, &m_uFramesWide, &m_uFramesHigh );
m_uSourceFrameWidth = GetSourceWidth() / m_uFramesWide;
m_uSourceFrameHeight = GetSourceHeight() / m_uFramesHigh;
/////////////////////////////////// ///////////////////////////////////
// Fill in the m_FrameRects with the bounds of each frame in the animation. // Fill in the m_FrameRects with the bounds of each frame in the animation.
/////////////////////////////////// ///////////////////////////////////
for( UINT j=0; j<m_uFramesHigh; j++ ) // traverse along Y
bool bTextureWasScaled = GetImageWidth() > GetTextureWidth() ||
GetImageHeight() > GetTextureHeight();
// calculate the width and height of the frames
if( bTextureWasScaled ) {
m_uTextureFrameWidth = GetTextureWidth() / m_uFramesWide;
m_uTextureFrameHeight= GetTextureHeight() / m_uFramesHigh;
m_fWidthCorrectionRatio = GetImageWidth()/(float)GetTextureWidth();
m_fHeightCorrectionRatio = GetImageHeight()/(float)GetTextureHeight();
} else {
m_uTextureFrameWidth = GetImageWidth() / m_uFramesWide;
m_uTextureFrameHeight= GetImageHeight() / m_uFramesHigh;
m_fWidthCorrectionRatio = 1;
m_fHeightCorrectionRatio = 1;
}
m_uImageFrameWidth = GetImageWidth() / m_uFramesWide;
m_uImageFrameHeight= GetImageHeight() / m_uFramesHigh;
for( UINT j=0; j<m_uFramesHigh; j++ )
{ {
for( UINT i=0; i<m_uFramesWide; i++ ) for( UINT i=0; i<m_uFramesWide; i++ ) // traverse along X (important that this is the inner loop)
{ {
RECT rectCurFrame; FRECT frect( (i+0)/(float)m_uFramesWide, // these will all be between 0.0 and 1.0
::SetRect( &rectCurFrame, (i+0)*m_uTextureFrameWidth, (j+0)*m_uTextureFrameHeight, (j+0)/(float)m_uFramesHigh,
(i+1)*m_uTextureFrameWidth, (j+1)*m_uTextureFrameHeight ); (i+1)/(float)m_uFramesWide,
m_FrameRects.Add( rectCurFrame ); // the index of this array element will be (i + j*m_uFramesWide) (j+1)/(float)m_uFramesHigh );
m_TextureCoordRects.Add( frect ); // the index of this array element will be (i + j*m_uFramesWide)
RageLog( "!!!! Adding frame#%d: %d %d %d %d", (i + j*m_uFramesWide), rectCurFrame.left, rectCurFrame.top, rectCurFrame.right, rectCurFrame.bottom ); //RageLog( "Adding frect%d %f %f %f %f", (i + j*m_uFramesWide), frect.left, frect.top, frect.right, frect.bottom );
} }
} }
} }
#include "string.h" #include "string.h"
VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWide, UINT &uFramesHigh ) const VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesWide, UINT* puFramesHigh ) const
{ {
////////////////////////////////////////////////// //////////////////////////////////////////////////
// Parse m_sFilePath for the frame dimensions // Parse m_sFilePath for the frame dimensions
@@ -110,7 +89,7 @@ VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWi
int index_of_last_period = sDimensionsString.ReverseFind( '.' ); int index_of_last_period = sDimensionsString.ReverseFind( '.' );
if( index_of_last_period == -1 ) // this file name has no extension, but it the texture was loaded. I doubt this code will ever execute :-) if( index_of_last_period == -1 ) // this file name has no extension, but it the texture was loaded. I doubt this code will ever execute :-)
{ {
uFramesWide = uFramesHigh = 1; *puFramesWide = *puFramesHigh = 1;
return; return;
} }
sDimensionsString = sDimensionsString.Left(index_of_last_period); sDimensionsString = sDimensionsString.Left(index_of_last_period);
@@ -119,7 +98,7 @@ VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWi
int index_of_last_space = sDimensionsString.ReverseFind( ' ' ); int index_of_last_space = sDimensionsString.ReverseFind( ' ' );
if( index_of_last_space == -1 ) // this file name has space, so the dimensions tag cannot be read if( index_of_last_space == -1 ) // this file name has space, so the dimensions tag cannot be read
{ {
uFramesWide = uFramesHigh = 1; *puFramesWide = *puFramesHigh = 1;
return; return;
} }
sDimensionsString.Delete( 0, index_of_last_space+1 ); sDimensionsString.Delete( 0, index_of_last_space+1 );
@@ -128,15 +107,15 @@ VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWi
int index_of_x = sDimensionsString.Find( 'x' ); int index_of_x = sDimensionsString.Find( 'x' );
if( index_of_x == -1 ) // this file name doesn't have an x in the last token. So, this probably isn't a dimension tag. if( index_of_x == -1 ) // this file name doesn't have an x in the last token. So, this probably isn't a dimension tag.
{ {
uFramesWide = uFramesHigh = 1; *puFramesWide = *puFramesHigh = 1;
return; return;
} }
uFramesWide = (UINT) atoi( sDimensionsString.Left( index_of_x ) ); *puFramesWide = (UINT) atoi( sDimensionsString.Left( index_of_x ) );
// chop off the frames wide part and read in the frames high // chop off the frames wide part and read in the frames high
sDimensionsString.Delete( 0, index_of_x+1 ); sDimensionsString.Delete( 0, index_of_x+1 );
uFramesHigh = (UINT) atoi( sDimensionsString ); *puFramesHigh = (UINT) atoi( sDimensionsString );
if( uFramesWide == 0 ) uFramesWide = 1; if( *puFramesWide == 0 ) *puFramesWide = 1;
if( uFramesHigh == 0 ) uFramesHigh = 1; if( *puFramesHigh == 0 ) *puFramesHigh = 1;
} }
+24 -19
View File
@@ -22,6 +22,18 @@ typedef RageTexture* LPRageTexture;
//#include <d3d8types.h> //#include <d3d8types.h>
struct FRECT
{
public:
FRECT() {};
FRECT(float l, float t, float r, float b) {
left = l; top = t; right = r; bottom = b;
};
float left, top, right, bottom;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// RageTexture Class Declarations // RageTexture Class Declarations
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -33,49 +45,42 @@ public:
virtual LPDIRECT3DTEXTURE8 GetD3DTexture() PURE; virtual LPDIRECT3DTEXTURE8 GetD3DTexture() PURE;
UINT GetImageWidth() {return m_uImageWidth;}; UINT GetSourceWidth() {return m_uSourceWidth;};
UINT GetImageHeight() {return m_uImageHeight;}; UINT GetSourceHeight() {return m_uSourceHeight;};
UINT GetTextureWidth() {return m_uTextureWidth;}; UINT GetTextureWidth() {return m_uTextureWidth;};
UINT GetTextureHeight() {return m_uTextureHeight;}; UINT GetTextureHeight() {return m_uTextureHeight;};
UINT GetFramesWide() {return m_uFramesWide;}; UINT GetFramesWide() {return m_uFramesWide;};
UINT GetFramesHigh() {return m_uFramesHigh;}; UINT GetFramesHigh() {return m_uFramesHigh;};
UINT GetImageFrameWidth() {return m_uImageFrameWidth;}; UINT GetSourceFrameWidth() {return m_uSourceFrameWidth;};
UINT GetImageFrameHeight() {return m_uImageFrameHeight;}; UINT GetSourceFrameHeight() {return m_uSourceFrameHeight;};
UINT GetTextureFrameWidth() {return m_uTextureFrameWidth;}; FRECT* GetTextureCoordRect( UINT uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
UINT GetTextureFrameHeight() {return m_uTextureFrameHeight;}; UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
float GetWidthCorrectionRatio() {return m_fWidthCorrectionRatio;};
float GetHeightCorrectionRatio() {return m_fHeightCorrectionRatio;};
LPRECT GetFrameRect( UINT uFrameNo ) {return &m_FrameRects[uFrameNo];};
UINT GetNumFrames() {return m_FrameRects.GetSize();};
CString GetFilePath() {return m_sFilePath;}; CString GetFilePath() {return m_sFilePath;};
INT m_iRefCount; INT m_iRefCount;
protected: protected:
virtual VOID CreateFrameRects(); virtual void CreateFrameRects();
virtual VOID GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWide, UINT &uFramesHigh ) const; virtual void GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesWide, UINT* puFramesHigh ) const;
CString m_sFilePath; CString m_sFilePath;
LPDIRECT3DDEVICE8 m_pd3dDevice; LPDIRECT3DDEVICE8 m_pd3dDevice;
LPDIRECT3DTEXTURE8 m_pd3dTexture; LPDIRECT3DTEXTURE8 m_pd3dTexture;
UINT m_uImageWidth, m_uImageHeight; UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image
UINT m_uTextureWidth, m_uTextureHeight; UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture holding the image
D3DFORMAT m_TextureFormat; D3DFORMAT m_TextureFormat;
// The number of frames of animation in each row and column of this texture. // The number of frames of animation in each row and column of this texture.
UINT m_uFramesWide, m_uFramesHigh; UINT m_uFramesWide, m_uFramesHigh;
UINT m_uImageFrameWidth, m_uImageFrameHeight; UINT m_uSourceFrameWidth, m_uSourceFrameHeight;
UINT m_uTextureFrameWidth, m_uTextureFrameHeight;
float m_fWidthCorrectionRatio;
float m_fHeightCorrectionRatio;
// RECTs that hold the bounds of each frame in the bitmap. // RECTs that hold the bounds of each frame in the bitmap.
// e.g., if the texture has 4 frames of animation, the SrcRect for each frame would // e.g., if the texture has 4 frames of animation, the SrcRect for each frame would
// be in m_FrameRects[0..4]. // be in m_FrameRects[0..4].
CArray<RECT, RECT&> m_FrameRects; CArray<FRECT, FRECT&> m_TextureCoordRects;
}; };
+1 -1
View File
@@ -252,7 +252,7 @@ void GetDirListing( CString sPath, CStringArray &AddTo, BOOL bOnlyDirs )
} }
} }
BOOL DoesFileExist( CString sPath ) bool DoesFileExist( CString sPath )
{ {
RageLog( "DoesFileExist(%s)", sPath ); RageLog( "DoesFileExist(%s)", sPath );
+1 -1
View File
@@ -81,7 +81,7 @@ CString join(CString Deliminator, CStringArray& Source);
void GetDirListing( CString sPath, CStringArray &AddTo, BOOL bOnlyDirs=FALSE ); void GetDirListing( CString sPath, CStringArray &AddTo, BOOL bOnlyDirs=FALSE );
BOOL DoesFileExist( CString sPath ); bool DoesFileExist( CString sPath );
int CompareCStrings(const void *arg1, const void *arg2); int CompareCStrings(const void *arg1, const void *arg2);
void SortCStringArray( CStringArray &AddTo, BOOL bSortAcsending = TRUE ); void SortCStringArray( CStringArray &AddTo, BOOL bSortAcsending = TRUE );
+36 -39
View File
@@ -165,7 +165,7 @@ bool Song::LoadSongInfoFromBMSFile( CString sPath )
} }
} }
FillEmptyValuesWithDefaults(); TidyUpData();
return TRUE; return TRUE;
} }
@@ -281,7 +281,7 @@ bool Song::LoadSongInfoFromMSDFile( CString sPath )
} }
void Song::FillEmptyValuesWithDefaults() void Song::TidyUpData()
{ {
if( m_sTitle == "" ) m_sTitle = "Untitled song"; if( m_sTitle == "" ) m_sTitle = "Untitled song";
if( m_sArtist == "" ) m_sArtist = "Unknown artist"; if( m_sArtist == "" ) m_sArtist = "Unknown artist";
@@ -292,52 +292,49 @@ void Song::FillEmptyValuesWithDefaults()
if( m_fBeatOffset == 0.0 ) if( m_fBeatOffset == 0.0 )
RageLog( "WARNING: #OFFSET or #GAP in '%s' is either 0.0, or was missing.", GetSongFilePath() ); RageLog( "WARNING: #OFFSET or #GAP in '%s' is either 0.0, or was missing.", GetSongFilePath() );
if( m_sMusic == "" ) if( m_sMusic == "" || !DoesFileExist(GetMusicPath()) )
{ {
m_sMusic = "music.mp3"; CStringArray arrayPossibleMusic;
if( !DoesFileExist( m_sSongDir + m_sMusic ) ) GetDirListing( m_sSongDir + CString("*.wma"), arrayPossibleMusic );
{ GetDirListing( m_sSongDir + CString("*.mp3"), arrayPossibleMusic );
// music.mp3 didn't exist, so search for any mp3 in the same dir GetDirListing( m_sSongDir + CString("*.wav"), arrayPossibleMusic );
CStringArray arrayMP3Files;
GetDirListing( m_sSongDir + CString("*.mp3"), arrayMP3Files );
if( arrayMP3Files.GetSize() != 0 ) // we found a .mp3 file! if( arrayPossibleMusic.GetSize() != 0 ) // we found a match
m_sMusic = arrayMP3Files.GetAt( 0 ); m_sMusic = arrayPossibleMusic.GetAt( 0 );
else else
RageError( ssprintf("Music could not be found. In Song file '%s' no #MUSIC was specified, music.mp3 doesn't exist, and no other MP3s could be found.", GetSongFilePath()) ); RageError( ssprintf("Music could not be found. Please check the Song file '%s' and verify the specified #MUSIC exists.", GetSongFilePath()) );
} }
} if( m_sBanner == "" || !DoesFileExist(GetBannerPath()) )
if( m_sSample == "" )
{ {
m_sSample = "sample.mp3"; CStringArray arrayPossibleBanners;
if( !DoesFileExist( m_sSongDir + m_sSample ) ) GetDirListing( m_sSongDir + CString("*banner*.*"), arrayPossibleBanners );
m_sSample = m_sMusic; // we assured above that the m_sMusic file exists GetDirListing( m_sSongDir + CString("*.png"), arrayPossibleBanners );
} GetDirListing( m_sSongDir + CString("*.bmp"), arrayPossibleBanners );
if( m_sBanner == "" )
{
m_sBanner = "banner.bmp";
if( !DoesFileExist( m_sSongDir + m_sBanner ) )
{
m_sBanner = "banner.png";
if( !DoesFileExist( m_sSongDir + m_sBanner ) )
{
// couldn't find a true banner, so search for any bmp in the same dir
CStringArray arrayBMPFiles;
GetDirListing( m_sSongDir + CString("*.bmp"), arrayBMPFiles );
GetDirListing( m_sSongDir + CString("*.png"), arrayBMPFiles );
if( arrayBMPFiles.GetSize() != 0 ) // we found a .bmp file! if( arrayPossibleBanners.GetSize() != 0 ) // we found a match
m_sBanner = arrayBMPFiles.GetAt( 0 ); m_sBanner = arrayPossibleBanners.GetAt( 0 );
else else
RageError( ssprintf("Banner could not be found. In Song file '%s' no #BANNER was specified, banner.bmp doesn't exist, and no other BMPs could be found.", GetSongFilePath()) ); RageError( ssprintf("Banner could not be found. Please check the Song file '%s' and verify the specified #BANNER exists.", GetSongFilePath()) );
} }
} if( m_sBackground == "" || !DoesFileExist(GetBackgroundPath()) )
}
if( m_sBackground == "" )
{ {
m_sBackground = "background.bmp"; CStringArray arrayPossibleBanners;
if( !DoesFileExist( m_sSongDir + m_sBackground ) ) GetDirListing( m_sSongDir + CString("*b*g*.*"), arrayPossibleBanners );
m_sBackground = m_sBanner; // we assured above that the m_sBanner file exists GetDirListing( m_sSongDir + CString("*640*.*"), arrayPossibleBanners );
GetDirListing( m_sSongDir + CString("*.png"), arrayPossibleBanners );
GetDirListing( m_sSongDir + CString("*.bmp"), arrayPossibleBanners );
if( arrayPossibleBanners.GetSize() != 0 ) // we found a match
m_sBackground = arrayPossibleBanners.GetAt( 0 );
else
RageError( ssprintf("Banner could not be found. Please check the Song file '%s' and verify the specified #BANNER exists.", GetSongFilePath()) );
} }
} }
/*
D3DXIMAGE_INFO ddii;
if( FAILED( hr = D3DXGetImageInfoFromFile(m_sFilePath,&ddii) ) ) {
RageErrorHr( ssprintf("D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath), hr );
}
*/
+194 -55
View File
@@ -31,7 +31,7 @@ void Sprite::Init()
m_uCurState = 0; m_uCurState = 0;
m_bIsAnimating = TRUE; m_bIsAnimating = TRUE;
m_fSecsIntoState = 0.0; m_fSecsIntoState = 0.0;
m_bUsingCustomSrcRect = FALSE ; m_bUsingCustomTexCoordRect = FALSE ;
m_Effect = no_effect ; m_Effect = no_effect ;
m_fPercentBetweenColors = 0.0f ; m_fPercentBetweenColors = 0.0f ;
m_bTweeningTowardEndColor = TRUE ; m_bTweeningTowardEndColor = TRUE ;
@@ -42,7 +42,6 @@ void Sprite::Init()
m_fSpinSpeed = 2.0f ; m_fSpinSpeed = 2.0f ;
m_fVibrationDistance = 5.0f ; m_fVibrationDistance = 5.0f ;
m_bVisibleThisFrame = FALSE; m_bVisibleThisFrame = FALSE;
m_bBlendAdd = FALSE;
} }
Sprite::~Sprite() Sprite::~Sprite()
@@ -130,8 +129,10 @@ BOOL Sprite::LoadTexture( CString sTexturePath )
m_pTexture = TM->LoadTexture( m_sTexturePath ); m_pTexture = TM->LoadTexture( m_sTexturePath );
assert( m_pTexture != NULL ); assert( m_pTexture != NULL );
SetWidth( (FLOAT)m_pTexture->GetImageFrameWidth() );
SetHeight( (FLOAT)m_pTexture->GetImageFrameHeight() ); // the size of the sprite is the size of the image before it was scaled
SetWidth( (FLOAT)m_pTexture->GetSourceFrameWidth() );
SetHeight( (FLOAT)m_pTexture->GetSourceFrameHeight() );
// Assume the frames of this animation play in sequential order with 0.2 second delay. // Assume the frames of this animation play in sequential order with 0.2 second delay.
for( UINT i=0; i<m_pTexture->GetNumFrames(); i++ ) for( UINT i=0; i<m_pTexture->GetNumFrames(); i++ )
@@ -229,34 +230,21 @@ void Sprite::Draw()
if( m_pTexture == NULL ) if( m_pTexture == NULL )
return; return;
FRECT* pTexCoordRect; // the texture coordinates of the frame we're going to use
if( m_bUsingCustomTexCoordRect ) {
pTexCoordRect = &m_CustomTexCoordRect;
} else {
UINT uFrameNo = m_uFrame[m_uCurState]; UINT uFrameNo = m_uFrame[m_uCurState];
pTexCoordRect = m_pTexture->GetTextureCoordRect( uFrameNo );
LPRECT pRectSrc; }
if( m_bUsingCustomSrcRect )
pRectSrc = &m_rectCustomSrcRect;
else
pRectSrc = m_pTexture->GetFrameRect( uFrameNo );
//::SetRect( &rectSrc, 0, 0, m_pTexture->GetImageWidth(), m_pTexture->GetImageHeight() );
D3DXVECTOR2 scaling;
scaling.x = GetZoom() * m_pTexture->GetWidthCorrectionRatio();
scaling.y = GetZoom() * m_pTexture->GetHeightCorrectionRatio();
D3DXVECTOR2 translation;
translation.x = (float)GetLeftEdge();
translation.y = (float)GetTopEdge();
D3DXVECTOR3 rotation = m_rotation;
D3DXVECTOR2 rot_center;
rot_center.x = GetZoomedWidth()/2.0f;
rot_center.y = GetZoomedHeight()/2.0f;
D3DXCOLOR color = m_color; D3DXCOLOR color = m_color;
D3DXVECTOR2 pos = m_pos;
D3DXVECTOR3 rotation = m_rotation;
D3DXVECTOR2 scale = m_scale;
bool bBlendAdd = false;
// update properties based on SpriteEffects
// update SpriteEffect
switch( m_Effect ) switch( m_Effect )
{ {
case no_effect: case no_effect:
@@ -265,8 +253,11 @@ void Sprite::Draw()
color = m_bTweeningTowardEndColor ? m_start_color : m_end_color; color = m_bTweeningTowardEndColor ? m_start_color : m_end_color;
break; break;
case camelion: case camelion:
color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors);
break;
case glowing: case glowing:
color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors); color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors);
bBlendAdd = true;
break; break;
case wagging: case wagging:
rotation.z = m_fWagRadians * (FLOAT)sin( rotation.z = m_fWagRadians * (FLOAT)sin(
@@ -277,8 +268,8 @@ void Sprite::Draw()
// nothing special needed // nothing special needed
break; break;
case vibrating: case vibrating:
translation.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
translation.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
break; break;
case flickering: case flickering:
m_bVisibleThisFrame = !m_bVisibleThisFrame; m_bVisibleThisFrame = !m_bVisibleThisFrame;
@@ -287,15 +278,167 @@ void Sprite::Draw()
break; break;
} }
SCREEN->DrawQuad( m_pTexture,
pRectSrc, // make a 1x1 rect centered at the origin
&scaling, // scaling LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer();
&rot_center, // rotation center CUSTOMVERTEX* v;
&rotation, // rotation pVB->Lock( 0, 0, (BYTE**)&v, 0 );
&translation, // translation
color, v[0].p = D3DXVECTOR3( -0.5f, 0.5f, 0 ); // bottom left
m_Effect == glowing ? op_add : op_modulate, v[1].p = D3DXVECTOR3( -0.5f, -0.5f, 0 ); // top left
m_bBlendAdd ); v[2].p = D3DXVECTOR3( 0.5f, 0.5f, 0 ); // bottom right
v[3].p = D3DXVECTOR3( 0.5f, -0.5f, 0 ); // top right
v[0].tu = pTexCoordRect->left; v[0].tv = pTexCoordRect->bottom; // bottom left
v[1].tu = pTexCoordRect->left; v[1].tv = pTexCoordRect->top; // top left
v[2].tu = pTexCoordRect->right; v[2].tv = pTexCoordRect->bottom; // bottom right
v[3].tu = pTexCoordRect->right; v[3].tv = pTexCoordRect->top; // top right
v[0].color = v[1].color = v[2].color = v[3].color = color;
pVB->Unlock();
// set texture and alpha properties
LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice();
pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
//pd3dDevice->SetRenderState( D3DRS_SRCBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA );
//pd3dDevice->SetRenderState( D3DRS_DESTBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA );
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
// calculate transforms
D3DXMATRIX matWorld, matTemp;
D3DXMatrixIdentity( &matWorld ); // initialize world
D3DXMatrixScaling( &matTemp, m_size.x, m_size.y, 1 ); // scale to the native height and width
matWorld *= matTemp;
D3DXMatrixScaling( &matTemp, scale.x, scale.y, 1 ); // add in the zoom
matWorld *= matTemp;
D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation
matWorld *= matTemp;
D3DXMatrixTranslation( &matTemp, pos.x, pos.y, 0 ); // add in the translation
matWorld *= matTemp;
D3DXMatrixTranslation( &matTemp, -0.5f, -0.5f, 0 ); // shift to align texels with pixels
matWorld *= matTemp;
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXMATRIX matView;
D3DXMatrixIdentity( &matView );
pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMATRIX matProj;
D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -100, 100 );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// finally! Pump those triangles!
pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
pd3dDevice->SetStreamSource( 0, pVB, sizeof(CUSTOMVERTEX) );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
/* WORKS!
LPDIRECT3DVERTEXBUFFER8 pVB2 = NULL; // Buffer to hold vertices
// A structure for our custom vertex type
struct CUSTOMVERTEX
{
FLOAT x, y, z; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
};
// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
// Initialize three vertices for rendering a triangle
CUSTOMVERTEX g_Vertices[] =
{
{ -15.0f,-15.0f, 0.0f, 0xffff0000, },
{ 15.0f,-15.0f, 0.0f, 0xff0000ff, },
{ 00.0f, 15.0f, 0.0f, 0xffffffff, },
};
// Create the vertex buffer.
if( FAILED( pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &pVB2 ) ) )
{
return;
}
// Turn off culling, so we see the front and back of the triangle
pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
// Turn off D3D lighting, since we are providing our own vertex colors
pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
// Fill the vertex buffer.
void* pVertices;
if( FAILED( pVB2->Lock( 0, sizeof(g_Vertices), (BYTE**)&pVertices, 0 ) ) )
return;
memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );
pVB2->Unlock();
// For our world matrix, we will just rotate the object about the y-axis.
//D3DXMATRIX matWorld;
D3DXMatrixRotationY( &matWorld, GetTickCount()/150.0f );
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
// Set up our view matrix. A view matrix can be defined given an eye point,
// a point to lookat, and a direction for which way is up. Here, we set the
// eye five units back along the z-axis and up three units, look at the
// origin, and define "up" to be in the y-direction.
//D3DXMATRIX matView;
//D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f ),
// &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
// &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
D3DXMatrixIdentity( &matView );
pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
// For the projection matrix, we set up a perspective transform (which
// transforms geometry from 3D view space to 2D viewport space, with
// a perspective divide making objects smaller in the distance). To build
// a perpsective transform, we need the field of view (1/4 pi is common),
// the aspect ratio, and the near and far clipping planes (which define at
// what distances geometry should be no longer be rendered).
//D3DXMATRIX matProj;
//D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
//D3DXMatrixOrthoLH( &matProj, 640, -480, -100, 100 );
D3DXMatrixOrthoOffCenterLH( &matProj, 0, 320, 480, 0, -100, 100 );
// D3DXMatrixOrthoOffCenterLH( &matProj, -20, 20, 20, -20, -100, 100 );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Render the vertex buffer contents
pd3dDevice->SetStreamSource( 0, pVB2, sizeof(CUSTOMVERTEX) );
pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
if( pVB2 != NULL )
pVB2->Release();
*/
} }
@@ -307,23 +450,19 @@ void Sprite::SetState( UINT uNewState )
m_fSecsIntoState = 0.0; m_fSecsIntoState = 0.0;
} }
void Sprite::SetCustomSrcRect( RECT newRect ) void Sprite::SetCustomSrcRect( FRECT new_texcoord_frect )
{ {
m_bUsingCustomSrcRect = TRUE; m_bUsingCustomTexCoordRect = true;
m_rectCustomSrcRect = newRect; m_CustomTexCoordRect = new_texcoord_frect;
}
SetWidth( (FLOAT) RECTWIDTH(newRect) ); void Sprite::SetEffectNone()
SetHeight( (FLOAT) RECTHEIGHT(newRect) );
};
VOID Sprite::SetEffectNone()
{ {
m_Effect = no_effect; m_Effect = no_effect;
//m_color = D3DXCOLOR( 1.0,1.0,1.0,1.0 ); //m_color = D3DXCOLOR( 1.0,1.0,1.0,1.0 );
} }
VOID Sprite::SetEffectBlinking( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) void Sprite::SetEffectBlinking( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 )
{ {
m_Effect = blinking; m_Effect = blinking;
m_start_color = Color; m_start_color = Color;
@@ -333,7 +472,7 @@ VOID Sprite::SetEffectBlinking( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
} }
VOID Sprite::SetEffectCamelion( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) void Sprite::SetEffectCamelion( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 )
{ {
m_Effect = camelion; m_Effect = camelion;
m_start_color = Color; m_start_color = Color;
@@ -343,7 +482,7 @@ VOID Sprite::SetEffectCamelion( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
} }
VOID Sprite::SetEffectGlowing( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) void Sprite::SetEffectGlowing( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 )
{ {
m_Effect = glowing; m_Effect = glowing;
m_start_color = Color; m_start_color = Color;
@@ -353,26 +492,26 @@ VOID Sprite::SetEffectGlowing( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
} }
VOID Sprite::SetEffectWagging( FLOAT fWagRadians, FLOAT fWagPeriod ) void Sprite::SetEffectWagging( FLOAT fWagRadians, FLOAT fWagPeriod )
{ {
m_Effect = wagging; m_Effect = wagging;
m_fWagRadians = fWagRadians; m_fWagRadians = fWagRadians;
m_fWagPeriod = fWagPeriod; m_fWagPeriod = fWagPeriod;
} }
VOID Sprite::SetEffectSpinning( FLOAT fSpinSpeed /*radians per second*/ ) void Sprite::SetEffectSpinning( FLOAT fSpinSpeed /*radians per second*/ )
{ {
m_Effect = spinning; m_Effect = spinning;
m_fSpinSpeed = fSpinSpeed; m_fSpinSpeed = fSpinSpeed;
} }
VOID Sprite::SetEffectVibrating( FLOAT fVibrationDistance ) void Sprite::SetEffectVibrating( FLOAT fVibrationDistance )
{ {
m_Effect = vibrating; m_Effect = vibrating;
m_fVibrationDistance = fVibrationDistance; m_fVibrationDistance = fVibrationDistance;
} }
VOID Sprite::SetEffectFlickering() void Sprite::SetEffectFlickering()
{ {
m_Effect = flickering; m_Effect = flickering;
} }
+12 -16
View File
@@ -39,7 +39,7 @@ public:
BOOL LoadFromTexture( CString sTexturePath ); BOOL LoadFromTexture( CString sTexturePath );
BOOL LoadFromSpriteFile( CString sSpritePath ); BOOL LoadFromSpriteFile( CString sSpritePath );
VOID PrintDebugInfo(); void PrintDebugInfo();
virtual void Draw(); virtual void Draw();
virtual void Update( const FLOAT &fDeltaTime ); virtual void Update( const FLOAT &fDeltaTime );
@@ -52,28 +52,26 @@ public:
CString GetTexturePath() { return m_sTexturePath; }; CString GetTexturePath() { return m_sTexturePath; };
VOID SetCustomSrcRect( RECT newRect ); // for cropping or flipping void SetCustomSrcRect( FRECT new_texcoord_frect ); // for cropping
VOID SetEffectNone(); void SetEffectNone();
VOID SetEffectBlinking( FLOAT fDeltaPercentPerSecond = 2.5, void SetEffectBlinking( FLOAT fDeltaPercentPerSecond = 2.5,
D3DXCOLOR Color = D3DXCOLOR(0.5f,0.5f,0.5f,1), D3DXCOLOR Color = D3DXCOLOR(0.5f,0.5f,0.5f,1),
D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) );
VOID SetEffectCamelion( FLOAT fDeltaPercentPerSecond = 2.5, void SetEffectCamelion( FLOAT fDeltaPercentPerSecond = 2.5,
D3DXCOLOR Color = D3DXCOLOR(0,0,0,1), D3DXCOLOR Color = D3DXCOLOR(0,0,0,1),
D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) );
VOID SetEffectGlowing( FLOAT fDeltaPercentPerSecond = 2.5, void SetEffectGlowing( FLOAT fDeltaPercentPerSecond = 2.5,
D3DXCOLOR Color = D3DXCOLOR(0.4f,0.4f,0.4f,0), D3DXCOLOR Color = D3DXCOLOR(0.4f,0.4f,0.4f,0),
D3DXCOLOR Color2 = D3DXCOLOR(1.0f,1.0f,1.0f,0) ); D3DXCOLOR Color2 = D3DXCOLOR(1.0f,1.0f,1.0f,0) );
VOID SetEffectWagging( FLOAT fWagRadians = 0.2, void SetEffectWagging( FLOAT fWagRadians = 0.2,
FLOAT fWagPeriod = 2.0 ); FLOAT fWagPeriod = 2.0 );
VOID SetEffectSpinning( FLOAT fRadsPerSpeed = 2.0 ); void SetEffectSpinning( FLOAT fRadsPerSpeed = 2.0 );
VOID SetEffectVibrating( FLOAT fVibrationDistance = 5.0 ); void SetEffectVibrating( FLOAT fVibrationDistance = 5.0 );
VOID SetEffectFlickering(); void SetEffectFlickering();
SpriteEffect GetEffect() { return m_Effect; }; SpriteEffect GetEffect() { return m_Effect; };
VOID SetBlendMode( BOOL bBlendAdd ) { m_bBlendAdd = bBlendAdd; };
protected: protected:
void Init(); void Init();
@@ -90,10 +88,8 @@ protected:
BOOL m_bIsAnimating; BOOL m_bIsAnimating;
FLOAT m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame FLOAT m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
BOOL m_bBlendAdd; BOOL m_bUsingCustomTexCoordRect;
FRECT m_CustomTexCoordRect;
BOOL m_bUsingCustomSrcRect;
RECT m_rectCustomSrcRect;
SpriteEffect m_Effect; SpriteEffect m_Effect;
+10 -10
View File
@@ -397,19 +397,19 @@ void Update()
WM->Update( fDeltaTime ); WM->Update( fDeltaTime );
static RageRawInputList listRawInput; static DeviceInputArray diArray;
listRawInput.RemoveAll(); diArray.RemoveAll();
INPUT->GetRawInput( listRawInput ); INPUT->GetDeviceInputs( diArray );
RageRawInput ri; DeviceInput di;
PadInput pi; PadInput pi;
POSITION pos = listRawInput.GetHeadPosition(); for( int i=0; i<diArray.GetSize(); i++ )
while( pos != NULL )
{ {
ri = listRawInput.GetNext( pos ); di = diArray[i];
pi = GAMEINFO->RawToPad( ri ); if( GAMEINFO->DeviceToPad( di, pi ) )
WM->Input( di, &pi ); // this di maps to a pi
WM->Input( ri, pi ); else
WM->Input( di, NULL ); // this di doesn't map to a pi, so pass NULL
} }
} }
+8 -8
View File
@@ -284,6 +284,14 @@ SOURCE=.\Banner.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\BitmapFont.cpp
# End Source File
# Begin Source File
SOURCE=.\BitmapFont.h
# End Source File
# Begin Source File
SOURCE=.\BitmapText.cpp SOURCE=.\BitmapText.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@@ -300,14 +308,6 @@ SOURCE=.\BlurredTitle.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\Button.cpp
# End Source File
# Begin Source File
SOURCE=.\button.h
# End Source File
# Begin Source File
SOURCE=.\FootBar.cpp SOURCE=.\FootBar.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
+1 -3
View File
@@ -35,13 +35,12 @@ private:
bool LoadSongInfoFromBMSFile( CString sPath ); bool LoadSongInfoFromBMSFile( CString sPath );
bool LoadSongInfoFromMSDFile( CString sPath ); bool LoadSongInfoFromMSDFile( CString sPath );
void FillEmptyValuesWithDefaults(); void TidyUpData();
public: public:
CString GetSongFilePath() {return m_sSongDir + m_sSongFile; }; CString GetSongFilePath() {return m_sSongDir + m_sSongFile; };
CString GetSongFileDir() {return m_sSongDir; }; CString GetSongFileDir() {return m_sSongDir; };
CString GetMusicPath() {return m_sSongDir + m_sMusic; }; CString GetMusicPath() {return m_sSongDir + m_sMusic; };
CString GetSamplePath() {return m_sSongDir + m_sSample; };
CString GetBannerPath() {return m_sSongDir + m_sBanner; }; CString GetBannerPath() {return m_sSongDir + m_sBanner; };
CString GetBackgroundPath() {return m_sSongDir + m_sBackground; }; CString GetBackgroundPath() {return m_sSongDir + m_sBackground; };
// Steps& GetStepsAt( int iIndex ) {return arraySteps[iIndex]; }; // Steps& GetStepsAt( int iIndex ) {return arraySteps[iIndex]; };
@@ -67,7 +66,6 @@ private:
float m_fBeatOffset; float m_fBeatOffset;
CString m_sMusic; CString m_sMusic;
CString m_sSample;
CString m_sBanner; CString m_sBanner;
CString m_sBackground; CString m_sBackground;