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.

76 lines
2.4 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "filesystem.h"
  7. #include "matsys_controls/tgapicker.h"
  8. #include "matsys_controls/tgapreviewpanel.h"
  9. #include "vgui_controls/Splitter.h"
  10. using namespace vgui;
  11. //-----------------------------------------------------------------------------
  12. //
  13. // Asset Picker with no preview
  14. //
  15. //-----------------------------------------------------------------------------
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Constructor
  18. //-----------------------------------------------------------------------------
  19. CTGAPicker::CTGAPicker( vgui::Panel *pParent ) :
  20. BaseClass( pParent, "TGA Files", "tga", "materialsrc", "tgaName", "CONTENT" )
  21. {
  22. // Horizontal splitter for preview
  23. m_pPreviewSplitter = new Splitter( this, "PreviewSplitter", SPLITTER_MODE_VERTICAL, 1 );
  24. vgui::Panel *pSplitterLeftSide = m_pPreviewSplitter->GetChild( 0 );
  25. vgui::Panel *pSplitterRightSide = m_pPreviewSplitter->GetChild( 1 );
  26. // TGA preview
  27. m_pTGAPreview = new CTGAPreviewPanel( pSplitterRightSide, "TGAPreview" );
  28. m_pTGAPreview->MaintainProportions( true );
  29. // Standard browser controls
  30. CreateStandardControls( pSplitterLeftSide );
  31. LoadControlSettingsAndUserConfig( "resource/tgapicker.res" );
  32. }
  33. CTGAPicker::~CTGAPicker()
  34. {
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Derived classes have this called when the previewed asset changes
  38. //-----------------------------------------------------------------------------
  39. void CTGAPicker::OnSelectedAssetPicked( const char *pAssetName )
  40. {
  41. char pFullPath[ MAX_PATH ];
  42. char pRelativePath[MAX_PATH];
  43. Q_snprintf( pRelativePath, sizeof(pRelativePath), "materialsrc\\%s", pAssetName );
  44. g_pFullFileSystem->RelativePathToFullPath( pRelativePath, "CONTENT", pFullPath, sizeof(pFullPath) );
  45. m_pTGAPreview->SetTGA( pFullPath );
  46. }
  47. //-----------------------------------------------------------------------------
  48. //
  49. // Purpose: Modal picker frame
  50. //
  51. //-----------------------------------------------------------------------------
  52. CTGAPickerFrame::CTGAPickerFrame( vgui::Panel *pParent, const char *pTitle ) :
  53. BaseClass( pParent )
  54. {
  55. SetAssetPicker( new CTGAPicker( this ) );
  56. LoadControlSettingsAndUserConfig( "resource/tgapickerframe.res" );
  57. SetTitle( pTitle, false );
  58. }