Skip to content

Commit

Permalink
Revert "remove "odd dimensions" and "missing texture" warnings NOBODY…
Browse files Browse the repository at this point in the history
… HAS EVER CARED"

This reverts commit df2c7ad.
  • Loading branch information
MinaciousGrace committed Jun 10, 2017
1 parent 41e3550 commit d1d1829
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ActorMultiVertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,9 @@ class LunaActorMultiVertex: public Luna<ActorMultiVertex>
else
{
RageTextureID ID( SArg(1) );
TEXTUREMAN->DisableOddDimensionWarning();
p->LoadFromTexture( ID );
TEXTUREMAN->EnableOddDimensionWarning();
}
COMMON_RETURN_SELF;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
RageTextureID::TexPolicy OldPolicy = TEXTUREMAN->GetDefaultTexturePolicy();
TEXTUREMAN->SetDefaultTexturePolicy( RageTextureID::TEX_VOLATILE );

TEXTUREMAN->DisableOddDimensionWarning();

// Set to not show any BGChanges, whether scripted or random if m_bStaticBackground is on
if( !g_bSongBackgrounds || GAMESTATE->m_SongOptions.GetCurrent().m_bStaticBackground )
{
Expand Down Expand Up @@ -689,6 +691,8 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
// Re-sort.
BackgroundUtil::SortBackgroundChangesArray( mainlayer.m_aBGChanges );

TEXTUREMAN->EnableOddDimensionWarning();

if( m_pDancingCharacters )
m_pDancingCharacters->LoadNextSong();

Expand Down
2 changes: 2 additions & 0 deletions src/Banner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ void Banner::Load( RageTextureID ID, bool bIsBanner )
m_fPercentScrolling = 0;
m_bScrolling = false;

TEXTUREMAN->DisableOddDimensionWarning();
TEXTUREMAN->VolatileTexture( ID );
Sprite::Load( ID );
TEXTUREMAN->EnableOddDimensionWarning();
};

void Banner::LoadFromCachedBanner( const RString &sPath )
Expand Down
60 changes: 60 additions & 0 deletions src/RageBitmapTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ void RageBitmapTexture::Create()
/* Tolerate corrupt/unknown images. */
if( pImg == NULL )
{
RString warning = ssprintf("RageBitmapTexture: Couldn't load %s: %s",
actualID.filename.c_str(), error.c_str());
LOG->Warn("%s", warning.c_str());
Dialog::OK(warning, "missing_texture");
pImg = RageSurfaceUtils::MakeDummySurface( 64, 64 );
ASSERT( pImg != NULL );
}
Expand Down Expand Up @@ -265,6 +269,62 @@ void RageBitmapTexture::Create()
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, pImg, actualID.bMipMaps );

CreateFrameRects();


{
// Enforce frames in the image have even dimensions.
// Otherwise, pixel/texel alignment will be off.
int iDimensionMultiple = 2;

if( sHintString.find("doubleres") != string::npos )
{
iDimensionMultiple = 4;
}

bool bRunCheck = true;

// Don't check if the artist intentionally blanked the image by making it very tiny.
if( this->GetSourceWidth()<=iDimensionMultiple || this->GetSourceHeight()<=iDimensionMultiple )
bRunCheck = false;

// HACK: Don't check song graphics. Many of them are weird dimensions.
if( !TEXTUREMAN->GetOddDimensionWarning() )
bRunCheck = false;

// Don't check if this is the screen texture, the theme can't do anything
// about it. -Kyz
if(actualID == TEXTUREMAN->GetScreenTextureID())
{
bRunCheck= false;
}

if( bRunCheck )
{
float fFrameWidth = this->GetSourceWidth() / static_cast<float>(this->GetFramesWide());
float fFrameHeight = this->GetSourceHeight() / static_cast<float>(this->GetFramesHigh());
float fBetterFrameWidth = ceilf(fFrameWidth/iDimensionMultiple) * iDimensionMultiple;
float fBetterFrameHeight = ceilf(fFrameHeight/iDimensionMultiple) * iDimensionMultiple;
float fBetterSourceWidth = this->GetFramesWide() * fBetterFrameWidth;
float fBetterSourceHeight = this->GetFramesHigh() * fBetterFrameHeight;
if( fFrameWidth!=fBetterFrameWidth || fFrameHeight!=fBetterFrameHeight )
{
RString sWarning = ssprintf(
"The graphic '%s' has frame dimensions that aren't a multiple of %d.\n"
"The entire image is %dx%d and frame size is %.1fx%.1f.\n"
"Image quality will be much improved if you resize the graphic to %.0fx%.0f, which is a frame size of %.0fx%.0f.",
actualID.filename.c_str(),
iDimensionMultiple,
this->GetSourceWidth(), this->GetSourceHeight(),
fFrameWidth, fFrameHeight,
fBetterSourceWidth, fBetterSourceHeight,
fBetterFrameWidth, fBetterFrameHeight );
LOG->Warn( "%s", sWarning.c_str() );
Dialog::OK( sWarning, "FRAME_DIMENSIONS_WARNING" );
}
}
}


delete pImg;

// Check for hints that override the apparent "size".
Expand Down
5 changes: 5 additions & 0 deletions src/RageTextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace
};

RageTextureManager::RageTextureManager():
m_iNoWarnAboutOddDimensions(0),
m_TexturePolicy(RageTextureID::TEX_DEFAULT) {}

RageTextureManager::~RageTextureManager()
Expand Down Expand Up @@ -344,6 +345,8 @@ void RageTextureManager::GarbageCollect( GCType type )

void RageTextureManager::ReloadAll()
{
DisableOddDimensionWarning();

/* Let's get rid of all unreferenced textures, so we don't reload a
* ton of cached data that we're not necessarily going to use. */
DoDelayedDelete();
Expand All @@ -352,6 +355,8 @@ void RageTextureManager::ReloadAll()
{
i->second->Reload();
}

EnableOddDimensionWarning();
}

/* In some cases, changing the display mode will reset the rendering context,
Expand Down
5 changes: 5 additions & 0 deletions src/RageTextureManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class RageTextureManager
void AdjustTextureID( RageTextureID &ID ) const;
void DiagnosticOutput() const;

void DisableOddDimensionWarning() { m_iNoWarnAboutOddDimensions++; }
void EnableOddDimensionWarning() { m_iNoWarnAboutOddDimensions--; }
bool GetOddDimensionWarning() const { return m_iNoWarnAboutOddDimensions == 0; }

RageTextureID GetDefaultTextureID();
RageTextureID GetScreenTextureID();
RageSurface* GetScreenSurface();
Expand All @@ -90,6 +94,7 @@ class RageTextureManager
RageTexture* LoadTextureInternal( RageTextureID ID );

RageTextureManagerPrefs m_Prefs;
int m_iNoWarnAboutOddDimensions;
RageTextureID::TexPolicy m_TexturePolicy;
};

Expand Down
2 changes: 2 additions & 0 deletions src/ScreenSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ void ScreenSelectMusic::CheckBackgroundRequests( bool bForce )

if( !sCDTitlePath.empty() )
{
TEXTUREMAN->DisableOddDimensionWarning();
m_sprCDTitleFront.Load( sCDTitlePath );
m_sprCDTitleBack.Load( sCDTitlePath );
TEXTUREMAN->EnableOddDimensionWarning();
}

m_BackgroundLoader.FinishedWithCachedFile( g_sCDTitlePath );
Expand Down
4 changes: 4 additions & 0 deletions src/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,13 +1084,17 @@ class LunaSprite: public Luna<Sprite>
static int LoadBackground(T* p, lua_State *L)
{
RageTextureID ID(SArg(1));
TEXTUREMAN->DisableOddDimensionWarning();
p->Load(Sprite::SongBGTexture(ID));
TEXTUREMAN->EnableOddDimensionWarning();
return 1;
}
static int LoadBanner( T* p, lua_State *L )
{
RageTextureID ID( SArg(1) );
TEXTUREMAN->DisableOddDimensionWarning();
p->Load( Sprite::SongBannerTexture(ID) );
TEXTUREMAN->EnableOddDimensionWarning();
return 1;
}

Expand Down

0 comments on commit d1d1829

Please sign in to comment.