mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-01-03 14:06:44 +00:00
game: make achievements work without steam
This commit is contained in:
parent
ab5c1c0b3a
commit
a5e9cdcbe2
@ -85,7 +85,7 @@ void CAchievementNotificationPanel::PerformLayout( void )
|
|||||||
SetBgColor( Color( 0, 0, 0, 0 ) );
|
SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||||
m_pLabelHeading->SetBgColor( Color( 0, 0, 0, 0 ) );
|
m_pLabelHeading->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||||
m_pLabelTitle->SetBgColor( Color( 0, 0, 0, 0 ) );
|
m_pLabelTitle->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||||
m_pPanelBackground->SetBgColor( Color( 62,70,55, 200 ) );
|
m_pPanelBackground->SetBgColor( Color( 128, 128, 128, 128 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -94,13 +94,14 @@ void CAchievementNotificationPanel::PerformLayout( void )
|
|||||||
void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||||
{
|
{
|
||||||
const char *name = event->GetName();
|
const char *name = event->GetName();
|
||||||
if ( 0 == Q_strcmp( name, "achievement_event" ) )
|
if ( Q_strcmp( name, "achievement_event" ) == 0 )
|
||||||
{
|
{
|
||||||
const char *pchName = event->GetString( "achievement_name" );
|
const char *pchName = event->GetString( "achievement_name" );
|
||||||
int iCur = event->GetInt( "cur_val" );
|
int iCur = event->GetInt( "cur_val" );
|
||||||
int iMax = event->GetInt( "max_val" );
|
int iMax = event->GetInt( "max_val" );
|
||||||
wchar_t szLocalizedName[256]=L"";
|
wchar_t szLocalizedName[256]=L"";
|
||||||
|
|
||||||
|
#ifndef DISABLE_STEAM
|
||||||
if ( IsPC() )
|
if ( IsPC() )
|
||||||
{
|
{
|
||||||
// shouldn't ever get achievement progress if steam not running and user logged in, but check just in case
|
// shouldn't ever get achievement progress if steam not running and user logged in, but check just in case
|
||||||
@ -115,6 +116,7 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// on X360 we need to show our own achievement progress UI
|
// on X360 we need to show our own achievement progress UI
|
||||||
|
|
||||||
@ -125,10 +127,17 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
|||||||
Q_wcsncpy( szLocalizedName, pchLocalizedName, sizeof( szLocalizedName ) );
|
Q_wcsncpy( szLocalizedName, pchLocalizedName, sizeof( szLocalizedName ) );
|
||||||
|
|
||||||
// this is achievement progress, compose the message of form: "<name> (<#>/<max>)"
|
// this is achievement progress, compose the message of form: "<name> (<#>/<max>)"
|
||||||
wchar_t szFmt[128]=L"";
|
|
||||||
wchar_t szText[512]=L"";
|
wchar_t szText[512]=L"";
|
||||||
|
wchar_t szFmt[128]=L"";
|
||||||
wchar_t szNumFound[16]=L"";
|
wchar_t szNumFound[16]=L"";
|
||||||
wchar_t szNumTotal[16]=L"";
|
wchar_t szNumTotal[16]=L"";
|
||||||
|
|
||||||
|
if( iCur >= iMax )
|
||||||
|
{
|
||||||
|
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Awarded" ), szLocalizedName );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_snwprintf( szNumFound, ARRAYSIZE( szNumFound ), L"%i", iCur );
|
_snwprintf( szNumFound, ARRAYSIZE( szNumFound ), L"%i", iCur );
|
||||||
_snwprintf( szNumTotal, ARRAYSIZE( szNumTotal ), L"%i", iMax );
|
_snwprintf( szNumTotal, ARRAYSIZE( szNumTotal ), L"%i", iMax );
|
||||||
|
|
||||||
@ -138,6 +147,7 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
|||||||
Q_wcsncpy( szFmt, pchFmt, sizeof( szFmt ) );
|
Q_wcsncpy( szFmt, pchFmt, sizeof( szFmt ) );
|
||||||
|
|
||||||
g_pVGuiLocalize->ConstructString( szText, sizeof( szText ), szFmt, 3, szLocalizedName, szNumFound, szNumTotal );
|
g_pVGuiLocalize->ConstructString( szText, sizeof( szText ), szFmt, 3, szLocalizedName, szNumFound, szNumTotal );
|
||||||
|
|
||||||
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Progress" ), szText );
|
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Progress" ), szText );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +255,7 @@ void CAchievementNotificationPanel::SetXAndWide( Panel *pPanel, int x, int wide
|
|||||||
pPanel->SetWide( wide );
|
pPanel->SetWide( wide );
|
||||||
}
|
}
|
||||||
|
|
||||||
CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY )
|
CON_COMMAND( achievement_notification_test, "Test the hud notification UI" )
|
||||||
{
|
{
|
||||||
static int iCount=0;
|
static int iCount=0;
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ def configure(conf):
|
|||||||
game = conf.options.GAMES
|
game = conf.options.GAMES
|
||||||
conf.env.GAMES = game
|
conf.env.GAMES = game
|
||||||
|
|
||||||
|
conf.env.append_unique('DEFINES', ['DISABLE_STEAM=1'])
|
||||||
|
|
||||||
if game not in games.keys():
|
if game not in games.keys():
|
||||||
conf.fatal("Couldn't find game: ", game)
|
conf.fatal("Couldn't find game: ", game)
|
||||||
|
|
||||||
|
@ -951,7 +951,7 @@ void CAchievementMgr::AwardAchievement( int iAchievementID )
|
|||||||
|
|
||||||
if ( IsPC() )
|
if ( IsPC() )
|
||||||
{
|
{
|
||||||
#ifndef NO_STEAM
|
#ifndef DISABLE_STEAM
|
||||||
if ( steamapicontext->SteamUserStats() )
|
if ( steamapicontext->SteamUserStats() )
|
||||||
{
|
{
|
||||||
VPROF_BUDGET( "AwardAchievement", VPROF_BUDGETGROUP_STEAM );
|
VPROF_BUDGET( "AwardAchievement", VPROF_BUDGETGROUP_STEAM );
|
||||||
@ -963,6 +963,7 @@ void CAchievementMgr::AwardAchievement( int iAchievementID )
|
|||||||
m_AchievementsAwarded.AddToTail( iAchievementID );
|
m_AchievementsAwarded.AddToTail( iAchievementID );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_AchievementsAwarded.AddToTail( iAchievementID );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if ( IsX360() )
|
else if ( IsX360() )
|
||||||
@ -1033,12 +1034,16 @@ extern bool IsInCommentaryMode( void );
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CAchievementMgr::CheckAchievementsEnabled()
|
bool CAchievementMgr::CheckAchievementsEnabled()
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
|
|
||||||
// if PC, Steam must be running and user logged in
|
// if PC, Steam must be running and user logged in
|
||||||
|
#ifndef DISABLE_STEAM
|
||||||
if ( IsPC() && !LoggedIntoSteam() )
|
if ( IsPC() && !LoggedIntoSteam() )
|
||||||
{
|
{
|
||||||
Msg( "Achievements disabled: Steam not running.\n" );
|
Msg( "Achievements disabled: Steam not running.\n" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( _X360 )
|
#if defined( _X360 )
|
||||||
uint state = XUserGetSigninState( XBX_GetPrimaryUserId() );
|
uint state = XUserGetSigninState( XBX_GetPrimaryUserId() );
|
||||||
|
@ -231,7 +231,7 @@ void CBaseAchievement::IncrementCount( int iOptIncrement )
|
|||||||
Msg( "Achievement count increased for %s: %d/%d\n", GetName(), m_iCount, m_iGoal );
|
Msg( "Achievement count increased for %s: %d/%d\n", GetName(), m_iCount, m_iGoal );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_STEAM
|
#ifndef DISABLE_STEAM
|
||||||
// if this achievement's progress should be stored in Steam, set the steam stat for it
|
// if this achievement's progress should be stored in Steam, set the steam stat for it
|
||||||
if ( StoreProgressInSteam() && steamapicontext->SteamUserStats() )
|
if ( StoreProgressInSteam() && steamapicontext->SteamUserStats() )
|
||||||
{
|
{
|
||||||
@ -275,13 +275,10 @@ void CBaseAchievement::SetShowOnHUD( bool bShow )
|
|||||||
|
|
||||||
void CBaseAchievement::HandleProgressUpdate()
|
void CBaseAchievement::HandleProgressUpdate()
|
||||||
{
|
{
|
||||||
// if we've hit the right # of progress steps to show a progress notification, show it
|
|
||||||
if ( ( m_iProgressMsgIncrement > 0 ) && m_iCount >= m_iProgressMsgMinimum && ( 0 == ( m_iCount % m_iProgressMsgIncrement ) ) )
|
|
||||||
{
|
|
||||||
// which notification is this
|
// which notification is this
|
||||||
int iProgress = m_iCount / m_iProgressMsgIncrement;
|
int iProgress = m_iCount / m_iProgressMsgIncrement;
|
||||||
// if we haven't already shown this progress step, show it
|
// if we haven't already shown this progress step, show it
|
||||||
if ( iProgress > m_iProgressShown )
|
if ( iProgress > m_iProgressShown || m_iCount == 1 )
|
||||||
{
|
{
|
||||||
ShowProgressNotification();
|
ShowProgressNotification();
|
||||||
// remember progress step shown so we don't show it again if the player loads an earlier save game
|
// remember progress step shown so we don't show it again if the player loads an earlier save game
|
||||||
@ -289,7 +286,6 @@ void CBaseAchievement::HandleProgressUpdate()
|
|||||||
m_iProgressShown = iProgress;
|
m_iProgressShown = iProgress;
|
||||||
m_pAchievementMgr->SetDirty( true );
|
m_pAchievementMgr->SetDirty( true );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -383,6 +379,7 @@ void CBaseAchievement::AwardAchievement()
|
|||||||
if ( IsAchieved() )
|
if ( IsAchieved() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ShowProgressNotification();
|
||||||
m_pAchievementMgr->AwardAchievement( m_iAchievementID );
|
m_pAchievementMgr->AwardAchievement( m_iAchievementID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +520,10 @@ class CAchievementPortalFindAllDinosaurs : public CBaseAchievement
|
|||||||
{
|
{
|
||||||
EnsureComponentBitSetAndEvaluate( id );
|
EnsureComponentBitSetAndEvaluate( id );
|
||||||
|
|
||||||
|
#ifndef DISABLE_STEAM
|
||||||
// Update our Steam stat
|
// Update our Steam stat
|
||||||
steamapicontext->SteamUserStats()->SetStat( "PORTAL_TRANSMISSION_RECEIVED_STAT", m_iCount );
|
steamapicontext->SteamUserStats()->SetStat( "PORTAL_TRANSMISSION_RECEIVED_STAT", m_iCount );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user