From 27a6ebd1874ed0fccfb25871427f22e6d50ad222 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Fri, 20 May 2011 00:19:51 -0500 Subject: [PATCH] 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. --- src/BannerCache.cpp | 55 ----------------------------- src/Song.cpp | 6 ---- src/Sprite.cpp | 85 ++------------------------------------------- src/Sprite.h | 1 - 4 files changed, 2 insertions(+), 145 deletions(-) diff --git a/src/BannerCache.cpp b/src/BannerCache.cpp index ffcc4a3e6f..7b8b08110a 100644 --- a/src/BannerCache.cpp +++ b/src/BannerCache.cpp @@ -293,23 +293,14 @@ RageTextureID BannerCache::LoadCachedBanner( RString sBannerPath ) ASSERT( pImage ); int iSourceWidth = 0, iSourceHeight = 0; - bool bWasRotatedBanner = false; BannerData.GetValue( sBannerPath, "Width", iSourceWidth ); BannerData.GetValue( sBannerPath, "Height", iSourceHeight ); - BannerData.GetValue( sBannerPath, "Rotated", bWasRotatedBanner ); if( iSourceWidth == 0 || iSourceHeight == 0 ) { LOG->UserLog( "Cache file", sBannerPath, "couldn't be loaded." ); 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? */ if( TEXTUREMAN->IsTextureRegistered(ID) ) return ID; /* It's all set. */ @@ -383,50 +374,6 @@ void BannerCache::CacheBannerInternal( RString sBannerPath ) 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; 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, "Height", iSourceHeight ); BannerData.SetValue( sBannerPath, "FullHash", GetHashForFile( sBannerPath ) ); - /* Remember this, so we can hint Sprite. */ - BannerData.SetValue( sBannerPath, "Rotated", bWasRotatedBanner ); BannerData.WriteFile( BANNER_CACHE_INDEX ); } diff --git a/src/Song.cpp b/src/Song.cpp index fe1ec70663..3a962e72c4 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -651,12 +651,6 @@ void Song::TidyUpData() continue; } - if( !HasBanner() && Sprite::IsDiagonalBanner(width, height) ) - { - m_sBannerFile = arrayImages[i]; - continue; - } - if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 ) { m_sBannerFile = arrayImages[i]; diff --git a/src/Sprite.cpp b/src/Sprite.cpp index 6d0c4df7ae..ffd16e6d32 100644 --- a/src/Sprite.cpp +++ b/src/Sprite.cpp @@ -862,44 +862,7 @@ void Sprite::ScaleToClipped( float fWidth, float fHeight ) float fOriginalX = GetX(); float fOriginalY = GetY(); - if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite - { - 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 ) + if( fWidth != -1 && fHeight != -1 ) { // this is probably a background graphic or something not intended to be a CroppedSprite Sprite::StopUsingCustomCoords(); @@ -963,44 +926,7 @@ void Sprite::CropTo( float fWidth, float fHeight ) float fOriginalX = GetX(); float fOriginalY = GetY(); - if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite - { - 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 ) + if( fWidth != -1 && fHeight != -1 ) { // this is probably a background graphic or something not intended to be a CroppedSprite Sprite::StopUsingCustomCoords(); @@ -1045,13 +971,6 @@ void Sprite::CropTo( float fWidth, float fHeight ) } // 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 ) { float fTexCoords[8]; diff --git a/src/Sprite.h b/src/Sprite.h index 69e28ea790..7247171f70 100644 --- a/src/Sprite.h +++ b/src/Sprite.h @@ -67,7 +67,6 @@ public: * @param fHeight the new height. */ void ScaleToClipped( float fWidth, float fHeight ); void CropTo( float fWidth, float fHeight ); - static bool IsDiagonalBanner( int iWidth, int iHeight ); // Commands virtual void PushSelf( lua_State *L );