2001-11-03 10:52:42 +00:00
|
|
|
#include "stdafx.h"
|
2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: Banner.h
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-04 19:34:28 +00:00
|
|
|
Desc: The song's banner displayed in SelectSong.
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-04 19:34:28 +00:00
|
|
|
Copyright (c) 2001 Chris Danford. All rights reserved.
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
|
|
|
|
|
#include "Banner.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-25 04:31:44 +00:00
|
|
|
bool Banner::LoadFromSong( Song &song )
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
2001-11-25 04:31:44 +00:00
|
|
|
Sprite::LoadFromTexture( song.GetBannerPath() );
|
2001-12-19 01:50:57 +00:00
|
|
|
//Sprite::TurnShadowOff();
|
2001-11-25 04:31:44 +00:00
|
|
|
|
|
|
|
|
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
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
2001-11-25 04:31:44 +00:00
|
|
|
float fPercentageToCutOff = (this->GetZoomedWidth() - BANNER_WIDTH) / this->GetZoomedWidth();
|
|
|
|
|
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
|
2001-11-21 03:21:00 +00:00
|
|
|
|
2001-11-25 04:31:44 +00:00
|
|
|
// generate a rectangle with new texture coordinates
|
|
|
|
|
FRECT frectNewSrc( fPercentageToCutOffEachSide,
|
|
|
|
|
0,
|
|
|
|
|
1 - fPercentageToCutOffEachSide,
|
|
|
|
|
1 );
|
|
|
|
|
Sprite::SetCustomSrcRect( frectNewSrc );
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|
2001-11-25 04:31:44 +00:00
|
|
|
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 );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-25 04:31:44 +00:00
|
|
|
|
|
|
|
|
return true;
|
2001-11-03 10:52:42 +00:00
|
|
|
}
|