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.

234 lines
5.2 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BASEMODELPANEL_H
  8. #define BASEMODELPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/IScheme.h>
  13. #include <vgui_controls/ImagePanel.h>
  14. #include <vgui_controls/EditablePanel.h>
  15. #include "GameEventListener.h"
  16. #include "keyvalues.h"
  17. class C_SceneEntity;
  18. class CModelPanelModel : public C_BaseFlex
  19. {
  20. public:
  21. CModelPanelModel(){}
  22. DECLARE_CLASS( CModelPanelModel, C_BaseFlex );
  23. virtual bool IsMenuModel() const{ return true; }
  24. };
  25. //-----------------------------------------------------------------------------
  26. // Purpose:
  27. //-----------------------------------------------------------------------------
  28. class CModelPanelModelAnimation
  29. {
  30. public:
  31. CModelPanelModelAnimation()
  32. {
  33. m_pszName = NULL;
  34. m_pszSequence = NULL;
  35. m_pszActivity = NULL;
  36. m_pPoseParameters = NULL;
  37. m_bDefault = false;
  38. }
  39. ~CModelPanelModelAnimation()
  40. {
  41. if ( m_pszName && m_pszName[0] )
  42. {
  43. delete [] m_pszName;
  44. m_pszName = NULL;
  45. }
  46. if ( m_pszSequence && m_pszSequence[0] )
  47. {
  48. delete [] m_pszSequence;
  49. m_pszSequence = NULL;
  50. }
  51. if ( m_pszActivity && m_pszActivity[0] )
  52. {
  53. delete [] m_pszActivity;
  54. m_pszActivity = NULL;
  55. }
  56. if ( m_pPoseParameters )
  57. {
  58. m_pPoseParameters->deleteThis();
  59. m_pPoseParameters = NULL;
  60. }
  61. }
  62. public:
  63. const char *m_pszName;
  64. const char *m_pszSequence;
  65. const char *m_pszActivity;
  66. KeyValues *m_pPoseParameters;
  67. bool m_bDefault;
  68. };
  69. //-----------------------------------------------------------------------------
  70. // Purpose:
  71. //-----------------------------------------------------------------------------
  72. class CModelPanelAttachedModelInfo
  73. {
  74. public:
  75. CModelPanelAttachedModelInfo()
  76. {
  77. m_pszModelName = NULL;
  78. m_nSkin = 0;
  79. }
  80. ~CModelPanelAttachedModelInfo()
  81. {
  82. if ( m_pszModelName && m_pszModelName[0] )
  83. {
  84. delete [] m_pszModelName;
  85. m_pszModelName = NULL;
  86. }
  87. }
  88. public:
  89. const char *m_pszModelName;
  90. int m_nSkin;
  91. };
  92. //-----------------------------------------------------------------------------
  93. // Purpose:
  94. //-----------------------------------------------------------------------------
  95. class CModelPanelModelInfo
  96. {
  97. public:
  98. CModelPanelModelInfo()
  99. {
  100. m_pszModelName = NULL;
  101. m_pszModelName_HWM = NULL;
  102. m_nSkin = -1;
  103. m_vecAbsAngles.Init();
  104. m_vecOriginOffset.Init();
  105. m_vecFramedOriginOffset.Init();
  106. m_bUseSpotlight = false;
  107. }
  108. ~CModelPanelModelInfo()
  109. {
  110. if ( m_pszModelName && m_pszModelName[0] )
  111. {
  112. delete [] m_pszModelName;
  113. m_pszModelName = NULL;
  114. }
  115. if ( m_pszModelName_HWM && m_pszModelName_HWM[0] )
  116. {
  117. delete [] m_pszModelName_HWM;
  118. m_pszModelName_HWM = NULL;
  119. }
  120. if ( m_pszVCD && m_pszVCD[0] )
  121. {
  122. delete [] m_pszVCD;
  123. m_pszVCD = NULL;
  124. }
  125. m_Animations.PurgeAndDeleteElements();
  126. m_AttachedModelsInfo.PurgeAndDeleteElements();
  127. }
  128. public:
  129. const char *m_pszModelName;
  130. const char *m_pszModelName_HWM;
  131. int m_nSkin;
  132. const char *m_pszVCD;
  133. Vector m_vecAbsAngles;
  134. Vector m_vecOriginOffset;
  135. Vector2D m_vecViewportOffset;
  136. Vector m_vecFramedOriginOffset;
  137. bool m_bUseSpotlight;
  138. CUtlVector<CModelPanelModelAnimation*> m_Animations;
  139. CUtlVector<CModelPanelAttachedModelInfo*> m_AttachedModelsInfo;
  140. };
  141. //-----------------------------------------------------------------------------
  142. // Purpose:
  143. //-----------------------------------------------------------------------------
  144. class CModelPanel : public vgui::EditablePanel, public CGameEventListener
  145. {
  146. public:
  147. DECLARE_CLASS_SIMPLE( CModelPanel, vgui::EditablePanel );
  148. CModelPanel( vgui::Panel *parent, const char *name );
  149. virtual ~CModelPanel();
  150. virtual void Paint();
  151. virtual void ApplySettings( KeyValues *inResourceData );
  152. virtual void DeleteVCDData( void );
  153. virtual void DeleteModelData( void );
  154. virtual void SetFOV( int nFOV ){ m_nFOV = nFOV; }
  155. virtual void SetPanelDirty( void ){ m_bPanelDirty = true; }
  156. virtual bool SetSequence( const char *pszSequence );
  157. MESSAGE_FUNC_PARAMS( OnAddAnimation, "AddAnimation", data );
  158. MESSAGE_FUNC_PARAMS( OnSetAnimation, "SetAnimation", data );
  159. void SetDefaultAnimation( const char *pszName );
  160. void SwapModel( const char *pszName, const char *pszAttached = NULL );
  161. virtual void ParseModelInfo( KeyValues *inResourceData );
  162. void ClearAttachedModelInfos( void );
  163. void CalculateFrameDistance( void );
  164. void ZoomToFrameDistance( void );
  165. public: // IGameEventListener:
  166. virtual void FireGameEvent( IGameEvent * event );
  167. protected:
  168. virtual void SetupModel( void );
  169. virtual void SetupVCD( void );
  170. virtual const char *GetModelName( void );
  171. private:
  172. void InitCubeMaps();
  173. int FindAnimByName( const char *pszName );
  174. void CalculateFrameDistanceInternal( const model_t *pModel );
  175. void UpdateIfDirty();
  176. public:
  177. int m_nFOV;
  178. float m_flFrameDistance;
  179. bool m_bStartFramed;
  180. CModelPanelModelInfo *m_pModelInfo;
  181. CHandle<CModelPanelModel> m_hModel;
  182. CUtlVector<CHandle<C_BaseAnimating> > m_AttachedModels;
  183. CHandle<C_SceneEntity> m_hScene;
  184. private:
  185. bool m_bPanelDirty;
  186. int m_iDefaultAnimation;
  187. bool m_bAllowOffscreen;
  188. CTextureReference m_DefaultEnvCubemap;
  189. CTextureReference m_DefaultHDREnvCubemap;
  190. };
  191. #endif // BASEMODELPANEL_H