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.

102 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "dme_controls/dmecontrols.h"
  8. #include "soundemittersystem/isoundemittersystembase.h"
  9. #include "matsys_controls/matsyscontrols.h"
  10. #include "toolframework/ienginetool.h"
  11. #include "vphysics_interface.h"
  12. #include "dme_controls/inotifyui.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. namespace vgui
  16. {
  17. ISoundEmitterSystemBase *g_pSoundEmitterSystem = NULL;
  18. ISoundEmitterSystemBase *SoundEmitterSystem()
  19. {
  20. return g_pSoundEmitterSystem;
  21. }
  22. IEngineTool *enginetools = NULL;
  23. IEngineTool *EngineTool()
  24. {
  25. return enginetools;
  26. }
  27. IPhysicsCollision *g_pPhysicsCollision = NULL;
  28. IPhysicsCollision *PhysicsCollision()
  29. {
  30. return g_pPhysicsCollision;
  31. }
  32. class CDefaultElementPropertiesChoices : public CBaseElementPropertiesChoices
  33. {
  34. public:
  35. };
  36. static CDefaultElementPropertiesChoices s_DefaultChoices;
  37. IElementPropertiesChoices *g_pElementPropertiesChoices = &s_DefaultChoices;
  38. IElementPropertiesChoices *ElementPropertiesChoices()
  39. {
  40. return g_pElementPropertiesChoices;
  41. }
  42. void SetElementPropertiesChoices( IElementPropertiesChoices *pElementPropertiesChoices )
  43. {
  44. g_pElementPropertiesChoices = pElementPropertiesChoices ? pElementPropertiesChoices : &s_DefaultChoices;
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose: finds a particular interface in the factory set
  48. //-----------------------------------------------------------------------------
  49. static void *InitializeInterface( char const *interfaceName, CreateInterfaceFn *factoryList, int numFactories )
  50. {
  51. void *retval;
  52. for ( int i = 0; i < numFactories; i++ )
  53. {
  54. CreateInterfaceFn factory = factoryList[ i ];
  55. if ( !factory )
  56. continue;
  57. retval = factory( interfaceName, NULL );
  58. if ( retval )
  59. return retval;
  60. }
  61. // No provider for requested interface!!!
  62. // Assert( !"No provider for requested interface!!!" );
  63. return NULL;
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose: Initializes the controls
  67. //-----------------------------------------------------------------------------
  68. bool VGui_InitDmeInterfacesList( const char *moduleName, CreateInterfaceFn *factoryList, int numFactories )
  69. {
  70. if ( !vgui::VGui_InitMatSysInterfacesList( moduleName, factoryList, numFactories ) )
  71. return false;
  72. g_pSoundEmitterSystem = (ISoundEmitterSystemBase*)InitializeInterface( SOUNDEMITTERSYSTEM_INTERFACE_VERSION, factoryList, numFactories );
  73. enginetools = (IEngineTool*)InitializeInterface( VENGINETOOL_INTERFACE_VERSION, factoryList, numFactories );
  74. g_pPhysicsCollision = (IPhysicsCollision*)InitializeInterface( VPHYSICS_COLLISION_INTERFACE_VERSION, factoryList, numFactories );
  75. // Can function without either of these
  76. return true;
  77. }
  78. } // namespace vgui