Counter Strike : Global Offensive Source Code
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.

54 lines
1.7 KiB

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