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.

218 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Linux support for the IGame interface
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "iengine.h"
  10. #include <stdlib.h>
  11. #include "engine_launcher_api.h"
  12. #include "basetypes.h"
  13. #include "ivideomode.h"
  14. #include "igame.h"
  15. #define UINT unsigned int
  16. #define WPARAM int
  17. #define LPARAM int
  18. #include "profile.h"
  19. #include "server.h"
  20. #include "cdll_int.h"
  21. #ifdef SWDS
  22. void ForceReloadProfile( void );
  23. void ClearIOStates( void );
  24. //-----------------------------------------------------------------------------
  25. // Purpose: Main game interface, including message pump and window creation
  26. //-----------------------------------------------------------------------------
  27. class CGame : public IGame
  28. {
  29. public:
  30. CGame( void );
  31. virtual ~CGame( void );
  32. bool Init( void *pvInstance );
  33. bool Shutdown( void );
  34. bool CreateGameWindow( void );
  35. virtual void DestroyGameWindow( void );
  36. virtual void SetGameWindow( void *hWnd );
  37. virtual bool InputAttachToGameWindow();
  38. virtual void InputDetachFromGameWindow();
  39. void* GetMainWindow( void );
  40. void* GetMainDeviceWindow( void );
  41. void** GetMainWindowAddress( void );
  42. void SetWindowXY( int x, int y );
  43. void SetWindowSize( int w, int h );
  44. void GetWindowRect( int *x, int *y, int *w, int *h );
  45. bool IsActiveApp( void );
  46. virtual void DispatchAllStoredGameMessages();
  47. virtual void PlayStartupVideos() {}
  48. virtual void GetDesktopInfo( int &width, int &height, int &refreshRate );
  49. private:
  50. void SetActiveApp( bool fActive );
  51. private:
  52. bool m_bActiveApp;
  53. static const char CLASSNAME[];
  54. };
  55. static CGame g_Game;
  56. IGame *game = ( IGame * )&g_Game;
  57. const char CGame::CLASSNAME[] = "Valve001";
  58. // In VCR playback mode, it sleeps this amount each frame.
  59. int g_iVCRPlaybackSleepInterval = 0;
  60. // During VCR playback, if this is true, then it'll pause at the end of each frame.
  61. bool g_bVCRSingleStep = false;
  62. void VCR_EnterPausedState()
  63. {
  64. // Turn this off in case they're in single-step mode.
  65. g_bVCRSingleStep = false;
  66. // This is cheesy, but GetAsyncKeyState is blocked (in protected_things. h)
  67. // from being accidentally used, so we get it through it by getting its pointer directly.
  68. // In this mode, we enter a wait state where we only pay attention to R and Q.
  69. /* while ( 1 )
  70. {
  71. if ( pfn( 'R' ) & 0x8000 )
  72. break;
  73. if ( pfn( 'Q' ) & 0x8000 )
  74. kill( getpid(), SIGKILL );
  75. if ( pfn( 'S' ) & 0x8000 )
  76. {
  77. // Do a single step.
  78. g_bVCRSingleStep = true;
  79. break;
  80. }
  81. Sleep( 2 );
  82. }
  83. */
  84. }
  85. bool CGame::CreateGameWindow( void )
  86. {
  87. return true;
  88. }
  89. void CGame::DestroyGameWindow( void )
  90. {
  91. }
  92. // This is used in edit mode to override the default wnd proc associated w/
  93. bool CGame::InputAttachToGameWindow()
  94. {
  95. return true;
  96. }
  97. void CGame::InputDetachFromGameWindow()
  98. {
  99. }
  100. void CGame::SetGameWindow( void *hWnd )
  101. {
  102. return;
  103. }
  104. CGame::CGame( void )
  105. {
  106. m_bActiveApp = true;
  107. }
  108. CGame::~CGame( void )
  109. {
  110. }
  111. bool CGame::Init( void *pvInstance )
  112. {
  113. return true;
  114. }
  115. bool CGame::Shutdown( void )
  116. {
  117. return true;
  118. }
  119. void *CGame::GetMainWindow( void )
  120. {
  121. return 0;
  122. }
  123. void *CGame::GetMainDeviceWindow( void )
  124. {
  125. return 0;
  126. }
  127. void **CGame::GetMainWindowAddress( void )
  128. {
  129. return NULL;
  130. }
  131. void CGame::SetWindowXY( int x, int y )
  132. {
  133. }
  134. void CGame::SetWindowSize( int w, int h )
  135. {
  136. }
  137. void CGame::GetWindowRect( int *x, int *y, int *w, int *h )
  138. {
  139. if ( x )
  140. {
  141. *x = 0;
  142. }
  143. if ( y )
  144. {
  145. *y = 0;
  146. }
  147. if ( w )
  148. {
  149. *w = 0;
  150. }
  151. if ( h )
  152. {
  153. *h = 0;
  154. }
  155. }
  156. bool CGame::IsActiveApp( void )
  157. {
  158. return m_bActiveApp;
  159. }
  160. void CGame::SetActiveApp( bool active )
  161. {
  162. m_bActiveApp = active;
  163. }
  164. void CGame::DispatchAllStoredGameMessages()
  165. {
  166. }
  167. void CGame::GetDesktopInfo( int &width, int &height, int &refreshRate )
  168. {
  169. width = 0;
  170. height = 0;
  171. refreshRate = 0;
  172. }
  173. #endif