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.

125 lines
3.5 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef SOUNDPICKER_H
  7. #define SOUNDPICKER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "matsys_controls/BaseAssetPicker.h"
  12. #include "vgui_controls/Frame.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "tier1/utlstring.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. namespace vgui
  19. {
  20. class Panel;
  21. }
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Sound picker panel
  24. //-----------------------------------------------------------------------------
  25. class CSoundPicker : public CBaseAssetPicker
  26. {
  27. DECLARE_CLASS_SIMPLE( CSoundPicker, CBaseAssetPicker );
  28. public:
  29. enum PickType_t
  30. {
  31. PICK_NONE = 0,
  32. PICK_GAMESOUNDS = 0x1,
  33. PICK_WAVFILES = 0x2,
  34. PICK_ALL = 0x7FFFFFFF,
  35. ALLOW_MULTISELECT = 0x80000000,
  36. };
  37. CSoundPicker( vgui::Panel *pParent, int nFlags );
  38. // overridden frame functions
  39. virtual void Activate();
  40. // Forward arrow keys to the list
  41. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  42. // Sets the current sound choice
  43. void SetSelectedSound( PickType_t type, const char *pSoundName );
  44. // Returns the selceted sound name
  45. PickType_t GetSelectedSoundType();
  46. const char *GetSelectedSoundName( int nSelectionIndex = -1 );
  47. int GetSelectedSoundCount();
  48. void StopSoundPreview( );
  49. private:
  50. // Purpose: Called when a page is shown
  51. void RequestGameSoundFilterFocus( );
  52. // Updates the column header in the chooser
  53. void UpdateGameSoundColumnHeader( int nMatchCount, int nTotalCount );
  54. void BuildGameSoundList();
  55. void RefreshGameSoundList();
  56. void PlayGameSound( const char *pSoundName );
  57. void PlayWavSound( const char *pSoundName );
  58. void OnGameSoundFilterTextChanged( );
  59. // Derived classes have this called when the previewed asset changes
  60. void OnSelectedAssetPicked( const char *pAssetName );
  61. // Don't play a sound when the next selection is a default selection
  62. void OnNextSelectionIsDefault();
  63. // Purpose: builds the gamesound list
  64. bool IsGameSoundVisible( int hGameSound );
  65. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
  66. MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
  67. MESSAGE_FUNC( OnPageChanged, "PageChanged" );
  68. vgui::TextEntry *m_pGameSoundFilter;
  69. vgui::PropertySheet *m_pViewsSheet;
  70. vgui::PropertyPage *m_pGameSoundPage;
  71. vgui::PropertyPage *m_pWavPage;
  72. vgui::ListPanel *m_pGameSoundList;
  73. CUtlString m_GameSoundFilter;
  74. int m_nPlayingSound;
  75. unsigned char m_nSoundSuppressionCount;
  76. friend class CSoundPickerFrame;
  77. };
  78. //-----------------------------------------------------------------------------
  79. // Purpose: Modal sound picker window
  80. //-----------------------------------------------------------------------------
  81. class CSoundPickerFrame : public CBaseAssetPickerFrame
  82. {
  83. DECLARE_CLASS_SIMPLE( CSoundPickerFrame, CBaseAssetPickerFrame );
  84. public:
  85. CSoundPickerFrame( vgui::Panel *pParent, const char *pTitle, int nFlags );
  86. virtual ~CSoundPickerFrame();
  87. virtual void OnClose();
  88. // Purpose: Activate the dialog
  89. // The message "SoundSelected" will be sent if a sound is picked
  90. // Pass in optional context keyvalues to be added to any messages sent by the sound picker
  91. void DoModal( CSoundPicker::PickType_t initialType, const char *pInitialValue, KeyValues *pContextKeyValues = NULL );
  92. virtual void OnCommand( const char *pCommand );
  93. };
  94. #endif // SOUNDPICKER_H