remove support for diagonal banners; it's 2011, the theme should be taking care of banner rotation. plus this made things problematic for people wanting to use square banners.
This commit is contained in:
@@ -293,23 +293,14 @@ RageTextureID BannerCache::LoadCachedBanner( RString sBannerPath )
|
|||||||
ASSERT( pImage );
|
ASSERT( pImage );
|
||||||
|
|
||||||
int iSourceWidth = 0, iSourceHeight = 0;
|
int iSourceWidth = 0, iSourceHeight = 0;
|
||||||
bool bWasRotatedBanner = false;
|
|
||||||
BannerData.GetValue( sBannerPath, "Width", iSourceWidth );
|
BannerData.GetValue( sBannerPath, "Width", iSourceWidth );
|
||||||
BannerData.GetValue( sBannerPath, "Height", iSourceHeight );
|
BannerData.GetValue( sBannerPath, "Height", iSourceHeight );
|
||||||
BannerData.GetValue( sBannerPath, "Rotated", bWasRotatedBanner );
|
|
||||||
if( iSourceWidth == 0 || iSourceHeight == 0 )
|
if( iSourceWidth == 0 || iSourceHeight == 0 )
|
||||||
{
|
{
|
||||||
LOG->UserLog( "Cache file", sBannerPath, "couldn't be loaded." );
|
LOG->UserLog( "Cache file", sBannerPath, "couldn't be loaded." );
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bWasRotatedBanner )
|
|
||||||
{
|
|
||||||
/* We need to tell Sprite that this was originally a rotated
|
|
||||||
* sprite. */
|
|
||||||
ID.filename += "(was rotated)";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is the banner already in a texture? */
|
/* Is the banner already in a texture? */
|
||||||
if( TEXTUREMAN->IsTextureRegistered(ID) )
|
if( TEXTUREMAN->IsTextureRegistered(ID) )
|
||||||
return ID; /* It's all set. */
|
return ID; /* It's all set. */
|
||||||
@@ -383,50 +374,6 @@ void BannerCache::CacheBannerInternal( RString sBannerPath )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bWasRotatedBanner = false;
|
|
||||||
|
|
||||||
if( Sprite::IsDiagonalBanner(pImage->w , pImage->h) )
|
|
||||||
{
|
|
||||||
/* Ack. It's a diagonal banner. Problem: if we resize a diagonal banner, we
|
|
||||||
* get ugly checker patterns. We need to un-rotate it.
|
|
||||||
*
|
|
||||||
* If we spin the banner by hand, we need to do a linear filter, or the
|
|
||||||
* fade to the full resolution banner is misaligned, which looks strange.
|
|
||||||
*
|
|
||||||
* To do a linear filter, we need to lose the palette. Oh well.
|
|
||||||
*
|
|
||||||
* This also makes the banner take less memory, though that could also be
|
|
||||||
* done by RLEing the surface.
|
|
||||||
*/
|
|
||||||
//RageSurfaceUtils::ApplyHotPinkColorKey( pImage );
|
|
||||||
|
|
||||||
RageSurfaceUtils::ConvertSurface(pImage, pImage->w, pImage->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
|
||||||
|
|
||||||
RageSurface *dst = CreateSurface(
|
|
||||||
256, 64, pImage->format->BitsPerPixel,
|
|
||||||
pImage->format->Rmask, pImage->format->Gmask, pImage->format->Bmask, pImage->format->Amask );
|
|
||||||
|
|
||||||
if( pImage->format->BitsPerPixel == 8 )
|
|
||||||
{
|
|
||||||
ASSERT( pImage->format->palette );
|
|
||||||
dst->fmt.palette = pImage->fmt.palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float fCustomImageCoords[8] = {
|
|
||||||
0.02f, 0.78f, // top left
|
|
||||||
0.22f, 0.98f, // bottom left
|
|
||||||
0.98f, 0.22f, // bottom right
|
|
||||||
0.78f, 0.02f, // top right
|
|
||||||
};
|
|
||||||
|
|
||||||
RageSurfaceUtils::BlitTransform( pImage, dst, fCustomImageCoords );
|
|
||||||
|
|
||||||
delete pImage;
|
|
||||||
pImage = dst;
|
|
||||||
|
|
||||||
bWasRotatedBanner = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int iSourceWidth = pImage->w, iSourceHeight = pImage->h;
|
const int iSourceWidth = pImage->w, iSourceHeight = pImage->h;
|
||||||
|
|
||||||
int iWidth = pImage->w / 2, iHeight = pImage->h / 2;
|
int iWidth = pImage->w / 2, iHeight = pImage->h / 2;
|
||||||
@@ -504,8 +451,6 @@ void BannerCache::CacheBannerInternal( RString sBannerPath )
|
|||||||
BannerData.SetValue( sBannerPath, "Width", iSourceWidth );
|
BannerData.SetValue( sBannerPath, "Width", iSourceWidth );
|
||||||
BannerData.SetValue( sBannerPath, "Height", iSourceHeight );
|
BannerData.SetValue( sBannerPath, "Height", iSourceHeight );
|
||||||
BannerData.SetValue( sBannerPath, "FullHash", GetHashForFile( sBannerPath ) );
|
BannerData.SetValue( sBannerPath, "FullHash", GetHashForFile( sBannerPath ) );
|
||||||
/* Remember this, so we can hint Sprite. */
|
|
||||||
BannerData.SetValue( sBannerPath, "Rotated", bWasRotatedBanner );
|
|
||||||
BannerData.WriteFile( BANNER_CACHE_INDEX );
|
BannerData.WriteFile( BANNER_CACHE_INDEX );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -651,12 +651,6 @@ void Song::TidyUpData()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !HasBanner() && Sprite::IsDiagonalBanner(width, height) )
|
|
||||||
{
|
|
||||||
m_sBannerFile = arrayImages[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 )
|
if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 )
|
||||||
{
|
{
|
||||||
m_sBannerFile = arrayImages[i];
|
m_sBannerFile = arrayImages[i];
|
||||||
|
|||||||
+2
-83
@@ -862,44 +862,7 @@ void Sprite::ScaleToClipped( float fWidth, float fHeight )
|
|||||||
float fOriginalX = GetX();
|
float fOriginalX = GetX();
|
||||||
float fOriginalY = GetY();
|
float fOriginalY = GetY();
|
||||||
|
|
||||||
if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite
|
if( fWidth != -1 && fHeight != -1 )
|
||||||
{
|
|
||||||
float fCustomImageCoords[8] = {
|
|
||||||
0.02f, 0.78f, // top left
|
|
||||||
0.22f, 0.98f, // bottom left
|
|
||||||
0.98f, 0.22f, // bottom right
|
|
||||||
0.78f, 0.02f, // top right
|
|
||||||
};
|
|
||||||
Sprite::SetCustomImageCoords( fCustomImageCoords );
|
|
||||||
|
|
||||||
if( fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
|
||||||
m_size = RageVector2( fWidth, fHeight );
|
|
||||||
}
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
else if( m_pTexture->GetID().filename.find("(was rotated)") != string::npos &&
|
|
||||||
fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
|
||||||
/* Dumb hack: Normally, we crop all sprites except for diagonal banners,
|
|
||||||
* which are stretched. Low-res versions of banners need to do the same
|
|
||||||
* thing as their full resolution counterpart, so the crossfade looks right.
|
|
||||||
* However, low-res diagonal banners are un-rotated, to save space.
|
|
||||||
* BannerCache drops the above text into the "filename" (which is
|
|
||||||
* otherwise unused for these banners) to tell us this.
|
|
||||||
*/
|
|
||||||
Sprite::StopUsingCustomCoords();
|
|
||||||
m_size = RageVector2( fWidth, fHeight );
|
|
||||||
SetZoom( 1 );
|
|
||||||
}
|
|
||||||
else if( fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
{
|
||||||
// this is probably a background graphic or something not intended to be a CroppedSprite
|
// this is probably a background graphic or something not intended to be a CroppedSprite
|
||||||
Sprite::StopUsingCustomCoords();
|
Sprite::StopUsingCustomCoords();
|
||||||
@@ -963,44 +926,7 @@ void Sprite::CropTo( float fWidth, float fHeight )
|
|||||||
float fOriginalX = GetX();
|
float fOriginalX = GetX();
|
||||||
float fOriginalY = GetY();
|
float fOriginalY = GetY();
|
||||||
|
|
||||||
if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite
|
if( fWidth != -1 && fHeight != -1 )
|
||||||
{
|
|
||||||
float fCustomImageCoords[8] = {
|
|
||||||
0.02f, 0.78f, // top left
|
|
||||||
0.22f, 0.98f, // bottom left
|
|
||||||
0.98f, 0.22f, // bottom right
|
|
||||||
0.78f, 0.02f, // top right
|
|
||||||
};
|
|
||||||
Sprite::SetCustomImageCoords( fCustomImageCoords );
|
|
||||||
|
|
||||||
if( fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
|
||||||
m_size = RageVector2( fWidth, fHeight );
|
|
||||||
}
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
else if( m_pTexture->GetID().filename.find("(was rotated)") != string::npos &&
|
|
||||||
fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
|
||||||
/* Dumb hack: Normally, we crop all sprites except for diagonal banners,
|
|
||||||
* which are stretched. Low-res versions of banners need to do the same
|
|
||||||
* thing as their full resolution counterpart, so the crossfade looks right.
|
|
||||||
* However, low-res diagonal banners are un-rotated, to save space. BannerCache
|
|
||||||
* drops the above text into the "filename" (which is otherwise unused for
|
|
||||||
* these banners) to tell us this.
|
|
||||||
*/
|
|
||||||
Sprite::StopUsingCustomCoords();
|
|
||||||
m_size = RageVector2( fWidth, fHeight );
|
|
||||||
SetZoom( 1 );
|
|
||||||
}
|
|
||||||
else if( fWidth != -1 && fHeight != -1 )
|
|
||||||
{
|
{
|
||||||
// this is probably a background graphic or something not intended to be a CroppedSprite
|
// this is probably a background graphic or something not intended to be a CroppedSprite
|
||||||
Sprite::StopUsingCustomCoords();
|
Sprite::StopUsingCustomCoords();
|
||||||
@@ -1045,13 +971,6 @@ void Sprite::CropTo( float fWidth, float fHeight )
|
|||||||
}
|
}
|
||||||
// end magic
|
// end magic
|
||||||
|
|
||||||
|
|
||||||
bool Sprite::IsDiagonalBanner( int iWidth, int iHeight )
|
|
||||||
{
|
|
||||||
// A diagonal banner is a square. Give a couple pixels of leeway.
|
|
||||||
return iWidth >= 100 && abs(iWidth - iHeight) < 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::StretchTexCoords( float fX, float fY )
|
void Sprite::StretchTexCoords( float fX, float fY )
|
||||||
{
|
{
|
||||||
float fTexCoords[8];
|
float fTexCoords[8];
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ public:
|
|||||||
* @param fHeight the new height. */
|
* @param fHeight the new height. */
|
||||||
void ScaleToClipped( float fWidth, float fHeight );
|
void ScaleToClipped( float fWidth, float fHeight );
|
||||||
void CropTo( float fWidth, float fHeight );
|
void CropTo( float fWidth, float fHeight );
|
||||||
static bool IsDiagonalBanner( int iWidth, int iHeight );
|
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|||||||
Reference in New Issue
Block a user