Team Fortress 2 Source Code as on 22/4/2020
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.

123 lines
3.5 KiB

  1. //========= Copyright 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. ~CSoundPicker();
  39. // overridden frame functions
  40. virtual void Activate();
  41. // Forward arrow keys to the list
  42. virtual void OnKeyCodePressed( vgui::KeyCode code );
  43. // Sets the current sound choice
  44. void SetSelectedSound( PickType_t type, const char *pSoundName );
  45. // Returns the selceted sound name
  46. PickType_t GetSelectedSoundType();
  47. const char *GetSelectedSoundName( int nSelectionIndex = -1 );
  48. int GetSelectedSoundCount();
  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 StopSoundPreview( );
  59. void OnGameSoundFilterTextChanged( );
  60. // Derived classes have this called when the previewed asset changes
  61. void OnSelectedAssetPicked( const char *pAssetName );
  62. // Don't play a sound when the next selection is a default selection
  63. void OnNextSelectionIsDefault();
  64. // Purpose: builds the gamesound list
  65. bool IsGameSoundVisible( int hGameSound );
  66. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
  67. MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
  68. MESSAGE_FUNC( OnPageChanged, "PageChanged" );
  69. vgui::TextEntry *m_pGameSoundFilter;
  70. vgui::PropertySheet *m_pViewsSheet;
  71. vgui::PropertyPage *m_pGameSoundPage;
  72. vgui::PropertyPage *m_pWavPage;
  73. vgui::ListPanel *m_pGameSoundList;
  74. CUtlString m_GameSoundFilter;
  75. int m_nPlayingSound;
  76. unsigned char m_nSoundSuppressionCount;
  77. friend class CSoundPickerFrame;
  78. };
  79. //-----------------------------------------------------------------------------
  80. // Purpose: Modal sound picker window
  81. //-----------------------------------------------------------------------------
  82. class CSoundPickerFrame : public CBaseAssetPickerFrame
  83. {
  84. DECLARE_CLASS_SIMPLE( CSoundPickerFrame, CBaseAssetPickerFrame );
  85. public:
  86. CSoundPickerFrame( vgui::Panel *pParent, const char *pTitle, int nFlags );
  87. virtual ~CSoundPickerFrame();
  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