changes made from 0.95 through 0.97

This commit is contained in:
Chris Danford
2001-12-28 10:15:59 +00:00
parent 43fb348d2c
commit 7f3a131195
29 changed files with 1232 additions and 410 deletions
+65 -40
View File
@@ -14,53 +14,78 @@
#include "Banner.h"
const CString TEXTURE_FALLBACK_BANNER = "Textures\\Fallback Banner.png";
bool Banner::LoadFromSong( Song &song )
{
Sprite::LoadFromTexture( song.GetBannerPath() );
if( song.HasBanner() )
Sprite::LoadFromTexture( song.GetBannerPath() );
else if( song.HasBackground() && !song.BackgroundIsAMovie() )
Sprite::LoadFromTexture( song.GetBackgroundPath() );
else
Sprite::LoadFromTexture( TEXTURE_FALLBACK_BANNER );
//Sprite::TurnShadowOff();
float fSourceWidth = (float)m_pTexture->GetSourceWidth();
float fSourceHeight = (float)m_pTexture->GetSourceHeight();
int iSourceWidth = m_pTexture->GetSourceWidth();
int iSourceHeight = 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
{
float fPercentageToCutOff = (this->GetZoomedWidth() - BANNER_WIDTH) / this->GetZoomedWidth();
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// 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 );
if( iSourceWidth == iSourceHeight ) // this is a SSR/DWI style banner
{
float fCustomTexCoords[8] = {
0.22f, 0.98f, // bottom left
0.02f, 0.78f, // top left
0.98f, 0.22f, // bottom right
0.78f, 0.02f, // top right
};
Sprite::SetCustomTexCoords( fCustomTexCoords );
SetWidth( BANNER_WIDTH );
SetHeight( BANNER_HEIGHT );
}
else // this is a normal sized banner
{
// first find the correct zoom
Sprite::ScaleToCover( CRect(0, 0,
(int)BANNER_WIDTH,
(int)BANNER_HEIGHT )
);
float fFinalZoom = this->GetZoom();
// find which dimension is larger
bool bXDimNeedsToBeCropped = GetZoomedWidth() > BANNER_WIDTH;
if( bXDimNeedsToBeCropped ) // crop X
{
float fPercentageToCutOff = (this->GetZoomedWidth() - BANNER_WIDTH) / this->GetZoomedWidth();
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// 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;
}