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.

69 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "dme_controls/AttributeAssetPickerPanel.h"
  9. #include "dme_controls/AttributeTextEntry.h"
  10. #include "matsys_controls/AssetPicker.h"
  11. #include "matsys_controls/VtfPicker.h"
  12. #include "matsys_controls/VMTPicker.h"
  13. #include "tier1/KeyValues.h"
  14. using namespace vgui;
  15. //-----------------------------------------------------------------------------
  16. // Assets
  17. //-----------------------------------------------------------------------------
  18. IMPLEMENT_ATTRIBUTE_ASSET_PICKER( CAttributeBspPickerPanel, "Select .BSP file", "BSP Files", "bsp", "maps", "bspName" );
  19. IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVmtPickerPanel, CVMTPickerFrame, "Select .VMT file" );
  20. IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVtfPickerPanel, CVTFPickerFrame, "Select .VTF file" );
  21. //-----------------------------------------------------------------------------
  22. // Constructor
  23. //-----------------------------------------------------------------------------
  24. CAttributeAssetPickerPanel::CAttributeAssetPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  25. BaseClass( parent, info )
  26. {
  27. }
  28. CAttributeAssetPickerPanel::~CAttributeAssetPickerPanel()
  29. {
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Called when it's time to show the BSP picker
  33. //-----------------------------------------------------------------------------
  34. void CAttributeAssetPickerPanel::ShowPickerDialog()
  35. {
  36. CBaseAssetPickerFrame *pAssetPickerDialog = CreateAssetPickerFrame( );
  37. pAssetPickerDialog->AddActionSignalTarget( this );
  38. pAssetPickerDialog->DoModal( );
  39. }
  40. //-----------------------------------------------------------------------------
  41. // Called by the asset picker dialog if a asset was selected
  42. //-----------------------------------------------------------------------------
  43. void CAttributeAssetPickerPanel::OnAssetSelected( KeyValues *pKeyValues )
  44. {
  45. // Get the asset name back
  46. const char *pAssetName = pKeyValues->GetString( "asset", NULL );
  47. if ( !pAssetName || !pAssetName[ 0 ] )
  48. return;
  49. // Apply to text panel
  50. m_pData->SetText( pAssetName );
  51. SetDirty(true);
  52. if ( IsAutoApply() )
  53. {
  54. Apply();
  55. }
  56. }