summaryrefslogtreecommitdiff
path: root/movieobjects/dmesound.cpp
blob: d94c7323b4c14108fcf589c59326ffa73a261ab3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================
#include "movieobjects/dmesound.h"
#include "datamodel/dmelementfactoryhelper.h"
#include "movieobjects_interfaces.h"
#include "tier2/tier2.h"
#include "filesystem.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

//-----------------------------------------------------------------------------
// Expose this class to the scene database 
//-----------------------------------------------------------------------------
IMPLEMENT_ELEMENT_FACTORY( DmeSound, CDmeSound );


//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
void CDmeSound::OnConstruction()
{
	m_SoundName.Init( this, "soundname" );
	m_GameSoundName.Init( this, "gameSoundName" );
}

void CDmeSound::OnDestruction()
{
}


//-----------------------------------------------------------------------------
// For sounds that are relative paths (instead of GameSound names), get full path
//-----------------------------------------------------------------------------
bool CDmeSound::ComputeSoundFullPath( char *pBuf, int nBufLen )
{
	if ( !m_SoundName[0] )
	{
		pBuf[0] = 0;
		return false;
	}

	// Compute the full path of the sound
	char pRelativePath[MAX_PATH];
	Q_snprintf( pRelativePath, sizeof(pRelativePath), "sound\\%s", m_SoundName.Get() );
	return g_pFullFileSystem->RelativePathToFullPath( pRelativePath, "GAME", pBuf, nBufLen ) != NULL;
}


//-----------------------------------------------------------------------------
// Expose this class to the scene database 
//-----------------------------------------------------------------------------
IMPLEMENT_ELEMENT_FACTORY( DmeGameSound, CDmeGameSound );


//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
void CDmeGameSound::OnConstruction()
{
	m_Volume	.Init( this, "volume" );
	m_Level		.Init( this, "level" );
	m_Pitch		.Init( this, "pitch" );

	m_IsStatic	.Init( this, "static" );
	m_Channel	.Init( this, "channel" );
	m_Flags		.Init( this, "flags" );

//	m_Source	.Init( this, "source" );
//	m_FollowSource.Init( this, "followsource" );
	m_Origin	.Init( this, "origin" );
	m_Direction	.Init( this, "direction" );
}

void CDmeGameSound::OnDestruction()
{
}

CDmElement *CDmeGameSound::FindOrAddPhonemeExtractionSettings()
{
	if ( HasAttribute( "PhonemeExtractionSettings" ) )
		return GetValueElement< CDmElement >( "PhonemeExtractionSettings" );

	CDmElement *settings = CreateElement< CDmElement >( "PhonemeExtractionSettings", GetFileId() );
	if ( !settings )
		return NULL;

	SetValue( "PhonemeExtractionSettings", settings );
	return settings;
}