Counter Strike : Global Offensive Source Code
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.

86 lines
2.5 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "dme_controls/AttributeSoundPickerPanel.h"
  9. #include "dme_controls/soundpicker.h"
  10. #include "tier1/keyvalues.h"
  11. #include "dme_controls/AttributeTextEntry.h"
  12. #include "datamodel/dmelement.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // Constructor
  18. //-----------------------------------------------------------------------------
  19. CAttributeSoundPickerPanel::CAttributeSoundPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  20. BaseClass( parent, info )
  21. {
  22. }
  23. CAttributeSoundPickerPanel::~CAttributeSoundPickerPanel()
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Called when it's time to show the sound picker
  28. //-----------------------------------------------------------------------------
  29. void CAttributeSoundPickerPanel::ShowPickerDialog()
  30. {
  31. // Open file
  32. CSoundPicker::PickType_t pickType = CSoundPicker::PICK_ALL;
  33. const char *pTextType = GetTextType();
  34. if ( pTextType )
  35. {
  36. if ( !Q_stricmp( pTextType, "gamesoundName" ) )
  37. {
  38. pickType = CSoundPicker::PICK_GAMESOUNDS;
  39. }
  40. else if ( !Q_stricmp( pTextType, "wavName" ) )
  41. {
  42. pickType = CSoundPicker::PICK_WAVFILES;
  43. }
  44. }
  45. CUtlSymbolLarge symbol = GetAttributeValue<CUtlSymbolLarge>();
  46. const char *pCurrentSound = symbol.String();
  47. CSoundPickerFrame *pSoundPickerDialog = new CSoundPickerFrame( this, "Select sound", pickType );
  48. pSoundPickerDialog->AddActionSignalTarget( this );
  49. if ( pickType == CSoundPicker::PICK_ALL )
  50. {
  51. pickType = CSoundPicker::PICK_NONE;
  52. }
  53. pSoundPickerDialog->DoModal( pickType, pCurrentSound );
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Called when the sound picker has picked a sound
  57. //-----------------------------------------------------------------------------
  58. void CAttributeSoundPickerPanel::OnSoundSelected( KeyValues *pKeyValues )
  59. {
  60. // We're either going to get an activity or sequence name
  61. const char *pGameSoundName = pKeyValues->GetString( "gamesound", NULL );
  62. const char *pSoundName = pKeyValues->GetString( "wav", pGameSoundName );
  63. if ( !pSoundName || !pSoundName[ 0 ] )
  64. return;
  65. // Apply to text panel
  66. m_pData->SetText( pSoundName );
  67. SetDirty(true);
  68. if ( IsAutoApply() )
  69. {
  70. Apply();
  71. }
  72. }