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.

93 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef ATTRIBUTEASSETPICKERPANEL_H
  9. #define ATTRIBUTEASSETPICKERPANEL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "dme_controls/AttributeBasePickerPanel.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. class CBaseAssetPickerFrame;
  18. //-----------------------------------------------------------------------------
  19. // CAttributeAssetPickerPanel
  20. //-----------------------------------------------------------------------------
  21. class CAttributeAssetPickerPanel : public CAttributeBasePickerPanel
  22. {
  23. DECLARE_CLASS_SIMPLE( CAttributeAssetPickerPanel, CAttributeBasePickerPanel );
  24. public:
  25. CAttributeAssetPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
  26. ~CAttributeAssetPickerPanel();
  27. private:
  28. virtual CBaseAssetPickerFrame *CreateAssetPickerFrame() = 0;
  29. MESSAGE_FUNC_PARAMS( OnAssetSelected, "AssetSelected", kv );
  30. virtual void ShowPickerDialog();
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Macro to quickly make new attribute types
  34. //-----------------------------------------------------------------------------
  35. #define DECLARE_ATTRIBUTE_ASSET_PICKER( _className ) \
  36. class _className : public CAttributeAssetPickerPanel \
  37. { \
  38. DECLARE_CLASS_SIMPLE( _className, CAttributeAssetPickerPanel ); \
  39. public: \
  40. _className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
  41. BaseClass( parent, info ) {} \
  42. private: \
  43. virtual CBaseAssetPickerFrame *CreateAssetPickerFrame(); \
  44. }
  45. #define IMPLEMENT_ATTRIBUTE_ASSET_PICKER( _className, _popupTitle, _assetType, _assetExt, _assetSubDir, _assetTextType ) \
  46. CBaseAssetPickerFrame *_className::CreateAssetPickerFrame() \
  47. { \
  48. return new CAssetPickerFrame( this, _popupTitle, _assetType, _assetExt, _assetSubDir, _assetTextType ); \
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Macro to quickly make new attribute types
  52. //-----------------------------------------------------------------------------
  53. #define DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( _className ) \
  54. class _className : public CAttributeAssetPickerPanel \
  55. { \
  56. DECLARE_CLASS_SIMPLE( _className, CAttributeAssetPickerPanel ); \
  57. public: \
  58. _className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
  59. BaseClass( parent, info ) {} \
  60. private: \
  61. virtual CBaseAssetPickerFrame *CreateAssetPickerFrame(); \
  62. }
  63. #define IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( _className, _pickerClassName, _popupTitle ) \
  64. CBaseAssetPickerFrame *_className::CreateAssetPickerFrame() \
  65. { \
  66. return new _pickerClassName( this, _popupTitle ); \
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Assets
  70. //-----------------------------------------------------------------------------
  71. DECLARE_ATTRIBUTE_ASSET_PICKER( CAttributeBspPickerPanel );
  72. DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVmtPickerPanel );
  73. DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVtfPickerPanel );
  74. #endif // ATTRIBUTEASSETPICKERPANEL_H