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.

103 lines
3.6 KiB

  1. //===== Copyright � 1996-2008, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef CL_SPLITSCREEN_H
  8. #define CL_SPLITSCREEN_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. class INetChannel;
  13. class ISplitScreen
  14. {
  15. public:
  16. virtual bool Init() = 0;
  17. virtual void Shutdown() = 0;
  18. virtual bool AddSplitScreenUser( int nSlot, int nPlayerIndex ) = 0;
  19. virtual bool AddBaseUser( int nSlot, int nPlayerIndex ) = 0;
  20. virtual bool RemoveSplitScreenUser( int nSlot, int nPlayerIndex ) = 0;
  21. virtual int GetActiveSplitScreenPlayerSlot() = 0;
  22. virtual int SetActiveSplitScreenPlayerSlot( int nSlot ) = 0;
  23. virtual bool IsValidSplitScreenSlot( int nSlot ) = 0;
  24. virtual int FirstValidSplitScreenSlot() = 0; // -1 == invalid
  25. virtual int NextValidSplitScreenSlot( int nPreviousSlot ) = 0; // -1 == invalid
  26. virtual int GetNumSplitScreenPlayers() = 0;
  27. virtual int GetSplitScreenPlayerEntity( int nSlot ) = 0;
  28. virtual INetChannel *GetSplitScreenPlayerNetChan( int nSlot ) = 0;
  29. virtual bool IsDisconnecting( int nSlot ) = 0;
  30. virtual void SetDisconnecting( int nSlot, bool bState ) = 0;
  31. virtual bool SetLocalPlayerIsResolvable( char const *pchContext, int nLine, bool bResolvable ) = 0;
  32. virtual bool IsLocalPlayerResolvable() = 0;
  33. };
  34. #ifndef DEDICATED
  35. extern ISplitScreen *splitscreen;
  36. #endif
  37. class CSetActiveSplitScreenPlayerGuard
  38. {
  39. public:
  40. CSetActiveSplitScreenPlayerGuard( char const *pchContext, int nLine, int slot );
  41. ~CSetActiveSplitScreenPlayerGuard();
  42. private:
  43. char const *m_pchContext;
  44. int m_nLine;
  45. int m_nSaveSlot;
  46. bool m_bResolvable;
  47. };
  48. // If this is defined, all of the scopeguard objects are NULL'd out to reduce overhead
  49. #ifdef DEDICATED
  50. #define SPLIT_SCREEN_STUBS
  51. #endif
  52. #if defined( CSTRIKE15 ) // && !defined( _GAMECONSOLE ) // Split screen removed from console.
  53. #define SPLIT_SCREEN_STUBS
  54. #endif
  55. #if defined( SPLIT_SCREEN_STUBS )
  56. #define IS_LOCAL_PLAYER_RESOLVABLE true
  57. #define SET_LOCAL_PLAYER_RESOLVABLE( a, b, c ) true
  58. #define SET_ACTIVE_SPLIT_SCREEN_PLAYER_SLOT( x )
  59. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot )
  60. #define FORCE_DEFAULT_SPLITSCREEN_PLAYER_GUARD
  61. #define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) for ( int iteratorName = 0; iteratorName == 0; ++iteratorName )
  62. #define ASSERT_LOCAL_PLAYER_RESOLVABLE()
  63. #define GET_ACTIVE_SPLITSCREEN_SLOT() ( 0 )
  64. #define GET_NUM_SPLIT_SCREEN_PLAYERS() 1
  65. #define IS_VALID_SPLIT_SCREEN_SLOT( i ) ( ( i ) == 0 )
  66. #else
  67. #define IS_LOCAL_PLAYER_RESOLVABLE ( splitscreen->IsLocalPlayerResolvable() )
  68. #define SET_LOCAL_PLAYER_RESOLVABLE( a, b, c ) ( splitscreen->SetLocalPlayerIsResolvable( a, b, c ) )
  69. #define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ) CSetActiveSplitScreenPlayerGuard g_SSGuard( __FILE__, __LINE__, slot );
  70. #define FORCE_DEFAULT_SPLITSCREEN_PLAYER_GUARD CSetActiveSplitScreenPlayerGuard g_SSGuard( __FILE__, __LINE__, 0 );
  71. #define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) \
  72. for ( int iteratorName = splitscreen->FirstValidSplitScreenSlot(); \
  73. iteratorName != -1; \
  74. iteratorName = splitscreen->NextValidSplitScreenSlot( iteratorName ) )
  75. #define ASSERT_LOCAL_PLAYER_RESOLVABLE() Assert( splitscreen->IsLocalPlayerResolvable() );
  76. #define GET_ACTIVE_SPLITSCREEN_SLOT() splitscreen->GetActiveSplitScreenPlayerSlot()
  77. #define SET_ACTIVE_SPLIT_SCREEN_PLAYER_SLOT( x ) splitscreen->SetActiveSplitScreenPlayerSlot( x )
  78. #define GET_NUM_SPLIT_SCREEN_PLAYERS() ( splitscreen->GetNumSplitScreenPlayers() )
  79. #define IS_VALID_SPLIT_SCREEN_SLOT( i ) ( splitscreen->IsValidSplitScreenSlot( i ) )
  80. #endif
  81. #endif // CL_SPLITSCREEN_H