Rewrote texture loading actor and sprite
This commit is contained in:
@@ -125,21 +125,21 @@ void Actor::SetTweenColor( D3DXCOLOR c ) { m_end_color = c; }
|
||||
void Actor::ScaleTo( LPRECT pRect, StretchType st )
|
||||
{
|
||||
// width and height of rectangle
|
||||
int rect_width = RECTWIDTH(*pRect);
|
||||
int rect_height = RECTHEIGHT(*pRect);
|
||||
float rect_width = RECTWIDTH(*pRect);
|
||||
float rect_height = RECTHEIGHT(*pRect);
|
||||
|
||||
// center of the rectangle
|
||||
int rect_cx = pRect->left + rect_width/2;
|
||||
int rect_cy = pRect->top + rect_height/2;
|
||||
float rect_cx = pRect->left + rect_width/2;
|
||||
float rect_cy = pRect->top + rect_height/2;
|
||||
|
||||
// zoom factor needed to scale the Actor to fill the rectangle
|
||||
FLOAT fNewZoomX = (FLOAT)fabs(rect_width / m_size.x);
|
||||
FLOAT fNewZoomY = (FLOAT)fabs(rect_height / m_size.y);
|
||||
float fNewZoomX = (float)fabs(rect_width / m_size.x);
|
||||
float fNewZoomY = (float)fabs(rect_height / m_size.y);
|
||||
|
||||
if( rect_width < 0 ) SetRotationY( D3DX_PI );
|
||||
if( rect_height < 0 ) SetRotationX( D3DX_PI );
|
||||
|
||||
FLOAT fNewZoom;
|
||||
float fNewZoom;
|
||||
switch( st )
|
||||
{
|
||||
case cover:
|
||||
@@ -150,7 +150,7 @@ void Actor::ScaleTo( LPRECT pRect, StretchType st )
|
||||
break;
|
||||
}
|
||||
|
||||
SetXY( (FLOAT)rect_cx, (FLOAT)rect_cy );
|
||||
SetXY( rect_cx, rect_cy );
|
||||
SetZoom( fNewZoom );
|
||||
}
|
||||
|
||||
|
||||
+36
-36
@@ -31,56 +31,56 @@ public:
|
||||
virtual void Invalidate() {};
|
||||
|
||||
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 GetY() { return m_pos.y; };
|
||||
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 SetXY( FLOAT x, FLOAT y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; };
|
||||
virtual float GetX() { return m_pos.x; };
|
||||
virtual float GetY() { return m_pos.y; };
|
||||
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 SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; };
|
||||
|
||||
// height and width vary depending on zoom
|
||||
virtual FLOAT GetZoomedWidth() { return m_size.x * m_scale.x; }
|
||||
virtual FLOAT GetZoomedHeight() { return m_size.y * m_scale.y; }
|
||||
virtual void SetWidth( FLOAT width ){ m_size.x = width; }
|
||||
virtual void SetHeight( FLOAT height ){ m_size.y = height; }
|
||||
virtual float GetZoomedWidth() { return m_size.x * m_scale.x; }
|
||||
virtual float GetZoomedHeight() { return m_size.y * m_scale.y; }
|
||||
virtual void SetWidth( float width ){ m_size.x = width; }
|
||||
virtual void SetHeight( float height ){ m_size.y = height; }
|
||||
|
||||
virtual FLOAT GetZoom() { return m_scale.x; }
|
||||
virtual void SetZoom( FLOAT zoom ) { m_scale.x = zoom; m_scale.y = zoom; }
|
||||
virtual float GetZoom() { return m_scale.x; }
|
||||
virtual void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; }
|
||||
|
||||
virtual FLOAT GetRotation() { return m_rotation.z; }
|
||||
virtual void SetRotation( FLOAT rot ) { m_rotation.z = rot; }
|
||||
virtual FLOAT GetRotationX() { return m_rotation.x; }
|
||||
virtual void SetRotationX( FLOAT rot ) { m_rotation.x = rot; }
|
||||
virtual FLOAT GetRotationY() { return m_rotation.y; }
|
||||
virtual void SetRotationY( FLOAT rot ) { m_rotation.y = rot; }
|
||||
virtual float GetRotation() { return m_rotation.z; }
|
||||
virtual void SetRotation( float rot ) { m_rotation.z = rot; }
|
||||
virtual float GetRotationX() { return m_rotation.x; }
|
||||
virtual void SetRotationX( float rot ) { m_rotation.x = rot; }
|
||||
virtual float GetRotationY() { return m_rotation.y; }
|
||||
virtual void SetRotationY( float rot ) { m_rotation.y = rot; }
|
||||
|
||||
virtual void SetColor( D3DXCOLOR newColor ) { m_color = newColor; };
|
||||
virtual D3DXCOLOR GetColor() { return m_color; };
|
||||
|
||||
virtual void TweenTo( FLOAT time,
|
||||
FLOAT x, FLOAT y,
|
||||
FLOAT zoom = 1.0,
|
||||
FLOAT rot = 0.0,
|
||||
virtual void TweenTo( float time,
|
||||
float x, float y,
|
||||
float zoom = 1.0,
|
||||
float rot = 0.0,
|
||||
D3DXCOLOR col = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ),
|
||||
TweenType tt = tween_linear );
|
||||
|
||||
virtual void BeginTweening( FLOAT time, TweenType tt = tween_linear );
|
||||
virtual void SetTweenX( FLOAT x );
|
||||
virtual void SetTweenY( FLOAT y );
|
||||
virtual void SetTweenXY( FLOAT x, FLOAT y );
|
||||
virtual void SetTweenZoom( FLOAT zoom );
|
||||
virtual void SetTweenRotationX( FLOAT r );
|
||||
virtual void SetTweenRotationY( FLOAT r );
|
||||
virtual void SetTweenRotationZ( FLOAT r );
|
||||
virtual void BeginTweening( float time, TweenType tt = tween_linear );
|
||||
virtual void SetTweenX( float x );
|
||||
virtual void SetTweenY( float y );
|
||||
virtual void SetTweenXY( float x, float y );
|
||||
virtual void SetTweenZoom( float zoom );
|
||||
virtual void SetTweenRotationX( float r );
|
||||
virtual void SetTweenRotationY( float r );
|
||||
virtual void SetTweenRotationZ( float r );
|
||||
virtual void SetTweenColor( D3DXCOLOR c );
|
||||
|
||||
|
||||
// NOTE: GetEdge functions don't consider rotation
|
||||
virtual FLOAT GetLeftEdge() { 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 GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; };
|
||||
virtual float GetLeftEdge() { 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 GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; };
|
||||
|
||||
enum StretchType { fit_inside, cover };
|
||||
|
||||
@@ -108,8 +108,8 @@ protected:
|
||||
|
||||
// counters for tweening
|
||||
TweenType m_TweenType;
|
||||
FLOAT m_fTweenTime; // seconds between Start and End positions/zooms
|
||||
FLOAT m_fTimeIntoTween; // how long we have been tweening for
|
||||
float m_fTweenTime; // seconds between Start and End positions/zooms
|
||||
float m_fTimeIntoTween; // how long we have been tweening for
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void Background::LoadFromSong( Song& song )
|
||||
|
||||
m_sprVis.LoadFromTexture( sVisDir + sVisualizationPaths[iIndexRandom] );
|
||||
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) );
|
||||
}
|
||||
}
|
||||
|
||||
+42
-44
@@ -15,53 +15,51 @@
|
||||
|
||||
|
||||
|
||||
BOOL Banner::LoadFromSong( Song &song )
|
||||
bool Banner::LoadFromSong( Song &song )
|
||||
{
|
||||
BOOL bResult = Sprite::LoadFromTexture( song.GetBannerPath() );
|
||||
if( bResult )
|
||||
Sprite::LoadFromTexture( song.GetBannerPath() );
|
||||
|
||||
float fSourceWidth = (float)m_pTexture->GetSourceWidth();
|
||||
float fSourceHeight = (float)m_pTexture->GetSourceHeight();
|
||||
|
||||
// first find the correct zoom
|
||||
Sprite::ScaleToCover( CRect(0, 0,
|
||||
BANNER_WIDTH,
|
||||
BANNER_HEIGHT )
|
||||
);
|
||||
float fFinalZoom = this->GetZoom();
|
||||
|
||||
// find which dimension is larger
|
||||
bool bXDimNeedsToBeCropped = GetZoomedWidth() > BANNER_WIDTH;
|
||||
|
||||
if( bXDimNeedsToBeCropped ) // crop X
|
||||
{
|
||||
int iImageWidth = this->GetZoomedWidth();
|
||||
int iImageHeight = this->GetZoomedHeight();
|
||||
|
||||
int iCorrectedBannerWidth = BANNER_WIDTH / m_pTexture->GetWidthCorrectionRatio();
|
||||
int iCorrectedBannerHeight = BANNER_HEIGHT / m_pTexture->GetHeightCorrectionRatio();
|
||||
|
||||
// first find the correct zoom
|
||||
Sprite::ScaleToCover( CRect(0, 0,
|
||||
iCorrectedBannerWidth,
|
||||
iCorrectedBannerHeight )
|
||||
);
|
||||
float fPercentageToCutOff = (this->GetZoomedWidth() - BANNER_WIDTH) / this->GetZoomedWidth();
|
||||
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
|
||||
|
||||
FLOAT fFinalZoom = this->GetZoom();
|
||||
|
||||
// find which dimension is larger
|
||||
BOOL bYDimIsLarger = this->GetZoomedHeight() > iCorrectedBannerHeight;
|
||||
// BOOL bYDimIsLarger = this->GetZoomedHeight() > BANNER_HEIGHT;
|
||||
|
||||
// now crop it
|
||||
if( !bYDimIsLarger ) // crop X
|
||||
{
|
||||
int iScreenPixelsToCrop = (this->GetZoomedWidth() - iCorrectedBannerWidth) / 2;
|
||||
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom );
|
||||
RECT rectNewSrc;
|
||||
::SetRect( &rectNewSrc, iImagePixelsToCrop,
|
||||
0,
|
||||
iImageWidth - iImagePixelsToCrop,
|
||||
iImageHeight );
|
||||
Sprite::SetCustomSrcRect( rectNewSrc );
|
||||
}
|
||||
else // crop Y
|
||||
{
|
||||
int iScreenPixelsToCrop = (this->GetZoomedHeight() - iCorrectedBannerHeight) / 2;
|
||||
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom );
|
||||
RECT rectNewSrc;
|
||||
::SetRect( &rectNewSrc, 0,
|
||||
iImagePixelsToCrop,
|
||||
iImageWidth,
|
||||
iImageHeight - iImagePixelsToCrop );
|
||||
Sprite::SetCustomSrcRect( rectNewSrc );
|
||||
}
|
||||
// generate a rectangle with new texture coordinates
|
||||
FRECT frectNewSrc( fPercentageToCutOffEachSide,
|
||||
0,
|
||||
1 - fPercentageToCutOffEachSide,
|
||||
1 );
|
||||
Sprite::SetCustomSrcRect( frectNewSrc );
|
||||
}
|
||||
else // crop Y
|
||||
{
|
||||
float fPercentageToCutOff = (this->GetZoomedHeight() - BANNER_HEIGHT) / this->GetZoomedHeight();
|
||||
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
|
||||
|
||||
// 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;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,18 +16,15 @@
|
||||
#include "Song.h"
|
||||
|
||||
|
||||
#define COMMON_BANNER_TEXTURE_WIDTH 384
|
||||
#define COMMON_BANNER_TEXTURE_HEIGHT 110
|
||||
|
||||
#define BANNER_WIDTH (COMMON_BANNER_TEXTURE_WIDTH/2)
|
||||
#define BANNER_HEIGHT (COMMON_BANNER_TEXTURE_HEIGHT / 2)
|
||||
const float BANNER_WIDTH = 192; // from the source art of DDR
|
||||
const float BANNER_HEIGHT = 55;
|
||||
|
||||
|
||||
class Banner : public Sprite
|
||||
{
|
||||
public:
|
||||
|
||||
BOOL LoadFromSong( Song &song);
|
||||
bool LoadFromSong( Song &song);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -17,97 +17,68 @@
|
||||
|
||||
BitmapText::BitmapText()
|
||||
{
|
||||
m_pFont = NULL;
|
||||
m_colorTop = D3DXCOLOR(1,1,1,1);
|
||||
m_colorBottom = D3DXCOLOR(1,1,1,1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL BitmapText::LoadFromFontFile( CString sFontFilePath )
|
||||
BitmapText::~BitmapText()
|
||||
{
|
||||
RageLog( "BitmapText::LoadFromFontFile(%s)", sFontFilePath );
|
||||
delete m_pFont;
|
||||
}
|
||||
|
||||
m_sFontFilePath = sFontFilePath;
|
||||
bool BitmapText::LoadFromFontName( CString sFontName )
|
||||
{
|
||||
RageLog( "BitmapText::LoadFromFontName(%s)", sFontName );
|
||||
|
||||
SAFE_DELETE( m_pFont ); // delete old font (if any)
|
||||
|
||||
// read font file
|
||||
IniFile ini;
|
||||
ini.SetPath( m_sFontFilePath );
|
||||
if( !ini.ReadFile() )
|
||||
RageError( ssprintf("Error opening Font file: %s.", m_sFontFilePath) );
|
||||
m_sFontName = sFontName; // save font name
|
||||
|
||||
CString sTexturePath = ini.GetValue( "Font", "Texture" );
|
||||
if( sTexturePath == "" )
|
||||
RageError( ssprintf("Error reading value 'Texture' from %s.", m_sFontFilePath) );
|
||||
|
||||
this->LoadFromTexture( sTexturePath );
|
||||
|
||||
// fill in our map from characters to frame no
|
||||
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();
|
||||
m_pFont= new CBitmapFont( SCREEN->GetD3D(), SCREEN->GetDevice() );
|
||||
m_pFont->Load( BL_BITMAP, ssprintf("Fonts/%s.png",sFontName) );
|
||||
m_pFont->Load( BL_SIZES, ssprintf("Fonts/%s.dat",sFontName) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void BitmapText::SetText( CString sText )
|
||||
{
|
||||
m_sText = sText;
|
||||
|
||||
ResetWidthAndHeight();
|
||||
}
|
||||
|
||||
|
||||
void BitmapText::Draw()
|
||||
{
|
||||
//RageLog( "BitmapText::Draw()" );
|
||||
// UGLY!!!!
|
||||
RECT rect = m_pFont->GetTextRect(m_sText, 0, 0);
|
||||
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() );
|
||||
m_size.x = (FLOAT)iFrameWidth;
|
||||
|
||||
// draw each character in the string
|
||||
for( int i=0; i<iNumChars; i++ )
|
||||
{
|
||||
c = m_sText[i];
|
||||
LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice();
|
||||
|
||||
// Get what frame in the animation this character is.
|
||||
if( !m_mapCharToFrameNo.Lookup(c, uFrameNo) )
|
||||
uFrameNo = 0;
|
||||
|
||||
this->SetState( uFrameNo );
|
||||
this->SetX( (int)(iLeftEdge + iFrameWidth*(i+0.5f)) );
|
||||
// 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, 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 );
|
||||
|
||||
Sprite::Draw();
|
||||
}
|
||||
D3DXMATRIX matView;
|
||||
D3DXMatrixIdentity( &matView );
|
||||
pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -100, 100 );
|
||||
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -16,28 +16,32 @@
|
||||
#include "Sprite.h"
|
||||
#include "BitmapText.h"
|
||||
|
||||
#include "BitmapFont.h"
|
||||
|
||||
|
||||
|
||||
class BitmapText : public Sprite
|
||||
class BitmapText : public Actor
|
||||
{
|
||||
public:
|
||||
BitmapText();
|
||||
// virtual ~BitmapText();
|
||||
~BitmapText();
|
||||
|
||||
BOOL LoadFromFontFile( CString sFontFilePath );
|
||||
void SetText( CString sText );
|
||||
bool LoadFromFontName( CString sFontName );
|
||||
void SetText( CString sText ) { m_sText = 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();
|
||||
|
||||
protected:
|
||||
void ResetWidthAndHeight();
|
||||
|
||||
CString m_sFontFilePath;
|
||||
CString m_sFontName;
|
||||
CBitmapFont* m_pFont;
|
||||
CString m_sText; // the string that the font is displaying
|
||||
//Sprite m_Sprite; // holder for the graphic
|
||||
CMap<TCHAR, TCHAR&, UINT, UINT&> m_mapCharToFrameNo;
|
||||
D3DXCOLOR m_colorTop;
|
||||
D3DXCOLOR m_colorBottom;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -126,17 +126,17 @@ int IniFile::GetNumKeys()
|
||||
return keys.GetSize();
|
||||
}
|
||||
|
||||
//returns a refernce to the key for direct modification
|
||||
CMapStringToString& IniFile::GetKeyRef( CString keyname )
|
||||
//returns a pointer to the key for direct modification
|
||||
CMapStringToString* IniFile::GetKeyPointer( CString keyname )
|
||||
{
|
||||
int keynum = FindKey(keyname);
|
||||
if (keynum == -1)
|
||||
return keys[0];
|
||||
return NULL;
|
||||
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 keynum = FindKey(keyname);
|
||||
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
//returns number of keys currently in the ini
|
||||
int GetNumKeys();
|
||||
|
||||
//returns a refernce to the key for direct modification
|
||||
CMapStringToString& GetKeyRef( CString keyname );
|
||||
//returns a pointer to the key for direct modification
|
||||
CMapStringToString* GetKeyPointer( CString keyname );
|
||||
|
||||
//returns number of values stored for specified key
|
||||
int GetNumValues( CString keyname );
|
||||
|
||||
@@ -201,7 +201,7 @@ Player::Player()
|
||||
// combo
|
||||
m_bComboVisible = FALSE;
|
||||
m_sprCombo.LoadFromSpriteFile( COMBO_SPRITE );
|
||||
m_textComboNum.LoadFromFontFile( FONT_COMBO );
|
||||
m_textComboNum.LoadFromFontName( "Arial Bold" );
|
||||
m_textComboNum.SetText( "" );
|
||||
|
||||
// life meter
|
||||
@@ -210,7 +210,7 @@ Player::Player()
|
||||
|
||||
// score
|
||||
m_sprScoreFrame.LoadFromTexture( SCORE_FRAME_TEXTURE );
|
||||
m_textScoreNum.LoadFromFontFile( FONT_SCORE );
|
||||
m_textScoreNum.LoadFromFontName( "Arial Bold" );
|
||||
m_textScoreNum.SetText( " " );
|
||||
|
||||
|
||||
|
||||
@@ -61,26 +61,6 @@ VOID RageBitmapTexture::Create()
|
||||
|
||||
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
|
||||
if (FAILED (hr = D3DXCreateTextureFromFileEx(
|
||||
m_pd3dDevice,
|
||||
@@ -88,34 +68,32 @@ VOID RageBitmapTexture::Create()
|
||||
D3DX_DEFAULT, D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
D3DFMT_A4R4G4B4, //D3DFMT_UNKNOWN, // get format from source
|
||||
D3DFMT_A4R4G4B4, // this is our preferred format
|
||||
D3DPOOL_MANAGED,
|
||||
filterType, // don't blow up the image to the texure size
|
||||
filterType,
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0, // no color key
|
||||
&ddii,
|
||||
NULL, // no palette
|
||||
&m_pd3dTexture ) ) )
|
||||
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;
|
||||
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
|
||||
RageErrorHr( "Could not get level Description of D3DX texture!", hr );
|
||||
|
||||
m_uTextureWidth = ddsd.Width;
|
||||
m_uTextureHeight = ddsd.Height;
|
||||
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;
|
||||
// }
|
||||
|
||||
// save information about the texture
|
||||
m_uTextureWidth = ddsd.Width;
|
||||
m_uTextureHeight = ddsd.Height;
|
||||
m_TextureFormat = ddsd.Format;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -21,15 +21,15 @@
|
||||
// Includes
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
#include <dinput.h>
|
||||
#include "RageInput.h"
|
||||
#include <dinput.h>
|
||||
#include "RageUtil.h"
|
||||
|
||||
|
||||
LPRageInput INPUT = NULL;
|
||||
|
||||
|
||||
BOOL RageRawInput::LookupChar( TCHAR &char_out ) const
|
||||
BOOL DeviceInput::LookupChar( TCHAR &char_out ) const
|
||||
{
|
||||
switch( button )
|
||||
{
|
||||
@@ -103,7 +103,7 @@ BOOL RageRawInput::LookupChar( TCHAR &char_out ) const
|
||||
}
|
||||
|
||||
|
||||
CString RageRawInput::GetDescription() const
|
||||
CString DeviceInput::GetDescription() const
|
||||
{
|
||||
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
|
||||
#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
|
||||
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
|
||||
if( IS_LEFT( m_joyState[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 ) &&
|
||||
!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 ) &&
|
||||
!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 ) &&
|
||||
!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++ )
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "RageUtil.h"
|
||||
|
||||
|
||||
#define NUM_JOYSTICKS 4
|
||||
const int NUM_JOYSTICKS = 4;
|
||||
|
||||
// button byte codes for directional pad
|
||||
#define JOY_LEFT 101
|
||||
@@ -35,11 +35,11 @@
|
||||
#define DEVICE_JOYSTICK 2
|
||||
|
||||
|
||||
class RageRawInput
|
||||
class DeviceInput
|
||||
{
|
||||
public:
|
||||
RageRawInput() { device = device_no = button = just_pressed = 0; };
|
||||
RageRawInput( BYTE device,
|
||||
DeviceInput() { device = device_no = button = just_pressed = 0; };
|
||||
DeviceInput( BYTE device,
|
||||
BYTE device_no,
|
||||
BYTE button,
|
||||
BYTE just_pressed )
|
||||
@@ -49,20 +49,22 @@ public:
|
||||
this->button = button;
|
||||
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;
|
||||
split( sEncoding, "-", a);
|
||||
ASSERT( a.GetSize() == 3 );
|
||||
this->device = atoi( a[0] );
|
||||
this->device_no = atoi( a[1] );
|
||||
this->button = atoi( a[2] );
|
||||
};
|
||||
CString Encode() { return ssprintf("%u-%u-%u", device, device_no, button); };
|
||||
|
||||
BOOL LookupChar( TCHAR &char_out ) const;
|
||||
CString GetDescription() const;
|
||||
|
||||
BOOL IsBlank() { return device == DEVICE_NONE; };
|
||||
bool IsBlank() const { return device == DEVICE_NONE; };
|
||||
|
||||
BYTE device;
|
||||
BYTE device_no;
|
||||
@@ -72,7 +74,7 @@ public:
|
||||
|
||||
|
||||
|
||||
typedef CList<RageRawInput, RageRawInput&> RageRawInputList;
|
||||
typedef CArray<DeviceInput, DeviceInput&> DeviceInputArray;
|
||||
|
||||
|
||||
class RageInput
|
||||
@@ -118,7 +120,7 @@ public:
|
||||
// Release all DirectInput Resources
|
||||
VOID Release();
|
||||
// Get our Devices State
|
||||
HRESULT GetRawInput( RageRawInputList &listRawInput );
|
||||
HRESULT GetDeviceInputs( DeviceInputArray &listDeviceInputs );
|
||||
|
||||
LPDIRECTINPUT8 GetDirectInput() { return m_pDI; }
|
||||
LPDIRECTINPUTDEVICE8 GetMouseDevice() { return m_pMouse; }
|
||||
|
||||
@@ -344,9 +344,10 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer()
|
||||
m_pGB.QueryInterface(&m_pMP);
|
||||
m_pGB.QueryInterface(&m_pME);
|
||||
|
||||
// The graph is built, now get the set the output video width and height
|
||||
m_uImageWidth = m_pCTR->GetVidWidth();
|
||||
m_uImageHeight = m_pCTR->GetVidHeight();
|
||||
// The graph is built, now get the set the output video width and height.
|
||||
// The source and image width will always be the same since we can't scale the video
|
||||
m_uSourceWidth = m_pCTR->GetVidWidth();
|
||||
m_uSourceHeight = m_pCTR->GetVidHeight();
|
||||
|
||||
|
||||
return S_OK;
|
||||
@@ -360,7 +361,7 @@ HRESULT RageMovieTexture::CreateD3DTexture()
|
||||
// Create the texture that maps to this media type
|
||||
//////////////////////////////////////////////////
|
||||
if( FAILED( hr = D3DXCreateTexture(m_pd3dDevice,
|
||||
m_uImageWidth, m_uImageHeight,
|
||||
m_uSourceHeight, m_uSourceHeight,
|
||||
1, 0,
|
||||
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pd3dTexture ) ) )
|
||||
RageErrorHr( "Could not create the D3DX texture!", hr );
|
||||
|
||||
@@ -21,18 +21,14 @@
|
||||
// RageTexture constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
|
||||
m_uImageWidth( 0 ),
|
||||
m_uImageHeight( 0 ),
|
||||
m_uSourceWidth( 0 ),
|
||||
m_uSourceHeight( 0 ),
|
||||
m_uTextureWidth( 0 ),
|
||||
m_uTextureHeight( 0 ),
|
||||
m_uFramesWide( 1 ),
|
||||
m_uFramesHigh( 1 ),
|
||||
m_uImageFrameWidth( 0 ),
|
||||
m_uImageFrameHeight( 0 ),
|
||||
m_uTextureFrameWidth( 0 ),
|
||||
m_uTextureFrameHeight( 0 ),
|
||||
m_fWidthCorrectionRatio( 1 ),
|
||||
m_fHeightCorrectionRatio( 1 )
|
||||
m_uSourceFrameWidth( 0 ),
|
||||
m_uSourceFrameHeight( 0 )
|
||||
{
|
||||
// RageLog( "RageTexture::RageTexture()" );
|
||||
|
||||
@@ -56,48 +52,31 @@ RageTexture::~RageTexture()
|
||||
|
||||
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.
|
||||
///////////////////////////////////
|
||||
|
||||
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 j=0; j<m_uFramesHigh; j++ ) // traverse along Y
|
||||
{
|
||||
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;
|
||||
::SetRect( &rectCurFrame, (i+0)*m_uTextureFrameWidth, (j+0)*m_uTextureFrameHeight,
|
||||
(i+1)*m_uTextureFrameWidth, (j+1)*m_uTextureFrameHeight );
|
||||
m_FrameRects.Add( rectCurFrame ); // the index of this array element will be (i + j*m_uFramesWide)
|
||||
FRECT frect( (i+0)/(float)m_uFramesWide, // these will all be between 0.0 and 1.0
|
||||
(j+0)/(float)m_uFramesHigh,
|
||||
(i+1)/(float)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"
|
||||
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
|
||||
@@ -110,7 +89,7 @@ VOID RageTexture::GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWi
|
||||
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 :-)
|
||||
{
|
||||
uFramesWide = uFramesHigh = 1;
|
||||
*puFramesWide = *puFramesHigh = 1;
|
||||
return;
|
||||
}
|
||||
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( ' ' );
|
||||
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;
|
||||
}
|
||||
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' );
|
||||
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;
|
||||
}
|
||||
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
|
||||
sDimensionsString.Delete( 0, index_of_x+1 );
|
||||
uFramesHigh = (UINT) atoi( sDimensionsString );
|
||||
*puFramesHigh = (UINT) atoi( sDimensionsString );
|
||||
|
||||
if( uFramesWide == 0 ) uFramesWide = 1;
|
||||
if( uFramesHigh == 0 ) uFramesHigh = 1;
|
||||
if( *puFramesWide == 0 ) *puFramesWide = 1;
|
||||
if( *puFramesHigh == 0 ) *puFramesHigh = 1;
|
||||
}
|
||||
+25
-20
@@ -20,6 +20,18 @@ typedef RageTexture* LPRageTexture;
|
||||
#include <d3dx8.h>
|
||||
#include <assert.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;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -33,49 +45,42 @@ public:
|
||||
|
||||
virtual LPDIRECT3DTEXTURE8 GetD3DTexture() PURE;
|
||||
|
||||
UINT GetImageWidth() {return m_uImageWidth;};
|
||||
UINT GetImageHeight() {return m_uImageHeight;};
|
||||
UINT GetSourceWidth() {return m_uSourceWidth;};
|
||||
UINT GetSourceHeight() {return m_uSourceHeight;};
|
||||
UINT GetTextureWidth() {return m_uTextureWidth;};
|
||||
UINT GetTextureHeight() {return m_uTextureHeight;};
|
||||
|
||||
UINT GetFramesWide() {return m_uFramesWide;};
|
||||
UINT GetFramesHigh() {return m_uFramesHigh;};
|
||||
UINT GetImageFrameWidth() {return m_uImageFrameWidth;};
|
||||
UINT GetImageFrameHeight() {return m_uImageFrameHeight;};
|
||||
UINT GetTextureFrameWidth() {return m_uTextureFrameWidth;};
|
||||
UINT GetTextureFrameHeight() {return m_uTextureFrameHeight;};
|
||||
float GetWidthCorrectionRatio() {return m_fWidthCorrectionRatio;};
|
||||
float GetHeightCorrectionRatio() {return m_fHeightCorrectionRatio;};
|
||||
LPRECT GetFrameRect( UINT uFrameNo ) {return &m_FrameRects[uFrameNo];};
|
||||
UINT GetNumFrames() {return m_FrameRects.GetSize();};
|
||||
UINT GetSourceFrameWidth() {return m_uSourceFrameWidth;};
|
||||
UINT GetSourceFrameHeight() {return m_uSourceFrameHeight;};
|
||||
FRECT* GetTextureCoordRect( UINT uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
|
||||
UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
|
||||
CString GetFilePath() {return m_sFilePath;};
|
||||
|
||||
INT m_iRefCount;
|
||||
|
||||
protected:
|
||||
virtual VOID CreateFrameRects();
|
||||
virtual VOID GetFrameDimensionsFromFileName( CString sPath, UINT &uFramesWide, UINT &uFramesHigh ) const;
|
||||
virtual void CreateFrameRects();
|
||||
virtual void GetFrameDimensionsFromFileName( CString sPath, UINT* puFramesWide, UINT* puFramesHigh ) const;
|
||||
|
||||
CString m_sFilePath;
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
LPDIRECT3DTEXTURE8 m_pd3dTexture;
|
||||
|
||||
UINT m_uImageWidth, m_uImageHeight;
|
||||
UINT m_uTextureWidth, m_uTextureHeight;
|
||||
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image
|
||||
UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture holding the image
|
||||
D3DFORMAT m_TextureFormat;
|
||||
|
||||
// The number of frames of animation in each row and column of this texture.
|
||||
UINT m_uFramesWide, m_uFramesHigh;
|
||||
UINT m_uImageFrameWidth, m_uImageFrameHeight;
|
||||
UINT m_uTextureFrameWidth, m_uTextureFrameHeight;
|
||||
|
||||
float m_fWidthCorrectionRatio;
|
||||
float m_fHeightCorrectionRatio;
|
||||
UINT m_uSourceFrameWidth, m_uSourceFrameHeight;
|
||||
|
||||
|
||||
// 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
|
||||
// be in m_FrameRects[0..4].
|
||||
CArray<RECT, RECT&> m_FrameRects;
|
||||
CArray<FRECT, FRECT&> m_TextureCoordRects;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ void GetDirListing( CString sPath, CStringArray &AddTo, BOOL bOnlyDirs )
|
||||
}
|
||||
}
|
||||
|
||||
BOOL DoesFileExist( CString sPath )
|
||||
bool DoesFileExist( CString sPath )
|
||||
{
|
||||
RageLog( "DoesFileExist(%s)", sPath );
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ CString join(CString Deliminator, CStringArray& Source);
|
||||
|
||||
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);
|
||||
void SortCStringArray( CStringArray &AddTo, BOOL bSortAcsending = TRUE );
|
||||
|
||||
+38
-41
@@ -165,7 +165,7 @@ bool Song::LoadSongInfoFromBMSFile( CString sPath )
|
||||
}
|
||||
}
|
||||
|
||||
FillEmptyValuesWithDefaults();
|
||||
TidyUpData();
|
||||
|
||||
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_sArtist == "" ) m_sArtist = "Unknown artist";
|
||||
@@ -292,52 +292,49 @@ void Song::FillEmptyValuesWithDefaults()
|
||||
if( m_fBeatOffset == 0.0 )
|
||||
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";
|
||||
if( !DoesFileExist( m_sSongDir + m_sMusic ) )
|
||||
{
|
||||
// music.mp3 didn't exist, so search for any mp3 in the same dir
|
||||
CStringArray arrayMP3Files;
|
||||
GetDirListing( m_sSongDir + CString("*.mp3"), arrayMP3Files );
|
||||
CStringArray arrayPossibleMusic;
|
||||
GetDirListing( m_sSongDir + CString("*.wma"), arrayPossibleMusic );
|
||||
GetDirListing( m_sSongDir + CString("*.mp3"), arrayPossibleMusic );
|
||||
GetDirListing( m_sSongDir + CString("*.wav"), arrayPossibleMusic );
|
||||
|
||||
if( arrayMP3Files.GetSize() != 0 ) // we found a .mp3 file!
|
||||
m_sMusic = arrayMP3Files.GetAt( 0 );
|
||||
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()) );
|
||||
}
|
||||
if( arrayPossibleMusic.GetSize() != 0 ) // we found a match
|
||||
m_sMusic = arrayPossibleMusic.GetAt( 0 );
|
||||
else
|
||||
RageError( ssprintf("Music could not be found. Please check the Song file '%s' and verify the specified #MUSIC exists.", GetSongFilePath()) );
|
||||
}
|
||||
if( m_sSample == "" )
|
||||
if( m_sBanner == "" || !DoesFileExist(GetBannerPath()) )
|
||||
{
|
||||
m_sSample = "sample.mp3";
|
||||
if( !DoesFileExist( m_sSongDir + m_sSample ) )
|
||||
m_sSample = m_sMusic; // we assured above that the m_sMusic file exists
|
||||
}
|
||||
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 );
|
||||
CStringArray arrayPossibleBanners;
|
||||
GetDirListing( m_sSongDir + CString("*banner*.*"), arrayPossibleBanners );
|
||||
GetDirListing( m_sSongDir + CString("*.png"), arrayPossibleBanners );
|
||||
GetDirListing( m_sSongDir + CString("*.bmp"), arrayPossibleBanners );
|
||||
|
||||
if( arrayBMPFiles.GetSize() != 0 ) // we found a .bmp file!
|
||||
m_sBanner = arrayBMPFiles.GetAt( 0 );
|
||||
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()) );
|
||||
}
|
||||
}
|
||||
if( arrayPossibleBanners.GetSize() != 0 ) // we found a match
|
||||
m_sBanner = arrayPossibleBanners.GetAt( 0 );
|
||||
else
|
||||
RageError( ssprintf("Banner could not be found. Please check the Song file '%s' and verify the specified #BANNER exists.", GetSongFilePath()) );
|
||||
}
|
||||
if( m_sBackground == "" )
|
||||
if( m_sBackground == "" || !DoesFileExist(GetBackgroundPath()) )
|
||||
{
|
||||
m_sBackground = "background.bmp";
|
||||
if( !DoesFileExist( m_sSongDir + m_sBackground ) )
|
||||
m_sBackground = m_sBanner; // we assured above that the m_sBanner file exists
|
||||
CStringArray arrayPossibleBanners;
|
||||
GetDirListing( m_sSongDir + CString("*b*g*.*"), arrayPossibleBanners );
|
||||
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 );
|
||||
}
|
||||
*/
|
||||
+195
-56
@@ -31,7 +31,7 @@ void Sprite::Init()
|
||||
m_uCurState = 0;
|
||||
m_bIsAnimating = TRUE;
|
||||
m_fSecsIntoState = 0.0;
|
||||
m_bUsingCustomSrcRect = FALSE ;
|
||||
m_bUsingCustomTexCoordRect = FALSE ;
|
||||
m_Effect = no_effect ;
|
||||
m_fPercentBetweenColors = 0.0f ;
|
||||
m_bTweeningTowardEndColor = TRUE ;
|
||||
@@ -42,7 +42,6 @@ void Sprite::Init()
|
||||
m_fSpinSpeed = 2.0f ;
|
||||
m_fVibrationDistance = 5.0f ;
|
||||
m_bVisibleThisFrame = FALSE;
|
||||
m_bBlendAdd = FALSE;
|
||||
}
|
||||
|
||||
Sprite::~Sprite()
|
||||
@@ -130,8 +129,10 @@ BOOL Sprite::LoadTexture( CString sTexturePath )
|
||||
|
||||
m_pTexture = TM->LoadTexture( m_sTexturePath );
|
||||
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.
|
||||
for( UINT i=0; i<m_pTexture->GetNumFrames(); i++ )
|
||||
@@ -228,35 +229,22 @@ void Sprite::Draw()
|
||||
{
|
||||
if( m_pTexture == NULL )
|
||||
return;
|
||||
|
||||
UINT uFrameNo = m_uFrame[m_uCurState];
|
||||
|
||||
LPRECT pRectSrc;
|
||||
if( m_bUsingCustomSrcRect )
|
||||
pRectSrc = &m_rectCustomSrcRect;
|
||||
else
|
||||
pRectSrc = m_pTexture->GetFrameRect( uFrameNo );
|
||||
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];
|
||||
pTexCoordRect = m_pTexture->GetTextureCoordRect( 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();
|
||||
|
||||
D3DXCOLOR color = m_color;
|
||||
D3DXVECTOR2 pos = m_pos;
|
||||
D3DXVECTOR3 rotation = m_rotation;
|
||||
D3DXVECTOR2 scale = m_scale;
|
||||
bool bBlendAdd = false;
|
||||
|
||||
D3DXVECTOR2 rot_center;
|
||||
rot_center.x = GetZoomedWidth()/2.0f;
|
||||
rot_center.y = GetZoomedHeight()/2.0f;
|
||||
|
||||
D3DXCOLOR color = m_color;
|
||||
|
||||
|
||||
// update SpriteEffect
|
||||
// update properties based on SpriteEffects
|
||||
switch( m_Effect )
|
||||
{
|
||||
case no_effect:
|
||||
@@ -265,8 +253,11 @@ void Sprite::Draw()
|
||||
color = m_bTweeningTowardEndColor ? m_start_color : m_end_color;
|
||||
break;
|
||||
case camelion:
|
||||
color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors);
|
||||
break;
|
||||
case glowing:
|
||||
color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors);
|
||||
bBlendAdd = true;
|
||||
break;
|
||||
case wagging:
|
||||
rotation.z = m_fWagRadians * (FLOAT)sin(
|
||||
@@ -277,8 +268,8 @@ void Sprite::Draw()
|
||||
// nothing special needed
|
||||
break;
|
||||
case vibrating:
|
||||
translation.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
||||
translation.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
||||
pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
||||
pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom();
|
||||
break;
|
||||
case flickering:
|
||||
m_bVisibleThisFrame = !m_bVisibleThisFrame;
|
||||
@@ -287,15 +278,167 @@ void Sprite::Draw()
|
||||
break;
|
||||
}
|
||||
|
||||
SCREEN->DrawQuad( m_pTexture,
|
||||
pRectSrc,
|
||||
&scaling, // scaling
|
||||
&rot_center, // rotation center
|
||||
&rotation, // rotation
|
||||
&translation, // translation
|
||||
color,
|
||||
m_Effect == glowing ? op_add : op_modulate,
|
||||
m_bBlendAdd );
|
||||
|
||||
// make a 1x1 rect centered at the origin
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer();
|
||||
CUSTOMVERTEX* v;
|
||||
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
|
||||
v[0].p = D3DXVECTOR3( -0.5f, 0.5f, 0 ); // bottom left
|
||||
v[1].p = D3DXVECTOR3( -0.5f, -0.5f, 0 ); // top left
|
||||
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;
|
||||
}
|
||||
|
||||
void Sprite::SetCustomSrcRect( RECT newRect )
|
||||
void Sprite::SetCustomSrcRect( FRECT new_texcoord_frect )
|
||||
{
|
||||
m_bUsingCustomSrcRect = TRUE;
|
||||
m_rectCustomSrcRect = newRect;
|
||||
m_bUsingCustomTexCoordRect = true;
|
||||
m_CustomTexCoordRect = new_texcoord_frect;
|
||||
}
|
||||
|
||||
SetWidth( (FLOAT) RECTWIDTH(newRect) );
|
||||
SetHeight( (FLOAT) RECTHEIGHT(newRect) );
|
||||
|
||||
};
|
||||
|
||||
VOID Sprite::SetEffectNone()
|
||||
void Sprite::SetEffectNone()
|
||||
{
|
||||
m_Effect = no_effect;
|
||||
//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_start_color = Color;
|
||||
@@ -333,7 +472,7 @@ VOID Sprite::SetEffectBlinking( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D
|
||||
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_start_color = Color;
|
||||
@@ -343,7 +482,7 @@ VOID Sprite::SetEffectCamelion( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D
|
||||
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_start_color = Color;
|
||||
@@ -353,26 +492,26 @@ VOID Sprite::SetEffectGlowing( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3
|
||||
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
|
||||
}
|
||||
|
||||
VOID Sprite::SetEffectWagging( FLOAT fWagRadians, FLOAT fWagPeriod )
|
||||
void Sprite::SetEffectWagging( FLOAT fWagRadians, FLOAT fWagPeriod )
|
||||
{
|
||||
m_Effect = wagging;
|
||||
m_fWagRadians = fWagRadians;
|
||||
m_fWagPeriod = fWagPeriod;
|
||||
}
|
||||
|
||||
VOID Sprite::SetEffectSpinning( FLOAT fSpinSpeed /*radians per second*/ )
|
||||
void Sprite::SetEffectSpinning( FLOAT fSpinSpeed /*radians per second*/ )
|
||||
{
|
||||
m_Effect = spinning;
|
||||
m_fSpinSpeed = fSpinSpeed;
|
||||
}
|
||||
|
||||
VOID Sprite::SetEffectVibrating( FLOAT fVibrationDistance )
|
||||
void Sprite::SetEffectVibrating( FLOAT fVibrationDistance )
|
||||
{
|
||||
m_Effect = vibrating;
|
||||
m_fVibrationDistance = fVibrationDistance;
|
||||
}
|
||||
|
||||
VOID Sprite::SetEffectFlickering()
|
||||
void Sprite::SetEffectFlickering()
|
||||
{
|
||||
m_Effect = flickering;
|
||||
}
|
||||
|
||||
+12
-16
@@ -39,7 +39,7 @@ public:
|
||||
BOOL LoadFromTexture( CString sTexturePath );
|
||||
BOOL LoadFromSpriteFile( CString sSpritePath );
|
||||
|
||||
VOID PrintDebugInfo();
|
||||
void PrintDebugInfo();
|
||||
|
||||
virtual void Draw();
|
||||
virtual void Update( const FLOAT &fDeltaTime );
|
||||
@@ -52,28 +52,26 @@ public:
|
||||
CString GetTexturePath() { return m_sTexturePath; };
|
||||
|
||||
|
||||
VOID SetCustomSrcRect( RECT newRect ); // for cropping or flipping
|
||||
void SetCustomSrcRect( FRECT new_texcoord_frect ); // for cropping
|
||||
|
||||
|
||||
VOID SetEffectNone();
|
||||
VOID SetEffectBlinking( FLOAT fDeltaPercentPerSecond = 2.5,
|
||||
void SetEffectNone();
|
||||
void SetEffectBlinking( FLOAT fDeltaPercentPerSecond = 2.5,
|
||||
D3DXCOLOR Color = D3DXCOLOR(0.5f,0.5f,0.5f,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 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 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 );
|
||||
VOID SetEffectSpinning( FLOAT fRadsPerSpeed = 2.0 );
|
||||
VOID SetEffectVibrating( FLOAT fVibrationDistance = 5.0 );
|
||||
VOID SetEffectFlickering();
|
||||
void SetEffectSpinning( FLOAT fRadsPerSpeed = 2.0 );
|
||||
void SetEffectVibrating( FLOAT fVibrationDistance = 5.0 );
|
||||
void SetEffectFlickering();
|
||||
SpriteEffect GetEffect() { return m_Effect; };
|
||||
|
||||
VOID SetBlendMode( BOOL bBlendAdd ) { m_bBlendAdd = bBlendAdd; };
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
@@ -90,10 +88,8 @@ protected:
|
||||
BOOL m_bIsAnimating;
|
||||
FLOAT m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
|
||||
|
||||
BOOL m_bBlendAdd;
|
||||
|
||||
BOOL m_bUsingCustomSrcRect;
|
||||
RECT m_rectCustomSrcRect;
|
||||
BOOL m_bUsingCustomTexCoordRect;
|
||||
FRECT m_CustomTexCoordRect;
|
||||
|
||||
SpriteEffect m_Effect;
|
||||
|
||||
|
||||
+10
-10
@@ -397,19 +397,19 @@ void Update()
|
||||
WM->Update( fDeltaTime );
|
||||
|
||||
|
||||
static RageRawInputList listRawInput;
|
||||
listRawInput.RemoveAll();
|
||||
INPUT->GetRawInput( listRawInput );
|
||||
static DeviceInputArray diArray;
|
||||
diArray.RemoveAll();
|
||||
INPUT->GetDeviceInputs( diArray );
|
||||
|
||||
RageRawInput ri;
|
||||
DeviceInput di;
|
||||
PadInput pi;
|
||||
POSITION pos = listRawInput.GetHeadPosition();
|
||||
while( pos != NULL )
|
||||
for( int i=0; i<diArray.GetSize(); i++ )
|
||||
{
|
||||
ri = listRawInput.GetNext( pos );
|
||||
pi = GAMEINFO->RawToPad( ri );
|
||||
|
||||
WM->Input( ri, pi );
|
||||
di = diArray[i];
|
||||
if( GAMEINFO->DeviceToPad( di, pi ) )
|
||||
WM->Input( di, &pi ); // this di maps to a pi
|
||||
else
|
||||
WM->Input( di, NULL ); // this di doesn't map to a pi, so pass NULL
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -284,6 +284,14 @@ SOURCE=.\Banner.h
|
||||
# End 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
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -300,14 +308,6 @@ SOURCE=.\BlurredTitle.h
|
||||
# End 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
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -35,13 +35,12 @@ private:
|
||||
bool LoadSongInfoFromBMSFile( CString sPath );
|
||||
bool LoadSongInfoFromMSDFile( CString sPath );
|
||||
|
||||
void FillEmptyValuesWithDefaults();
|
||||
void TidyUpData();
|
||||
|
||||
public:
|
||||
CString GetSongFilePath() {return m_sSongDir + m_sSongFile; };
|
||||
CString GetSongFileDir() {return m_sSongDir; };
|
||||
CString GetMusicPath() {return m_sSongDir + m_sMusic; };
|
||||
CString GetSamplePath() {return m_sSongDir + m_sSample; };
|
||||
CString GetBannerPath() {return m_sSongDir + m_sBanner; };
|
||||
CString GetBackgroundPath() {return m_sSongDir + m_sBackground; };
|
||||
// Steps& GetStepsAt( int iIndex ) {return arraySteps[iIndex]; };
|
||||
@@ -67,7 +66,6 @@ private:
|
||||
float m_fBeatOffset;
|
||||
|
||||
CString m_sMusic;
|
||||
CString m_sSample;
|
||||
CString m_sBanner;
|
||||
CString m_sBackground;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user