no message
This commit is contained in:
@@ -20,22 +20,28 @@ BOOL Banner::LoadFromSong( Song &song )
|
||||
BOOL bResult = Sprite::LoadFromTexture( song.GetBannerPath() );
|
||||
if( bResult )
|
||||
{
|
||||
RECT r;
|
||||
int iImageWidth = this->GetZoomedWidth();
|
||||
int iImageHeight = this->GetZoomedHeight();
|
||||
|
||||
// first find the correct zoom
|
||||
::SetRect( &r, 0, 0, BANNER_WIDTH, BANNER_HEIGHT );
|
||||
Sprite::ScaleToCover( &r );
|
||||
FLOAT fFinalZoom = this->GetZoom();
|
||||
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 fFinalZoom = this->GetZoom();
|
||||
|
||||
// find which dimension is larger
|
||||
BOOL bYDimIsLarger = this->GetZoomedHeight() > BANNER_HEIGHT;
|
||||
BOOL bYDimIsLarger = this->GetZoomedHeight() > iCorrectedBannerHeight;
|
||||
// BOOL bYDimIsLarger = this->GetZoomedHeight() > BANNER_HEIGHT;
|
||||
|
||||
// now crop it
|
||||
if( !bYDimIsLarger ) // crop X
|
||||
{
|
||||
int iScreenPixelsToCrop = (this->GetZoomedWidth() - BANNER_WIDTH) / 2;
|
||||
int iScreenPixelsToCrop = (this->GetZoomedWidth() - iCorrectedBannerWidth) / 2;
|
||||
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom );
|
||||
RECT rectNewSrc;
|
||||
::SetRect( &rectNewSrc, iImagePixelsToCrop,
|
||||
@@ -46,7 +52,7 @@ BOOL Banner::LoadFromSong( Song &song )
|
||||
}
|
||||
else // crop Y
|
||||
{
|
||||
int iScreenPixelsToCrop = (this->GetZoomedHeight() - BANNER_HEIGHT) / 2;
|
||||
int iScreenPixelsToCrop = (this->GetZoomedHeight() - iCorrectedBannerHeight) / 2;
|
||||
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom );
|
||||
RECT rectNewSrc;
|
||||
::SetRect( &rectNewSrc, 0,
|
||||
|
||||
@@ -83,7 +83,7 @@ void BitmapText::Draw()
|
||||
int iOriginalCenterX = (int)this->GetX();
|
||||
FLOAT fOriginalWidth = m_size.x;
|
||||
|
||||
int iFrameWidth = (int)( m_pTexture->GetFrameWidth() * this->GetZoom() );
|
||||
int iFrameWidth = (int)( m_pTexture->GetImageFrameWidth() * this->GetZoom() );
|
||||
m_size.x = (FLOAT)iFrameWidth;
|
||||
|
||||
// draw each character in the string
|
||||
@@ -108,6 +108,6 @@ void BitmapText::Draw()
|
||||
|
||||
void BitmapText::ResetWidthAndHeight()
|
||||
{
|
||||
m_size.x = (FLOAT)m_pTexture->GetFrameWidth() * m_sText.GetLength();
|
||||
m_size.y = (FLOAT)m_pTexture->GetFrameHeight();
|
||||
m_size.x = (FLOAT)m_pTexture->GetImageFrameWidth() * m_sText.GetLength();
|
||||
m_size.y = (FLOAT)m_pTexture->GetImageFrameHeight();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,26 @@ 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,
|
||||
@@ -70,8 +90,8 @@ VOID RageBitmapTexture::Create()
|
||||
0,
|
||||
D3DFMT_A4R4G4B4, //D3DFMT_UNKNOWN, // get format from source
|
||||
D3DPOOL_MANAGED,
|
||||
D3DX_FILTER_NONE, // don't blow up the image to the texure size
|
||||
D3DX_FILTER_NONE,
|
||||
filterType, // don't blow up the image to the texure size
|
||||
filterType,
|
||||
0, // no color key
|
||||
&ddii,
|
||||
NULL, // no palette
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#define _RAGEINPUT_H_
|
||||
|
||||
|
||||
#ifndef DIRECTINPUT_VERSION
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#endif
|
||||
|
||||
#include <dinput.h>
|
||||
#include "RageUtil.h"
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
// Link with the DirectShow base class libraries
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#pragma comment(lib, "C:\\Program Files\\DX8aSDK\\samples\\Multimedia\\DirectShow\\BaseClasses\\Debug\\strmbasd.lib")
|
||||
#pragma comment(lib, "strmbasd.lib")
|
||||
#else
|
||||
#pragma comment(lib, "C:\\Program Files\\DX8aSDK\\samples\\Multimedia\\DirectShow\\BaseClasses\\Release\\strmbase.lib")
|
||||
#pragma comment(lib, "strmbase.lib")
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -27,8 +27,12 @@ RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
|
||||
m_uTextureHeight( 0 ),
|
||||
m_uFramesWide( 1 ),
|
||||
m_uFramesHigh( 1 ),
|
||||
m_uFrameWidth( 0 ),
|
||||
m_uFrameHeight( 0 )
|
||||
m_uImageFrameWidth( 0 ),
|
||||
m_uImageFrameHeight( 0 ),
|
||||
m_uTextureFrameWidth( 0 ),
|
||||
m_uTextureFrameHeight( 0 ),
|
||||
m_fWidthCorrectionRatio( 1 ),
|
||||
m_fHeightCorrectionRatio( 1 )
|
||||
{
|
||||
// RageLog( "RageTexture::RageTexture()" );
|
||||
|
||||
@@ -58,20 +62,36 @@ VOID RageTexture::CreateFrameRects()
|
||||
// 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
|
||||
m_uFrameWidth = GetImageWidth() / m_uFramesWide;
|
||||
m_uFrameHeight= GetImageHeight() / m_uFramesHigh;
|
||||
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++ )
|
||||
{
|
||||
RECT rectCurFrame;
|
||||
::SetRect( &rectCurFrame, (i+0)*m_uFrameWidth, (j+0)*m_uFrameHeight,
|
||||
(i+1)*m_uFrameWidth, (j+1)*m_uFrameHeight );
|
||||
::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)
|
||||
|
||||
// RageLog( "Adding frame#%d: %d %d %d %d", (i + j*m_uFramesWide), rectCurFrame.left, rectCurFrame.top, rectCurFrame.right, rectCurFrame.bottom );
|
||||
RageLog( "!!!! Adding frame#%d: %d %d %d %d", (i + j*m_uFramesWide), rectCurFrame.left, rectCurFrame.top, rectCurFrame.right, rectCurFrame.bottom );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,12 @@ public:
|
||||
|
||||
UINT GetFramesWide() {return m_uFramesWide;};
|
||||
UINT GetFramesHigh() {return m_uFramesHigh;};
|
||||
UINT GetFrameWidth() {return m_uFrameWidth;};
|
||||
UINT GetFrameHeight() {return m_uFrameHeight;};
|
||||
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();};
|
||||
CString GetFilePath() {return m_sFilePath;};
|
||||
@@ -62,7 +66,11 @@ protected:
|
||||
|
||||
// The number of frames of animation in each row and column of this texture.
|
||||
UINT m_uFramesWide, m_uFramesHigh;
|
||||
UINT m_uFrameWidth, m_uFrameHeight;
|
||||
UINT m_uImageFrameWidth, m_uImageFrameHeight;
|
||||
UINT m_uTextureFrameWidth, m_uTextureFrameHeight;
|
||||
|
||||
float m_fWidthCorrectionRatio;
|
||||
float m_fHeightCorrectionRatio;
|
||||
|
||||
// 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
|
||||
|
||||
@@ -96,7 +96,7 @@ void RageLog( LPCTSTR fmt, ...);
|
||||
// Error helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "dxerr8.h"
|
||||
#pragma comment(lib, "dxerr8.lib")
|
||||
#pragma comment(lib, "DxErr8.lib")
|
||||
|
||||
|
||||
VOID DisplayErrorAndDie( CString sError );
|
||||
|
||||
@@ -324,6 +324,7 @@ void Song::FillEmptyValuesWithDefaults()
|
||||
// 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!
|
||||
m_sBanner = arrayBMPFiles.GetAt( 0 );
|
||||
|
||||
@@ -130,8 +130,8 @@ BOOL Sprite::LoadTexture( CString sTexturePath )
|
||||
|
||||
m_pTexture = TM->LoadTexture( m_sTexturePath );
|
||||
assert( m_pTexture != NULL );
|
||||
SetWidth( (FLOAT)m_pTexture->GetFrameWidth() );
|
||||
SetHeight( (FLOAT)m_pTexture->GetFrameHeight() );
|
||||
SetWidth( (FLOAT)m_pTexture->GetImageFrameWidth() );
|
||||
SetHeight( (FLOAT)m_pTexture->GetImageFrameHeight() );
|
||||
|
||||
// Assume the frames of this animation play in sequential order with 0.2 second delay.
|
||||
for( UINT i=0; i<m_pTexture->GetNumFrames(); i++ )
|
||||
@@ -240,8 +240,8 @@ void Sprite::Draw()
|
||||
//::SetRect( &rectSrc, 0, 0, m_pTexture->GetImageWidth(), m_pTexture->GetImageHeight() );
|
||||
|
||||
D3DXVECTOR2 scaling;
|
||||
scaling.x = GetZoom();
|
||||
scaling.y = GetZoom();
|
||||
scaling.x = GetZoom() * m_pTexture->GetWidthCorrectionRatio();
|
||||
scaling.y = GetZoom() * m_pTexture->GetHeightCorrectionRatio();
|
||||
|
||||
D3DXVECTOR2 translation;
|
||||
translation.x = (float)GetLeftEdge();
|
||||
|
||||
@@ -157,7 +157,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow )
|
||||
Render();
|
||||
ShowFrame();
|
||||
//if( !g_bFullscreen )
|
||||
::Sleep(5); // give some time for the movie
|
||||
::Sleep(16); // give some time for the movie
|
||||
}
|
||||
} // end while( WM_QUIT != msg.message )
|
||||
|
||||
|
||||
@@ -374,14 +374,6 @@ SOURCE=.\Steps.cpp
|
||||
|
||||
SOURCE=.\Steps.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Text.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Text.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "File Types"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user