From f5db84045d8aff16d8bb2e38b9dae58f0c2e29c2 Mon Sep 17 00:00:00 2001 From: Razcoina Date: Fri, 6 Feb 2026 20:55:58 +0000 Subject: [PATCH 1/5] MovieBanner: preload logo.avi to be able to get dimensions and duration, remove duration check to improve compatibility with some mods --- controls/MovieBanner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 controls/MovieBanner.cpp diff --git a/controls/MovieBanner.cpp b/controls/MovieBanner.cpp old mode 100644 new mode 100755 index cc92fda0..799ba9c7 --- a/controls/MovieBanner.cpp +++ b/controls/MovieBanner.cpp @@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CMenuMovieBanner::VidInit() { + EngFuncs::PrecacheLogo( "logo.avi" ); + float scaleX = ScreenWidth / 640.0f; float scaleY = ScreenHeight / 480.0f; @@ -37,7 +39,7 @@ void CMenuMovieBanner::Draw() 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 ); From c4a8cf81e06e2d43e6a03e47b666f35244dcf2b4 Mon Sep 17 00:00:00 2001 From: Razcoina Date: Fri, 6 Feb 2026 20:56:47 +0000 Subject: [PATCH 2/5] Console: add ui_background_stretch CVAR, allows choosing between stretching and cropping the menu background (default: cropping) --- BaseMenu.cpp | 2 ++ BaseMenu.h | 1 + 2 files changed, 3 insertions(+) mode change 100644 => 100755 BaseMenu.cpp mode change 100644 => 100755 BaseMenu.h diff --git a/BaseMenu.cpp b/BaseMenu.cpp old mode 100644 new mode 100755 index 9d72bd2d..21827d11 --- 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 3616421d..f51edfa0 --- 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 { From 024dbfcf1bcc05c3fa8d43db8c1b04941ffadef4 Mon Sep 17 00:00:00 2001 From: Razcoina Date: Fri, 6 Feb 2026 20:57:29 +0000 Subject: [PATCH 3/5] Background: implement background stretching when CVAR ui_background_stretch is 1 --- controls/BackgroundBitmap.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) mode change 100644 => 100755 controls/BackgroundBitmap.cpp diff --git a/controls/BackgroundBitmap.cpp b/controls/BackgroundBitmap.cpp old mode 100644 new mode 100755 index 56fd2510..594219b1 --- 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 ); From 149788099aa39062ab102bd5adbedde032dcf11a Mon Sep 17 00:00:00 2001 From: Razcoina Date: Fri, 6 Feb 2026 20:58:08 +0000 Subject: [PATCH 4/5] MovieBanner: align the banner with the background image --- controls/MovieBanner.cpp | 49 ++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/controls/MovieBanner.cpp b/controls/MovieBanner.cpp index 799ba9c7..d56a95d5 100755 --- a/controls/MovieBanner.cpp +++ b/controls/MovieBanner.cpp @@ -19,23 +19,58 @@ 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() { EngFuncs::PrecacheLogo( "logo.avi" ); - float scaleX = ScreenWidth / 640.0f; - float scaleY = ScreenHeight / 480.0f; + 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; From d8c73ef018b0996f2fde3980708e98691246f1a3 Mon Sep 17 00:00:00 2001 From: Razcoina Date: Fri, 6 Feb 2026 20:58:43 +0000 Subject: [PATCH 5/5] MovieBanner: allow loading logo.avi from a fallback mod if not present in the current mod --- controls/BackgroundBitmap.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/controls/BackgroundBitmap.cpp b/controls/BackgroundBitmap.cpp index 594219b1..7797ac47 100755 --- a/controls/BackgroundBitmap.cpp +++ b/controls/BackgroundBitmap.cpp @@ -286,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; @@ -302,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; } @@ -371,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(); }