From 2713332a43b5e8577e73816cb485e9638b8470c8 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 29 Jan 2002 21:56:14 +0000 Subject: [PATCH] no message --- stepmania/src/Banner.cpp | 57 +++++++++++++++++------------ stepmania/src/Banner.h | 6 +-- stepmania/src/RageBitmapTexture.cpp | 15 +++++--- stepmania/src/Sprite.cpp | 28 +++++++++++++- stepmania/src/Sprite.h | 7 +++- stepmania/src/StepMania.cpp | 13 ++++++- 6 files changed, 90 insertions(+), 36 deletions(-) diff --git a/stepmania/src/Banner.cpp b/stepmania/src/Banner.cpp index edce6f36b6..e02668d7ad 100644 --- a/stepmania/src/Banner.cpp +++ b/stepmania/src/Banner.cpp @@ -17,34 +17,39 @@ -bool Banner::LoadFromSong( Song &song ) +bool Banner::LoadFromSong( Song* pSong ) // NULL means no song { - if( song.HasBanner() ) - Sprite::LoadFromTexture( song.GetBannerPath() ); - else if( song.HasBackground() ) - Sprite::LoadFromTexture( song.GetBackgroundPath() ); + if( pSong == NULL ) + Sprite::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER) ); + if( pSong->HasBanner() ) + Sprite::Load( pSong->GetBannerPath() ); + else if( pSong->HasBackground() ) + Sprite::Load( pSong->GetBackgroundPath() ); else - Sprite::LoadFromTexture( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER) ); + Sprite::Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BANNER) ); - //Sprite::TurnShadowOff(); + Sprite::TurnShadowOff(); - int iSourceWidth = m_pTexture->GetSourceWidth(); - int iSourceHeight = m_pTexture->GetSourceHeight(); + int iImageWidth = m_pTexture->GetImageWidth(); + int iImageHeight = m_pTexture->GetImageHeight(); + // save the original X&Y. We're going to resore them later. + float fOriginalX = GetX(); + float fOriginalY = GetY(); - if( iSourceWidth == iSourceHeight ) // this is a SSR/DWI style banner + if( iImageWidth == iImageHeight ) // this is a SSR/DWI style banner { - float fCustomTexCoords[8] = { + float fCustomImageCoords[8] = { 0.22f, 0.98f, // bottom left 0.02f, 0.78f, // top left 0.98f, 0.22f, // bottom right 0.78f, 0.02f, // top right }; - Sprite::SetCustomTexCoords( fCustomTexCoords ); + SetCustomImageCoords( fCustomImageCoords ); SetWidth( BANNER_WIDTH ); SetHeight( BANNER_HEIGHT ); - + SetZoom( 1 ); } else // this is a normal sized banner { @@ -65,11 +70,12 @@ bool Banner::LoadFromSong( Song &song ) float fPercentageToCutOffEachSide = fPercentageToCutOff / 2; // generate a rectangle with new texture coordinates - FRECT frectNewSrc( fPercentageToCutOffEachSide, - 0, - 1 - fPercentageToCutOffEachSide, - 1 ); - Sprite::SetCustomSrcRect( frectNewSrc ); + FRECT fCustomImageCoords( + fPercentageToCutOffEachSide, + 0, + 1 - fPercentageToCutOffEachSide, + 1 ); + SetCustomImageRect( fCustomImageCoords ); } else // crop Y { @@ -77,16 +83,21 @@ bool Banner::LoadFromSong( Song &song ) float fPercentageToCutOffEachSide = fPercentageToCutOff / 2; // generate a rectangle with new texture coordinates - FRECT frectNewSrc( 0, - fPercentageToCutOffEachSide, - 1, - 1 - fPercentageToCutOffEachSide ); - Sprite::SetCustomSrcRect( frectNewSrc ); + FRECT fCustomImageCoords( + 0, + fPercentageToCutOffEachSide, + 1, + 1 - fPercentageToCutOffEachSide ); + SetCustomImageRect( fCustomImageCoords ); } SetWidth( BANNER_WIDTH ); SetHeight( BANNER_HEIGHT ); SetZoom( 1 ); } + // restore original XY + SetXY( fOriginalX, fOriginalY ); + + return true; } diff --git a/stepmania/src/Banner.h b/stepmania/src/Banner.h index f364e90155..8e7affaf04 100644 --- a/stepmania/src/Banner.h +++ b/stepmania/src/Banner.h @@ -16,15 +16,15 @@ #include "Song.h" -const float BANNER_WIDTH = 192; // from the source art of DDR -const float BANNER_HEIGHT = 55; +const float BANNER_WIDTH = 264; +const float BANNER_HEIGHT = 86; class Banner : public Sprite { public: - bool LoadFromSong( Song &song); + bool LoadFromSong( Song* pSong ); // NULL means no Song }; diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index bf5f5ac575..354b50c9ab 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -67,13 +67,13 @@ void RageBitmapTexture::Create() /////////////////////// D3DFORMAT fmtTexture; - // look in the file name for a hint + // look in the file name for a format hint m_sFilePath.MakeLower(); - if( -1 != m_sFilePath.Find("(no alpha)") ) + if( -1 != m_sFilePath.Find("no alpha") ) { fmtTexture = D3DFMT_R5G6B5; } - else if( -1 != m_sFilePath.Find("(1 alpha)") ) + else if( -1 != m_sFilePath.Find("1 alpha") ) { fmtTexture = D3DFMT_A1R5G5B5; } @@ -82,6 +82,11 @@ void RageBitmapTexture::Create() fmtTexture = D3DFMT_A4R4G4B4; } + + // look in the file name for a dither hint + bool bDither = false;//-1 == m_sFilePath.Find("no dither"); + + // if the user has requested high color textures, use the higher color if( GAMEINFO != NULL && GAMEINFO->m_GameOptions.m_iDisplayColor == 32 @@ -119,8 +124,8 @@ void RageBitmapTexture::Create() 0, // usage (is a render target?) fmtTexture, // our preferred texture format D3DPOOL_MANAGED, // which memory pool - bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE, // filter - D3DX_DEFAULT, // mip filter + (bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter + D3DX_DEFAULT | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter 0, // no color key &ddii, // struct to fill with source image info NULL, // no palette diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index c85c4b64c9..c4ab603988 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -404,7 +404,7 @@ void Sprite::SetState( UINT uNewState ) m_fSecsIntoState = 0.0; } -void Sprite::SetCustomSrcRect( FRECT new_texcoord_frect ) +void Sprite::SetCustomTextureRect( FRECT new_texcoord_frect ) { m_bUsingCustomTexCoords = true; m_CustomTexCoords[0] = new_texcoord_frect.left; m_CustomTexCoords[1] = new_texcoord_frect.bottom; // bottom left @@ -414,10 +414,34 @@ void Sprite::SetCustomSrcRect( FRECT new_texcoord_frect ) } -void Sprite::SetCustomTexCoords( float fTexCoords[8] ) // order: bottom left, top left, bottom right, top right +void Sprite::SetCustomTextureCoords( float fTexCoords[8] ) // order: bottom left, top left, bottom right, top right { m_bUsingCustomTexCoords = true; for( int i=0; i<8; i++ ) m_CustomTexCoords[i] = fTexCoords[i]; } + +void Sprite::SetCustomImageRect( FRECT rectImageCoords ) +{ + // Convert to a rectangle in texture coordinate space. + rectImageCoords.left *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth(); + rectImageCoords.right *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth(); + rectImageCoords.top *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight(); + rectImageCoords.bottom *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight(); + + SetCustomTextureRect( rectImageCoords ); +} + +void Sprite::SetCustomImageCoords( float fImageCoords[8] ) // order: bottom left, top left, bottom right, top right +{ + // convert image coords to texture coords in place + for( int i=0; i<8; i+=2 ) + { + fImageCoords[i+0] *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth(); + fImageCoords[i+1] *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight(); + } + + SetCustomTextureCoords( fImageCoords ); +} + diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index f14caf5a66..68b69cc729 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -47,8 +47,11 @@ public: CString GetTexturePath() { return m_sTexturePath; }; - void SetCustomSrcRect( FRECT new_texcoord_frect ); // for cropping - void SetCustomTexCoords( float fTexCoords[8] ); + void SetCustomTextureRect( FRECT new_texcoord_frect ); + void SetCustomTextureCoords( float fTexCoords[8] ); + void SetCustomSourceRect( FRECT rectSourceCoords ); // in source pixel space + void SetCustomImageRect( FRECT rectImageCoords ); // in image pixel space + void SetCustomImageCoords( float fImageCoords[8] ); void TurnShadowOn() { m_bHasShadow = true; }; void TurnShadowOff() { m_bHasShadow = false; }; diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b1283d44f6..2f301a9252 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -354,6 +354,17 @@ HRESULT CreateObjects( HWND hWnd ) THEME = new ThemeManager; WM = new WindowManager; + + // Ugly... Switch the screen resolution again so that the system message will display + SwitchDisplayMode( + go.m_bWindowed, + go.m_iResolution, + go.m_iResolution==640 ? 480 : 240, + go.m_iDisplayColor + ); + + WM->SystemMessage( ssprintf("Found %d songs.", GAMEINFO->m_pSongs.GetSize()) ); + //WM->SetNewWindow( new WindowLoading ); //WM->SetNewWindow( new WindowSandbox ); @@ -606,7 +617,7 @@ BOOL SwitchDisplayMode( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwB if( WM ) { - WM->SetSystemMessage( ssprintf("%s - %ux%u - %u bits", bWindowed ? "Windowed" : "FullScreen", dwWidth, dwHeight, dwBPP) ); + WM->SystemMessage( ssprintf("%s - %ux%u - %u bits", bWindowed ? "Windowed" : "FullScreen", dwWidth, dwHeight, dwBPP) ); } return true;