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.

116 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMELAYER_H
  8. #define GAMELAYER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "igameuisystemmgr.h"
  13. #include "gamegraphic.h"
  14. #include "dmxloader/dmxelement.h"
  15. #include "materialsystem/materialsystemutil.h"
  16. #include "bitmap/psheet.h"
  17. #include "rendersystem/irenderdevice.h"
  18. #include "mathlib/vertexcolor.h"
  19. #include "resourcesystem/stronghandle.h"
  20. #include "tier1/utldict.h"
  21. #include "tier1/UtlStringMap.h"
  22. class IRenderContext;
  23. struct GameGraphicMap_t;
  24. class CGameGraphic;
  25. class GameUIDefinition;
  26. //-----------------------------------------------------------------------------
  27. // GameUI vertex format
  28. //-----------------------------------------------------------------------------
  29. struct GameUIVertex_t
  30. {
  31. Vector m_vecPosition;
  32. VertexColor_t m_color;
  33. Vector2D m_vecTexCoord;
  34. };
  35. //-----------------------------------------------------------------------------
  36. // A class that contains all of the rendering objects in a gameui layer
  37. //-----------------------------------------------------------------------------
  38. // There are currently 3 types of these, for static/dynamic/and font.
  39. class CGameLayer
  40. {
  41. DECLARE_DMXELEMENT_UNPACK()
  42. public:
  43. CGameLayer( SublayerTypes_t layerType = SUBLAYER_STATIC );
  44. ~CGameLayer();
  45. void Shutdown();
  46. bool Unserialize( CDmxElement *pLayer, CUtlDict< CGameGraphic *, int > &unserializedGraphicMapping );
  47. const char *GetName() const { return m_pName; }
  48. const SublayerTypes_t GetLayerType() { return m_LayerType; }
  49. void SetLayerType( SublayerTypes_t layerType ) { m_LayerType = layerType; }
  50. bool InitSheetTexture();
  51. bool InitSheetTexture( const char *pBaseTextureName );
  52. void GetSheetTextureSize( int &nWidth, int &nHeight );
  53. int AddGraphic( CGameGraphic *pGraphic );
  54. bool RemoveGraphic( CGameGraphic *pGraphic );
  55. void ClearGraphics();
  56. bool HasGraphic( CGameGraphic *pGraphic );
  57. CGameGraphic *FindGraphicByName( const char *pName );
  58. IMaterial *GetMaterial();
  59. HRenderTextureStrong GetTexture() { return m_hTexture; }
  60. // Sheet symbols (used to avoid string->symbol conversions)
  61. void InvalidateSheetSymbol();
  62. void CacheSheetSymbol( CUtlSymbol sheetSymbol );
  63. bool IsSheetSymbolCached() const { return m_bSheetSymbolCached; }
  64. CUtlSymbol GetSheetSymbol() const;
  65. void StartPlaying();
  66. void StopPlaying();
  67. void AdvanceState();
  68. void InitAnims();
  69. void UpdateGeometry();
  70. void UpdateRenderTransforms( const StageRenderInfo_t &stageRenderInfo );
  71. void UpdateRenderData( CGameUIDefinition &gameUIDef, color32 parentColor, CUtlVector< LayerRenderLists_t > &renderLists );
  72. CGameGraphic *GetGraphic( int x, int y );
  73. CGameGraphic *GetMouseFocus( int x, int y );
  74. CGameGraphic *GetNextFocus( bool &bGetNext, CGameGraphic *pCurrentGraphic );
  75. private:
  76. // Graphics in this layer
  77. CUtlVector< CGameGraphic * > m_LayerGraphics;
  78. CSheet *LoadSheet( IMaterial *pMaterial );
  79. CSheet *LoadSheet( char const *pszFname, ITexture *pTexture );
  80. CUtlString m_pName;
  81. SublayerTypes_t m_LayerType;
  82. CUtlString m_pTextureName;
  83. HRenderTextureStrong m_hTexture;
  84. CMaterialReference m_Material;
  85. CUtlReference< CSheet > m_Sheet;
  86. CUtlSymbol m_SheetSymbol;
  87. bool m_bSheetSymbolCached;
  88. };
  89. #endif // GAMELAYER_H