Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #if !defined( CLIENTSTEAMCONTEXT_H )
  3. #define CLIENTSTEAMCONTEXT_H
  4. #ifdef _WIN32
  5. #pragma once
  6. #endif
  7. #include "steam/steam_api.h"
  8. #include "utldelegate.h"
  9. struct SteamLoggedOnChange_t
  10. {
  11. bool bPreviousLoggedOn;
  12. bool bLoggedOn;
  13. };
  14. class CClientSteamContext : public CSteamAPIContext
  15. {
  16. public:
  17. CClientSteamContext();
  18. ~CClientSteamContext();
  19. void Activate();
  20. void Shutdown();
  21. #if !defined(NO_STEAM)
  22. STEAM_CALLBACK( CClientSteamContext, OnSteamServersDisconnected, SteamServersDisconnected_t, m_CallbackSteamServersDisconnected );
  23. STEAM_CALLBACK( CClientSteamContext, OnSteamServerConnectFailure, SteamServerConnectFailure_t, m_CallbackSteamServerConnectFailure );
  24. STEAM_CALLBACK( CClientSteamContext, OnSteamServersConnected, SteamServersConnected_t, m_CallbackSteamServersConnected );
  25. #ifdef TF_CLIENT_DLL
  26. STEAM_CALLBACK( CClientSteamContext, OnGameJoinRequested, GameRichPresenceJoinRequested_t, m_GameJoinRequested );
  27. #endif // TF_CLIENT_DLL
  28. #endif
  29. bool BLoggedOn() { return m_bLoggedOn; }
  30. EUniverse GetConnectedUniverse() { return m_nUniverse; }
  31. uint32 GetAppID() { return m_nAppID; }
  32. const CSteamID & GetLocalPlayerSteamID() { return m_SteamIDLocalPlayer; }
  33. // Allow others to register for a callback when the Steam logged on status changes
  34. void InstallCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate );
  35. void RemoveCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate );
  36. private:
  37. void UpdateLoggedOnState();
  38. void InvokeCallbacks( const SteamLoggedOnChange_t &loggedOnStatus );
  39. bool m_bActive;
  40. bool m_bLoggedOn;
  41. CSteamID m_SteamIDLocalPlayer;
  42. EUniverse m_nUniverse;
  43. uint32 m_nAppID;
  44. CUtlVector< CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > > m_LoggedOnCallbacks;
  45. };
  46. CClientSteamContext &ClientSteamContext(); // singleton accessor
  47. #endif // CLIENTSTEAMCONTEXT_H