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.

187 lines
5.7 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef PARTICLEPICKER_H
  7. #define PARTICLEPICKER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlstring.h"
  12. #include "vgui_controls/Frame.h"
  13. #include "matsys_controls/baseassetpicker.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. namespace vgui
  18. {
  19. class Splitter;
  20. class EditablePanel;
  21. class ScrollBar;
  22. class IScheme;
  23. class IImage;
  24. }
  25. class CParticleSystemPanel;
  26. class CParticleSnapshotPanel;
  27. class CParticleCollection;
  28. //-----------------------------------------------------------------------------
  29. // Purpose: Grid of particle snapshots
  30. //-----------------------------------------------------------------------------
  31. class CParticleSnapshotGrid: public vgui::EditablePanel
  32. {
  33. DECLARE_CLASS_SIMPLE( CParticleSnapshotGrid, vgui::EditablePanel );
  34. public:
  35. CParticleSnapshotGrid( vgui::Panel *pParent, const char *pName );
  36. virtual void PerformLayout();
  37. virtual void OnTick();
  38. virtual void OnMousePressed(vgui::MouseCode code);
  39. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  40. virtual void OnMouseWheeled(int delta);
  41. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  42. /*
  43. Since the grid can be re-ordered:
  44. - "index" is the location of a preview panel in m_Panels, which determines physical placement
  45. - "id" is the location of the system in the original SetParticleList() array that was handed in (useful for clients)
  46. */
  47. void SetParticleList( const CUtlVector<const char *>& ParticleNames );
  48. void LayoutScrolled();
  49. const char *GetSystemName( int nId );
  50. int GetSelectedSystemId( int nSelectionIndex );
  51. int GetSelectedSystemCount( );
  52. void SelectId( int nId, bool bAddToSelection, bool bToggle );
  53. void SelectSystem( const char *pSystemName, bool bAddToSelection, bool bToggle );
  54. void DeselectAll();
  55. MESSAGE_FUNC_CHARPTR( OnParticleSystemSelected, "ParticleSystemSelected", SystemName );
  56. MESSAGE_FUNC_CHARPTR( OnParticleSystemCtrlSelected, "ParticleSystemCtrlSelected", SystemName );
  57. MESSAGE_FUNC_CHARPTR( OnParticleSystemShiftSelected, "ParticleSystemShiftSelected", SystemName );
  58. MESSAGE_FUNC_CHARPTR( OnParticleSystemPicked, "ParticleSystemPicked", SystemName );
  59. MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" );
  60. MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", kv );
  61. struct PSysRelativeInfo_t
  62. {
  63. CUtlString relName;
  64. bool bVisibleInCurrentView;
  65. };
  66. private:
  67. void SelectIndex( int nIndex, bool bAddToSelection, bool bToggle );
  68. int IdToIndex( int nId );
  69. int InternalFindSystemIndexByName( const char *pSystemName );
  70. bool IsSystemVisible( int nInternalIndex );
  71. void UpdatePanelRelatives( int nInternalIndex );
  72. void MapSystemRelatives( );
  73. void UpdateAllRelatives( );
  74. void SetAllPreviewEnabled( bool bEnabled );
  75. int GetPanelWide();
  76. int GetPanelTall();
  77. vgui::Panel *m_pScrollPanel;
  78. vgui::Panel *m_pToolPanel;
  79. vgui::ScrollBar *m_pScrollBar;
  80. vgui::Label *m_pNoSystemsLabel;
  81. vgui::CheckButton *m_pPreviewCheckbox;
  82. CUtlVector<CParticleSnapshotPanel*> m_Panels;
  83. int m_nCurrentColCount;
  84. bool m_bAllowMultipleSelection;
  85. int m_nMostRecentSelectedIndex;
  86. vgui::IImage *m_pRelativesImgNeither;
  87. vgui::IImage *m_pRelativesImgPOnly;
  88. vgui::IImage *m_pRelativesImgCOnly;
  89. vgui::IImage *m_pRelativesImgBoth;
  90. CUtlVector< CUtlVector<PSysRelativeInfo_t> > m_ParentsMap;
  91. CUtlVector< CUtlVector<PSysRelativeInfo_t> > m_ChildrenMap;
  92. };
  93. //-----------------------------------------------------------------------------
  94. // Particle picker panel
  95. //-----------------------------------------------------------------------------
  96. class CParticlePicker : public CBaseAssetPicker
  97. {
  98. DECLARE_CLASS_SIMPLE( CParticlePicker, CBaseAssetPicker );
  99. public:
  100. CParticlePicker( vgui::Panel *pParent );
  101. ~CParticlePicker();
  102. virtual void PerformLayout();
  103. virtual void OnMousePressed(vgui::MouseCode code);
  104. void GetSelectedParticleSysName( char *pBuffer, int nMaxLen );
  105. void SelectParticleSys( const char *pRelativePath );
  106. // asset cache interface
  107. virtual int GetAssetCount();
  108. virtual const char *GetAssetName( int nAssetIndex );
  109. virtual const CachedAssetInfo_t& GetCachedAsset( int nAssetIndex );
  110. virtual int GetCachedAssetCount();
  111. virtual bool IncrementalCacheAssets( float flTimeAllowed ); // return true if finished
  112. virtual bool BeginCacheAssets( bool bForceRecache ); // return true if finished
  113. virtual CUtlString GetSelectedAssetFullPath( int nIndex );
  114. protected:
  115. virtual void OnAssetListChanged( );
  116. private:
  117. MESSAGE_FUNC_PARAMS( OnAssetSelected, "AssetSelected", params );
  118. MESSAGE_FUNC( OnParticleSystemSelectionChanged, "ParticleSystemSelectionChanged" );
  119. MESSAGE_FUNC_CHARPTR( OnParticleSystemPicked, "ParticleSystemPicked", SystemName );
  120. virtual void OnSelectedAssetPicked( const char *pParticleSysName );
  121. void CachePCFInfo( int nModIndex, const char *pFileName );
  122. void HandleModParticles( int nModIndex );
  123. vgui::Splitter* m_pFileBrowserSplitter;
  124. CParticleSnapshotGrid *m_pSnapshotGrid;
  125. friend class CParticlePickerFrame;
  126. };
  127. //-----------------------------------------------------------------------------
  128. // Purpose: Main app window
  129. //-----------------------------------------------------------------------------
  130. class CParticlePickerFrame : public CBaseAssetPickerFrame
  131. {
  132. DECLARE_CLASS_SIMPLE( CParticlePickerFrame, CBaseAssetPickerFrame );
  133. public:
  134. CParticlePickerFrame( vgui::Panel *pParent, const char *pTitle );
  135. virtual ~CParticlePickerFrame();
  136. // Allows external apps to select a MDL
  137. void SelectParticleSys( const char *pRelativePath );
  138. };
  139. #endif // MDLPICKER_H