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.

101 lines
3.3 KiB

  1. //====== Copyright � 1996-2005, 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/TGAPicker.h"
  13. #include "matsys_controls/VMTPicker.h"
  14. #include "tier1/keyvalues.h"
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // Assets
  18. //-----------------------------------------------------------------------------
  19. IMPLEMENT_ATTRIBUTE_ASSET_PICKER( CAttributeBspPickerPanel, "Select .BSP file", "BSP Files", "bsp", "maps", "bspName" );
  20. IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVmtPickerPanel, CVMTPickerFrame, "Select .VMT file" );
  21. IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVtfPickerPanel, CVTFPickerFrame, "Select .VTF file" );
  22. IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeTgaPickerPanel, CTGAPickerFrame, "Select .TGA file" );
  23. void CAttributeVmtPickerPanel::OnAssetSelected( KeyValues *kv )
  24. {
  25. BaseClass::OnAssetSelected(kv);
  26. int nSheetSequenceCount = kv->GetInt( "sheet_sequence_count" );
  27. int nSheetSequenceNum = kv->GetInt( "sheet_sequence_number" );
  28. int nSecondSheetSequenceNum = kv->GetInt( "sheet_sequence_secondary_number" );
  29. if ( nSheetSequenceCount > 0 )
  30. {
  31. CUndoScopeGuard guard( 0, NOTIFY_SETDIRTYFLAG, GetNotify(), "Auto-Set Sequence from VMT dialog" );
  32. // selected a VMT that uses sheet information
  33. CDmElement* pElement = GetPanelElement();
  34. CDmAttribute* pSeqNumberAttr = pElement->GetAttribute("sequence_number");
  35. if ( pSeqNumberAttr )
  36. {
  37. pSeqNumberAttr->SetValue(nSheetSequenceNum);
  38. }
  39. CDmAttribute* pSecondSeqNumberAttr = pElement->GetAttribute("sequence_number 1");
  40. if ( pSecondSeqNumberAttr )
  41. {
  42. pSecondSeqNumberAttr->SetValue(nSecondSheetSequenceNum);
  43. }
  44. }
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Constructor
  48. //-----------------------------------------------------------------------------
  49. CAttributeAssetPickerPanel::CAttributeAssetPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  50. BaseClass( parent, info )
  51. {
  52. }
  53. CAttributeAssetPickerPanel::~CAttributeAssetPickerPanel()
  54. {
  55. }
  56. //-----------------------------------------------------------------------------
  57. // Called when it's time to show the BSP picker
  58. //-----------------------------------------------------------------------------
  59. void CAttributeAssetPickerPanel::ShowPickerDialog()
  60. {
  61. CBaseAssetPickerFrame *pAssetPickerDialog = CreateAssetPickerFrame( );
  62. pAssetPickerDialog->AddActionSignalTarget( this );
  63. pAssetPickerDialog->DoModal( );
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Called by the asset picker dialog if a asset was selected
  67. //-----------------------------------------------------------------------------
  68. void CAttributeAssetPickerPanel::OnAssetSelected( KeyValues *pKeyValues )
  69. {
  70. // Get the asset name back
  71. const char *pAssetName = pKeyValues->GetString( "asset", NULL );
  72. if ( !pAssetName || !pAssetName[ 0 ] )
  73. return;
  74. // Apply to text panel
  75. m_pData->SetText( pAssetName );
  76. SetDirty(true);
  77. if ( IsAutoApply() )
  78. {
  79. Apply();
  80. }
  81. }