make ScaleTo work on CroppedSprites
This commit is contained in:
@@ -15,10 +15,12 @@
|
|||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "RageBitmapTexture.h"
|
#include "RageBitmapTexture.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
CroppedSprite::CroppedSprite()
|
CroppedSprite::CroppedSprite()
|
||||||
{
|
{
|
||||||
m_fCropWidth = m_fCropHeight = 100;
|
/* By default, crop to the size of the image. */
|
||||||
|
m_fCropWidth = m_fCropHeight = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CroppedSprite::Load( RageTextureID ID )
|
bool CroppedSprite::Load( RageTextureID ID )
|
||||||
@@ -58,11 +60,20 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
|
|||||||
};
|
};
|
||||||
Sprite::SetCustomImageCoords( fCustomImageCoords );
|
Sprite::SetCustomImageCoords( fCustomImageCoords );
|
||||||
|
|
||||||
m_size = RageVector2( m_fCropWidth, m_fCropHeight );
|
if( m_fCropWidth != -1 && m_fCropHeight != -1)
|
||||||
|
m_size = RageVector2( m_fCropWidth, m_fCropHeight );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If no crop size is set, then we're only being used to crop diagonal
|
||||||
|
* banners so they look like regular ones. We don't actually care about
|
||||||
|
* the size of the image, only that it has an aspect ratio of 4:1. */
|
||||||
|
m_size = RageVector2(256, 64);
|
||||||
|
}
|
||||||
SetZoom( 1 );
|
SetZoom( 1 );
|
||||||
}
|
}
|
||||||
else // this is probably a background graphic or something not intended to be a CroppedSprite
|
else if( m_fCropWidth != -1 && m_fCropHeight != -1)
|
||||||
{
|
{
|
||||||
|
// this is probably a background graphic or something not intended to be a CroppedSprite
|
||||||
Sprite::StopUsingCustomCoords();
|
Sprite::StopUsingCustomCoords();
|
||||||
|
|
||||||
// first find the correct zoom
|
// first find the correct zoom
|
||||||
|
|||||||
Reference in New Issue
Block a user