blob: c167c24c93499a99f994b67bbcd1de0ab0b13b39 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "dme_controls/AttributeSoundPickerPanel.h"
#include "dme_controls/soundpicker.h"
#include "tier1/KeyValues.h"
#include "dme_controls/AttributeTextEntry.h"
#include "datamodel/dmelement.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CAttributeSoundPickerPanel::CAttributeSoundPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
BaseClass( parent, info )
{
}
CAttributeSoundPickerPanel::~CAttributeSoundPickerPanel()
{
}
//-----------------------------------------------------------------------------
// Called when it's time to show the sound picker
//-----------------------------------------------------------------------------
void CAttributeSoundPickerPanel::ShowPickerDialog()
{
// Open file
CSoundPicker::PickType_t pickType = CSoundPicker::PICK_ALL;
const char *pTextType = GetTextType();
if ( pTextType )
{
if ( !Q_stricmp( pTextType, "gamesoundName" ) )
{
pickType = CSoundPicker::PICK_GAMESOUNDS;
}
else if ( !Q_stricmp( pTextType, "wavName" ) )
{
pickType = CSoundPicker::PICK_WAVFILES;
}
}
const char *pCurrentSound = GetAttributeValue<CUtlString>().Get();
CSoundPickerFrame *pSoundPickerDialog = new CSoundPickerFrame( this, "Select sound", pickType );
pSoundPickerDialog->AddActionSignalTarget( this );
if ( pickType == CSoundPicker::PICK_ALL )
{
pickType = CSoundPicker::PICK_NONE;
}
pSoundPickerDialog->DoModal( pickType, pCurrentSound );
}
//-----------------------------------------------------------------------------
// Called when the sound picker has picked a sound
//-----------------------------------------------------------------------------
void CAttributeSoundPickerPanel::OnSoundSelected( KeyValues *pKeyValues )
{
// We're either going to get an activity or sequence name
const char *pGameSoundName = pKeyValues->GetString( "gamesound", NULL );
const char *pSoundName = pKeyValues->GetString( "wav", pGameSoundName );
if ( !pSoundName || !pSoundName[ 0 ] )
return;
// Apply to text panel
m_pData->SetText( pSoundName );
SetDirty(true);
if ( IsAutoApply() )
{
Apply();
}
}
|