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.

61 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "dme_controls/AttributeMDLPickerPanel.h"
  9. #include "filesystem.h"
  10. #include "vgui_controls/Button.h"
  11. #include "vgui_controls/FileOpenDialog.h"
  12. #include "dme_controls/AttributeTextEntry.h"
  13. #include "matsys_controls/MDLPicker.h"
  14. #include "tier1/KeyValues.h"
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // Constructor
  18. //-----------------------------------------------------------------------------
  19. CAttributeMDLPickerPanel::CAttributeMDLPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  20. BaseClass( parent, info )
  21. {
  22. }
  23. CAttributeMDLPickerPanel::~CAttributeMDLPickerPanel()
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Called when it's time to show the MDL picker
  28. //-----------------------------------------------------------------------------
  29. void CAttributeMDLPickerPanel::ShowPickerDialog()
  30. {
  31. // Open file
  32. CMDLPickerFrame *pMDLPickerDialog = new CMDLPickerFrame( this, "Select .MDL File" );
  33. pMDLPickerDialog->AddActionSignalTarget( this );
  34. pMDLPickerDialog->DoModal( );
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Called when it's time to show the MDL picker
  38. //-----------------------------------------------------------------------------
  39. void CAttributeMDLPickerPanel::OnMDLSelected( KeyValues *pKeyValues )
  40. {
  41. const char *pMDLName = pKeyValues->GetString( "mdl", NULL );
  42. if ( !pMDLName || !pMDLName[ 0 ] )
  43. return;
  44. // Apply to text panel
  45. m_pData->SetText( pMDLName );
  46. SetDirty(true);
  47. if ( IsAutoApply() )
  48. {
  49. Apply();
  50. }
  51. }