diff --git a/BaseMenu.cpp b/BaseMenu.cpp old mode 100644 new mode 100755 index 9d72bd2..21827d1 --- a/BaseMenu.cpp +++ b/BaseMenu.cpp @@ -35,6 +35,7 @@ cvar_t *ui_showmodels; cvar_t *ui_show_window_stack; cvar_t *ui_borderclip; cvar_t *ui_prefer_won_background; +cvar_t *ui_background_stretch; uiStatic_t uiStatic; static CMenuEntry *s_pEntries = NULL; @@ -1138,6 +1139,7 @@ void UI_Init( void ) ui_show_window_stack = EngFuncs::CvarRegister( "ui_show_window_stack", "0", FCVAR_ARCHIVE ); ui_borderclip = EngFuncs::CvarRegister( "ui_borderclip", "0", FCVAR_ARCHIVE ); ui_prefer_won_background = EngFuncs::CvarRegister( "ui_prefer_won_background", "0", FCVAR_ARCHIVE ); + ui_background_stretch = EngFuncs::CvarRegister( "ui_background_stretch", "0", FCVAR_ARCHIVE ); // show cl_predict dialog EngFuncs::CvarRegister( "menu_mp_firsttime2", "1", FCVAR_ARCHIVE ); diff --git a/BaseMenu.h b/BaseMenu.h old mode 100644 new mode 100755 index 3616421..f51edfa --- a/BaseMenu.h +++ b/BaseMenu.h @@ -60,6 +60,7 @@ extern cvar_t *ui_showmodels; extern cvar_t *ui_show_window_stack; extern cvar_t *ui_borderclip; extern cvar_t *ui_prefer_won_background; +extern cvar_t *ui_background_stretch; enum EUISounds { diff --git a/controls/BackgroundBitmap.cpp b/controls/BackgroundBitmap.cpp old mode 100644 new mode 100755 index 56fd251..7797ac4 --- a/controls/BackgroundBitmap.cpp +++ b/controls/BackgroundBitmap.cpp @@ -174,25 +174,37 @@ void CMenuBackgroundBitmap::Draw() #else p.x = p.y = 0; - // work out scaling factors - if( ScreenWidth * s.h > ScreenHeight * s.w ) + // Stretch the background image if the user chose to do so + if( ui_background_stretch->value ) { xScale = ScreenWidth / s.w; - yScale = xScale; + yScale = ScreenHeight / s.h; } else { - yScale = ScreenHeight / s.h; - xScale = yScale; + // work out scaling factors + if( ScreenWidth * s.h > ScreenHeight * s.w ) + { + xScale = ScreenWidth / s.w; + yScale = xScale; + } + else + { + yScale = ScreenHeight / s.h; + xScale = yScale; + } } #endif - // center wide background (for example if background is wider than our window) int xOffset = 0, yOffset = 0; - if( s.w * xScale > ScreenWidth ) - xOffset = ( ScreenWidth - s.w * xScale ) / 2; - else if( s.h * yScale > ScreenHeight ) - yOffset = ( ScreenHeight - s.h * yScale ) / 2; + if( !ui_background_stretch->value ) + { + // center wide background (for example if background is wider than our window) + if( s.w * xScale > ScreenWidth ) + xOffset = ( ScreenWidth - s.w * xScale ) / 2; + else if( s.h * yScale > ScreenHeight ) + yOffset = ( ScreenHeight - s.h * yScale ) / 2; + } if( s_state == DRAW_WON ) DrawBackgroundPiece( s_WONBackground, p, xOffset, yOffset, xScale, yScale ); @@ -274,8 +286,6 @@ bool CMenuBackgroundBitmap::LoadSteamBackground( bool gamedirOnly ) bool CMenuBackgroundBitmap::LoadWONBackground( bool gamedirOnly ) { - s_bEnableLogoMovie = false; - if( EngFuncs::FileExists( ART_BACKGROUND, gamedirOnly )) { bimage_t img; @@ -290,12 +300,6 @@ bool CMenuBackgroundBitmap::LoadWONBackground( bool gamedirOnly ) img.size.h = EngFuncs::PIC_Height( img.hImage ); s_WONBackground = img; - if( gamedirOnly ) - { - // if we doesn't have logo.avi in gamedir we don't want to draw it - s_bEnableLogoMovie = EngFuncs::FileExists( "media/logo.avi", true ); - } - return true; } @@ -359,5 +363,8 @@ void CMenuBackgroundBitmap::LoadBackground() else if( LoadWONBackground( false )) Con_DPrintf( "%s: found %s background in %s directory\n", __func__, "won", "game" ); + // logo.avi should be an independent asset from the background image + s_bEnableLogoMovie = EngFuncs::FileExists( "media/logo.avi", false ); + UpdatePreference(); } diff --git a/controls/MovieBanner.cpp b/controls/MovieBanner.cpp old mode 100644 new mode 100755 index cc92fda..d56a95d --- a/controls/MovieBanner.cpp +++ b/controls/MovieBanner.cpp @@ -19,25 +19,62 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "MovieBanner.h" +// In WON menus the background is always 640x480 +const float splashWidth = 640.0f; +const float splashHeight = 480.0f; + void CMenuMovieBanner::VidInit() { - float scaleX = ScreenWidth / 640.0f; - float scaleY = ScreenHeight / 480.0f; + EngFuncs::PrecacheLogo( "logo.avi" ); + + float xScale, yScale; + float xOffset = 0, yOffset = 0; + + // Adapt to stretched or cropped background + if( ui_background_stretch->value ) + { + xScale = ScreenWidth / splashWidth; + yScale = ScreenHeight / splashHeight; + } + else + { + if( ScreenWidth * splashHeight > ScreenHeight * splashWidth ) + { + xScale = ScreenWidth / splashWidth; + yScale = xScale; + + yOffset = ( ScreenHeight - 480.0f * yScale ) / 2; + } + else + { + yScale = ScreenHeight / splashHeight; + xScale = yScale; - m_scPos.x = 0; - m_scPos.y = 70 * scaleY * uiStatic.scaleY; // 70 is empirically determined value (magic number) + xOffset = ( ScreenWidth - 640.0f * xScale ) / 2; + } + } - // a1ba: multiply by height scale to look better on wide screens - m_scSize.w = EngFuncs::GetLogoWidth() * scaleX; - m_scSize.h = EngFuncs::GetLogoHeight() * scaleY * uiStatic.scaleY; + m_scPos.x = (int)xOffset; + m_scPos.y = (int)( yOffset + 70.0f * yScale ); // 70 is empirically determined value (magic number) + + m_scSize.w = (int)( EngFuncs::GetLogoWidth( ) * xScale ); + m_scSize.h = (int)( EngFuncs::GetLogoHeight( ) * yScale ); } void CMenuMovieBanner::Draw() { + if( FBitSet( ui_background_stretch->flags, FCVAR_CHANGED ) ) + { + ClearBits( ui_background_stretch->flags, FCVAR_CHANGED ); + + // Logo needs to be reset when this CVAR changes + VidInit(); + } + if( EngFuncs::ClientInGame() && EngFuncs::GetCvarFloat( "ui_renderworld" )) return; - if( EngFuncs::GetLogoLength() <= 0.05f || EngFuncs::GetLogoWidth() <= 32 ) + if( EngFuncs::GetLogoLength() <= 0 || EngFuncs::GetLogoWidth() <= 32 ) return; EngFuncs::DrawLogo( "logo.avi", m_scPos.x, m_scPos.y, m_scSize.w, m_scSize.h );