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.

93 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "movieobjects/dmesound.h"
  7. #include "datamodel/dmelementfactoryhelper.h"
  8. #include "movieobjects_interfaces.h"
  9. #include "tier2/tier2.h"
  10. #include "filesystem.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. // Expose this class to the scene database
  15. //-----------------------------------------------------------------------------
  16. IMPLEMENT_ELEMENT_FACTORY( DmeSound, CDmeSound );
  17. //-----------------------------------------------------------------------------
  18. // Constructor, destructor
  19. //-----------------------------------------------------------------------------
  20. void CDmeSound::OnConstruction()
  21. {
  22. m_SoundName.Init( this, "soundname" );
  23. m_GameSoundName.Init( this, "gameSoundName" );
  24. }
  25. void CDmeSound::OnDestruction()
  26. {
  27. }
  28. //-----------------------------------------------------------------------------
  29. // For sounds that are relative paths (instead of GameSound names), get full path
  30. //-----------------------------------------------------------------------------
  31. bool CDmeSound::ComputeSoundFullPath( char *pBuf, int nBufLen )
  32. {
  33. if ( !m_SoundName[0] )
  34. {
  35. pBuf[0] = 0;
  36. return false;
  37. }
  38. // Compute the full path of the sound
  39. char pRelativePath[MAX_PATH];
  40. Q_snprintf( pRelativePath, sizeof(pRelativePath), "sound\\%s", m_SoundName.Get() );
  41. return g_pFullFileSystem->RelativePathToFullPath( pRelativePath, "GAME", pBuf, nBufLen ) != NULL;
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Expose this class to the scene database
  45. //-----------------------------------------------------------------------------
  46. IMPLEMENT_ELEMENT_FACTORY( DmeGameSound, CDmeGameSound );
  47. //-----------------------------------------------------------------------------
  48. // Constructor, destructor
  49. //-----------------------------------------------------------------------------
  50. void CDmeGameSound::OnConstruction()
  51. {
  52. m_Volume .Init( this, "volume" );
  53. m_Level .Init( this, "level" );
  54. m_Pitch .Init( this, "pitch" );
  55. m_IsStatic .Init( this, "static" );
  56. m_Channel .Init( this, "channel" );
  57. m_Flags .Init( this, "flags" );
  58. // m_Source .Init( this, "source" );
  59. // m_FollowSource.Init( this, "followsource" );
  60. m_Origin .Init( this, "origin" );
  61. m_Direction .Init( this, "direction" );
  62. }
  63. void CDmeGameSound::OnDestruction()
  64. {
  65. }
  66. CDmElement *CDmeGameSound::FindOrAddPhonemeExtractionSettings()
  67. {
  68. if ( HasAttribute( "PhonemeExtractionSettings" ) )
  69. return GetValueElement< CDmElement >( "PhonemeExtractionSettings" );
  70. CDmElement *settings = CreateElement< CDmElement >( "PhonemeExtractionSettings", GetFileId() );
  71. if ( !settings )
  72. return NULL;
  73. SetValue( "PhonemeExtractionSettings", settings );
  74. return settings;
  75. }