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.

118 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMEGRAPHIC_H
  8. #define GAMEGRAPHIC_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "uigeometry.h"
  13. #include "tier1/utlvector.h"
  14. #include "inputsystem/ButtonCode.h"
  15. #include "tier1/utlstring.h"
  16. //#include "gameuiscript.h"
  17. #include "filesystem.h"
  18. struct InputEvent_t;
  19. class CGraphicGroup;
  20. class CGameUIScript;
  21. class CGameUIDefinition;
  22. class CAnimData;
  23. class CDmxElement;
  24. enum EScriptExecution;
  25. struct StageRenderInfo_t
  26. {
  27. Vector parentPos;
  28. Vector2D parentScale;
  29. int parentRot;
  30. matrix3x4_t relToScreen;
  31. matrix3x4_t relToScreenHoldAspectRatio;
  32. };
  33. //-----------------------------------------------------------------------------
  34. // A class that contains a rect or text or hit area
  35. //-----------------------------------------------------------------------------
  36. class CGameGraphic
  37. {
  38. public:
  39. CGameGraphic();
  40. virtual ~CGameGraphic();
  41. // Update geometry and execute scripting.
  42. virtual void UpdateGeometry(){}
  43. // Populate lists for rendering
  44. virtual void UpdateRenderTransforms( const StageRenderInfo_t &stageRenderInfo );
  45. virtual void UpdateRenderData( color32 parentColor, CUtlVector< RenderGeometryList_t > &renderGeometryLists, int firstListIndex );
  46. virtual void DrawExtents( CUtlVector< RenderGeometryList_t > &renderGeometryLists, int firstListIndex );
  47. virtual bool HasState( const char *pStateName );
  48. virtual void SetState( const char *pStateName, bool bStartPlaying = true );
  49. bool IsDonePlaying();
  50. const char *GetState();
  51. virtual void StartPlaying();
  52. virtual void StopPlaying();
  53. virtual void AdvanceState();
  54. void SetAnimationTimePassed( DmeTime_t time );
  55. DmeTime_t GetAnimationTimePassed();
  56. virtual KeyValues *HandleScriptCommand( KeyValues *args );
  57. virtual bool HitTest( int x, int y ) { return false; }
  58. CGraphicGroup *GetGroup() const { return m_pGroup; }
  59. void SetGroup( CGraphicGroup *pGroup ) { m_pGroup = pGroup; }
  60. const char *GetName() const { return m_pName; }
  61. bool IsGraphicNamed( const char *pName );
  62. virtual CGameGraphic *FindGraphicByName( const char *pName ) const;
  63. virtual void SetVisible( bool bVisible ){ m_Geometry.m_bVisible = bVisible; }
  64. bool GetVisible( ) const { return m_Geometry.m_bVisible; }
  65. bool CanAcceptInput() const { return m_bCanAcceptInput; }
  66. virtual bool IsHitArea() const { return false; }
  67. virtual bool IsGroup() const { return false; }
  68. virtual bool IsDynamic() const { return false; }
  69. void SetResultantColor( bool bTop, color32 parentColor );
  70. virtual bool MaintainAspectRatio() const { return m_Geometry.m_bMaintainAspectRatio; }
  71. int32 GetScriptHandle() { return m_iScriptHandle; }
  72. static CGameGraphic * FromScriptHandle( int32 iScriptHandle );
  73. virtual const char *GetMaterialAlias(){ return NULL; }
  74. virtual void SetCenter( float x, float y ) { m_Geometry.m_Center = Vector2D( x, y ); }
  75. virtual void SetScale( float xScale, float yScale ) { m_Geometry.m_Scale = Vector2D( xScale, yScale); }
  76. virtual void SetColor( color32 c ){ m_Geometry.m_Color = c; }
  77. protected:
  78. int GetStateIndex( const char *pStateName );
  79. CUtlString m_pName;
  80. CGraphicGroup *m_pGroup;
  81. bool m_bCanAcceptInput;
  82. CGeometry m_Geometry;
  83. CUtlVector< CAnimData * > m_Anims;
  84. int m_CurrentState;
  85. DmeTime_t m_flAnimTime;
  86. int32 m_iScriptHandle;
  87. };
  88. #endif // GAMEGRAPHIC_H