diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /vgui2/dme_controls/AttributeSoundPickerPanel.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'vgui2/dme_controls/AttributeSoundPickerPanel.cpp')
| -rw-r--r-- | vgui2/dme_controls/AttributeSoundPickerPanel.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/vgui2/dme_controls/AttributeSoundPickerPanel.cpp b/vgui2/dme_controls/AttributeSoundPickerPanel.cpp new file mode 100644 index 0000000..c167c24 --- /dev/null +++ b/vgui2/dme_controls/AttributeSoundPickerPanel.cpp @@ -0,0 +1,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(); + } +} |