Initial checkin

This commit is contained in:
Chris Danford
2001-11-03 10:52:42 +00:00
parent 2f65fb99f0
commit 7caffe0c93
54 changed files with 7057 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
#include "stdafx.h"
//-----------------------------------------------------------------------------
// File: Banner.cpp
//
// Desc: The song's banner displayed in Song Select.
//
// Copyright (c) 2001 Chris Danford. All rights reserved.
//-----------------------------------------------------------------------------
#include "RageUtil.h"
#include "Banner.h"
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();
// find which dimension is larger
BOOL bYDimIsLarger = this->GetZoomedHeight() > BANNER_HEIGHT;
// now crop it
if( !bYDimIsLarger ) // crop X
{
int iScreenPixelsToCrop = (this->GetZoomedWidth() - BANNER_WIDTH) / 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() - BANNER_HEIGHT) / 2;
int iImagePixelsToCrop = roundf( iScreenPixelsToCrop / fFinalZoom );
RECT rectNewSrc;
::SetRect( &rectNewSrc, 0,
iImagePixelsToCrop,
iImageWidth,
iImageHeight - iImagePixelsToCrop );
Sprite::SetCustomSrcRect( rectNewSrc );
}
}
return TRUE;
}