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.

70 lines
2.3 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "dme_controls/AttributeFilePickerPanel.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 "vgui/IInput.h"
  14. // memdbgon must be the last include file in a .cpp file!!!
  15. #include "tier0/memdbgon.h"
  16. using namespace vgui;
  17. //-----------------------------------------------------------------------------
  18. // Various file picker types
  19. //-----------------------------------------------------------------------------
  20. IMPLEMENT_ATTRIBUTE_FILE_PICKER( CAttributeDmeFilePickerPanel, "Choose DMX file", "DMX", "dmx" );
  21. IMPLEMENT_ATTRIBUTE_FILE_PICKER( CAttributeAviFilePickerPanel, "Choose AVI file", "AVI", "avi" );
  22. IMPLEMENT_ATTRIBUTE_FILE_PICKER( CAttributeShtFilePickerPanel, "Choose Sheet file", "SHT", "sht" );
  23. IMPLEMENT_ATTRIBUTE_FILE_PICKER( CAttributeRawFilePickerPanel, "Choose RAW file", "RAW", "raw" );
  24. //-----------------------------------------------------------------------------
  25. // Constructor
  26. //-----------------------------------------------------------------------------
  27. CAttributeFilePickerPanel::CAttributeFilePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  28. BaseClass( parent, info )
  29. {
  30. }
  31. CAttributeFilePickerPanel::~CAttributeFilePickerPanel()
  32. {
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Shows the picker dialog
  36. //-----------------------------------------------------------------------------
  37. void CAttributeFilePickerPanel::ShowPickerDialog()
  38. {
  39. FileOpenDialog *pFileOpenDialog = new FileOpenDialog( this, "Choose file", true );
  40. SetupFileOpenDialog( pFileOpenDialog );
  41. pFileOpenDialog->AddActionSignalTarget( this );
  42. pFileOpenDialog->DoModal( true );
  43. input()->SetAppModalSurface( pFileOpenDialog->GetVPanel() );
  44. }
  45. void CAttributeFilePickerPanel::OnFileSelected( char const *fullpath )
  46. {
  47. if ( !fullpath || !fullpath[ 0 ] )
  48. return;
  49. char relativepath[ 512 ];
  50. g_pFullFileSystem->FullPathToRelativePath( fullpath, relativepath, sizeof( relativepath ) );
  51. // Apply to text panel
  52. m_pData->SetText( relativepath );
  53. SetDirty(true);
  54. if ( IsAutoApply() )
  55. {
  56. Apply();
  57. }
  58. }