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.

65 lines
1.9 KiB

  1. //====== Copyright � 1996-2005, 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. char pszModelName[ 1024 ];
  35. m_pData->GetText( pszModelName, sizeof( pszModelName ) );
  36. pMDLPickerDialog->SetInitialSelection( pszModelName );
  37. pMDLPickerDialog->DoModal( );
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Called when it's time to show the MDL picker
  41. //-----------------------------------------------------------------------------
  42. void CAttributeMDLPickerPanel::OnMDLSelected( KeyValues *pKeyValues )
  43. {
  44. const char *pMDLName = pKeyValues->GetString( "asset", NULL );
  45. if ( !pMDLName || !pMDLName[ 0 ] )
  46. return;
  47. // Apply to text panel
  48. m_pData->SetText( pMDLName );
  49. SetDirty(true);
  50. if ( IsAutoApply() )
  51. {
  52. Apply();
  53. }
  54. }