Basic Steam Dick support (#166)

Without gamepadui library
This commit is contained in:
exstrim401 2023-01-08 17:38:24 +05:00 committed by GitHub
parent f63849bb34
commit e26b40d889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 10 deletions

View File

@ -819,10 +819,13 @@ void CVideoMode_Common::SetupStartupGraphic()
// loading.vtf
buf.Clear(); // added this Clear() because we saw cases where LoadVTF was not emptying the buf fully in the above section
m_pLoadingTexture = LoadVTF( buf, "materials/console/startup_loading.vtf" );
const char* loading = "materials/console/startup_loading.vtf";
if ( IsSteamDeck() )
loading = "materials/gamepadui/game_logo.vtf";
m_pLoadingTexture = LoadVTF( buf, loading );
if ( !m_pLoadingTexture )
{
Error( "Can't find background image materials/console/startup_loading.vtf\n" );
Error( "Can't find background image '%s'\n", loading );
return;
}
}
@ -883,8 +886,12 @@ void CVideoMode_Common::DrawStartupGraphic()
pVMTKeyValues->SetInt( "$nocull", 1 );
IMaterial *pMaterial = g_pMaterialSystem->CreateMaterial( "__background", pVMTKeyValues );
const char* loading = "console/startup_loading.vtf";
if ( IsSteamDeck() )
loading = "gamepadui/game_logo.vtf";
pVMTKeyValues = new KeyValues( "UnlitGeneric" );
pVMTKeyValues->SetString( "$basetexture", "Console/startup_loading.vtf" );
pVMTKeyValues->SetString( "$basetexture", loading );
pVMTKeyValues->SetInt( "$translucent", 1 );
pVMTKeyValues->SetInt( "$ignorez", 1 );
pVMTKeyValues->SetInt( "$nofog", 1 );
@ -922,7 +929,11 @@ void CVideoMode_Common::DrawStartupGraphic()
slide = 0;
DrawScreenSpaceRectangle( pMaterial, 0, 0+slide, w, h-50, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
if ( !IsSteamDeck() )
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
else
// TODO: Steam Deck
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
}
if(0)

View File

@ -613,7 +613,7 @@ void CEngineVGui::Init()
return;
}
if ( IsX360() )
if ( IsX360() || IsSteamDeck() )
{
CCommand ccommand;
if ( CL_ShouldLoadBackgroundLevel( ccommand ) )
@ -1273,7 +1273,7 @@ void CEngineVGui::OnLevelLoadingStarted()
}
}
if ( IsX360() )
if ( IsX360() || IsSteamDeck() )
{
// TCR requirement, always!!!
m_bShowProgressDialog = true;

View File

@ -258,7 +258,15 @@ void CHudCrosshair::Paint( void )
pWeapon->GetWeaponCrosshairScale( flWeaponScale );
}
float flPlayerScale = 1.0f;
int iScreenDiv = 1600;
if ( IsSteamDeck() )
iScreenDiv = 1440;
float flPlayerScale;
if ( !m_pCrosshair->bRenderUsingFont )
flPlayerScale = (ScreenHeight() / iScreenDiv) + 1;
else
flPlayerScale = 1.0f;
#ifdef TF_CLIENT_DLL
Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 );
flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab

View File

@ -1801,8 +1801,11 @@ void CBasePanel::ApplySchemeSettings(IScheme *pScheme)
// load the loading icon
if ( m_iLoadingImageID == -1 )
{
const char* loading = "console/startup_loading";
if ( IsSteamDeck() )
loading = "gamepadui/game_logo";
m_iLoadingImageID = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iLoadingImageID, "Console/startup_loading", false, false );
surface()->DrawSetTextureFile( m_iLoadingImageID, loading, false, false );
}
}
}

View File

@ -428,6 +428,8 @@ inline bool KeyValues::IsEmpty( int keySymbol )
return dat ? dat->IsEmpty( ) : true;
}
bool IsSteamDeck();
bool EvaluateConditional( const char *str );
class CUtlSortVectorKeyValuesByName

View File

@ -2179,6 +2179,34 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
}
}
static int s_nSteamDeckCached = -1;
bool IsSteamDeck()
{
if (s_nSteamDeckCached == -1) {
if ( CommandLine()->CheckParm( "-nogamepadui" ) != 0 )
{
s_nSteamDeckCached = 0;
}
else
{
if ( CommandLine()->CheckParm( "-gamepadui" ) != 0 )
{
s_nSteamDeckCached = 1;
}
else
{
char *deck = getenv("SteamDeck");
if ( deck == 0 || *deck == 0 )
s_nSteamDeckCached = 0;
else
s_nSteamDeckCached = atoi(deck) != 0;
}
}
}
return s_nSteamDeckCached;
}
//-----------------------------------------------------------------------------
// Returns whether a keyvalues conditional evaluates to true or false
// Needs more flexibility with conditionals, checking convars would be nice.
@ -2195,8 +2223,8 @@ bool EvaluateConditional( const char *str )
if ( *str == '!' )
bNot = true;
if( Q_stristr( str, "$DECK" ) )
return false ^ bNot; // Steam deck unsupported
if ( Q_stristr( str, "$DECK" ) )
return IsSteamDeck() ^ bNot;
if ( Q_stristr( str, "$X360" ) )
return IsX360() ^ bNot;