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.

154 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A higher level link library for general use in the game and tools.
  4. //
  5. //===========================================================================//
  6. #include "tier3/tier3.h"
  7. #include "tier0/dbg.h"
  8. #include "istudiorender.h"
  9. #include "vgui/IVGui.h"
  10. #include "vgui/IInput.h"
  11. #include "vgui/IPanel.h"
  12. #include "vgui/ISurface.h"
  13. #include "vgui/ILocalize.h"
  14. #include "vgui/IScheme.h"
  15. #include "vgui/ISystem.h"
  16. #include "VGuiMatSurface/IMatSystemSurface.h"
  17. #include "datacache/idatacache.h"
  18. #include "datacache/imdlcache.h"
  19. #include "video/ivideoservices.h"
  20. #include "movieobjects/idmemakefileutils.h"
  21. #include "vphysics_interface.h"
  22. #include "SoundEmitterSystem/isoundemittersystembase.h"
  23. #include "ivtex.h"
  24. //-----------------------------------------------------------------------------
  25. // These tier3 libraries must be set by any users of this library.
  26. // They can be set by calling ConnectTier3Libraries.
  27. // It is hoped that setting this, and using this library will be the common mechanism for
  28. // allowing link libraries to access tier3 library interfaces
  29. //-----------------------------------------------------------------------------
  30. IStudioRender *g_pStudioRender = 0;
  31. IStudioRender *studiorender = 0;
  32. IMatSystemSurface *g_pMatSystemSurface = 0;
  33. vgui::IInput *g_pVGuiInput = 0;
  34. vgui::ISurface *g_pVGuiSurface = 0;
  35. vgui::IPanel *g_pVGuiPanel = 0;
  36. vgui::IVGui *g_pVGui = 0;
  37. vgui::ILocalize *g_pVGuiLocalize = 0;
  38. vgui::ISchemeManager *g_pVGuiSchemeManager = 0;
  39. vgui::ISystem *g_pVGuiSystem = 0;
  40. IDataCache *g_pDataCache = 0;
  41. IMDLCache *g_pMDLCache = 0;
  42. IMDLCache *mdlcache = 0;
  43. IVideoServices *g_pVideo = NULL;
  44. IDmeMakefileUtils *g_pDmeMakefileUtils = 0;
  45. IPhysicsCollision *g_pPhysicsCollision = 0;
  46. ISoundEmitterSystemBase *g_pSoundEmitterSystem = 0;
  47. IVTex *g_pVTex = 0;
  48. //-----------------------------------------------------------------------------
  49. // Call this to connect to all tier 3 libraries.
  50. // It's up to the caller to check the globals it cares about to see if ones are missing
  51. //-----------------------------------------------------------------------------
  52. void ConnectTier3Libraries( CreateInterfaceFn *pFactoryList, int nFactoryCount )
  53. {
  54. // Don't connect twice..
  55. Assert( !g_pStudioRender && !studiorender && !g_pMatSystemSurface && !g_pVGui && !g_pVGuiPanel && !g_pVGuiInput &&
  56. !g_pVGuiSurface && !g_pDataCache && !g_pMDLCache && !mdlcache && !g_pVideo &&
  57. !g_pDmeMakefileUtils && !g_pPhysicsCollision && !g_pVGuiLocalize && !g_pSoundEmitterSystem &&
  58. !g_pVGuiSchemeManager && !g_pVGuiSystem );
  59. for ( int i = 0; i < nFactoryCount; ++i )
  60. {
  61. if ( !g_pStudioRender )
  62. {
  63. g_pStudioRender = studiorender = ( IStudioRender * )pFactoryList[i]( STUDIO_RENDER_INTERFACE_VERSION, NULL );
  64. }
  65. if ( !g_pVGui )
  66. {
  67. g_pVGui = (vgui::IVGui*)pFactoryList[i]( VGUI_IVGUI_INTERFACE_VERSION, NULL );
  68. }
  69. if ( !g_pVGuiInput )
  70. {
  71. g_pVGuiInput = (vgui::IInput*)pFactoryList[i]( VGUI_INPUT_INTERFACE_VERSION, NULL );
  72. }
  73. if ( !g_pVGuiPanel )
  74. {
  75. g_pVGuiPanel = (vgui::IPanel*)pFactoryList[i]( VGUI_PANEL_INTERFACE_VERSION, NULL );
  76. }
  77. if ( !g_pVGuiSurface )
  78. {
  79. g_pVGuiSurface = (vgui::ISurface*)pFactoryList[i]( VGUI_SURFACE_INTERFACE_VERSION, NULL );
  80. }
  81. if ( !g_pVGuiSchemeManager )
  82. {
  83. g_pVGuiSchemeManager = (vgui::ISchemeManager*)pFactoryList[i]( VGUI_SCHEME_INTERFACE_VERSION, NULL );
  84. }
  85. if ( !g_pVGuiSystem )
  86. {
  87. g_pVGuiSystem = (vgui::ISystem*)pFactoryList[i]( VGUI_SYSTEM_INTERFACE_VERSION, NULL );
  88. }
  89. if ( !g_pVGuiLocalize )
  90. {
  91. g_pVGuiLocalize = (vgui::ILocalize*)pFactoryList[i]( VGUI_LOCALIZE_INTERFACE_VERSION, NULL );
  92. }
  93. if ( !g_pMatSystemSurface )
  94. {
  95. g_pMatSystemSurface = ( IMatSystemSurface * )pFactoryList[i]( MAT_SYSTEM_SURFACE_INTERFACE_VERSION, NULL );
  96. }
  97. if ( !g_pDataCache )
  98. {
  99. g_pDataCache = (IDataCache*)pFactoryList[i]( DATACACHE_INTERFACE_VERSION, NULL );
  100. }
  101. if ( !g_pMDLCache )
  102. {
  103. g_pMDLCache = mdlcache = (IMDLCache*)pFactoryList[i]( MDLCACHE_INTERFACE_VERSION, NULL );
  104. }
  105. if ( !g_pVideo )
  106. {
  107. g_pVideo = (IVideoServices *)pFactoryList[i](VIDEO_SERVICES_INTERFACE_VERSION, NULL);
  108. }
  109. if ( !g_pDmeMakefileUtils )
  110. {
  111. g_pDmeMakefileUtils = (IDmeMakefileUtils*)pFactoryList[i]( DMEMAKEFILE_UTILS_INTERFACE_VERSION, NULL );
  112. }
  113. if ( !g_pPhysicsCollision )
  114. {
  115. g_pPhysicsCollision = ( IPhysicsCollision* )pFactoryList[i]( VPHYSICS_COLLISION_INTERFACE_VERSION, NULL );
  116. }
  117. if ( !g_pSoundEmitterSystem )
  118. {
  119. g_pSoundEmitterSystem = ( ISoundEmitterSystemBase* )pFactoryList[i]( SOUNDEMITTERSYSTEM_INTERFACE_VERSION, NULL );
  120. }
  121. if ( !g_pVTex )
  122. {
  123. g_pVTex = ( IVTex * )pFactoryList[i]( IVTEX_VERSION_STRING, NULL );
  124. }
  125. }
  126. }
  127. void DisconnectTier3Libraries()
  128. {
  129. g_pStudioRender = 0;
  130. studiorender = 0;
  131. g_pVGui = 0;
  132. g_pVGuiInput = 0;
  133. g_pVGuiPanel = 0;
  134. g_pVGuiSurface = 0;
  135. g_pVGuiLocalize = 0;
  136. g_pVGuiSchemeManager = 0;
  137. g_pVGuiSystem = 0;
  138. g_pMatSystemSurface = 0;
  139. g_pDataCache = 0;
  140. g_pMDLCache = 0;
  141. mdlcache = 0;
  142. g_pVideo = NULL;
  143. g_pPhysicsCollision = 0;
  144. g_pDmeMakefileUtils = NULL;
  145. g_pSoundEmitterSystem = 0;
  146. g_pVTex = NULL;
  147. }