Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BaseMenu.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions BaseMenu.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
43 changes: 25 additions & 18 deletions controls/BackgroundBitmap.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
}
53 changes: 45 additions & 8 deletions controls/MovieBanner.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down