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.

126 lines
3.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMEUIDEFINITION_H
  8. #define GAMEUIDEFINITION_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "dmxloader/dmxelement.h"
  13. #include "gamegraphic.h"
  14. #include "gameuischeme.h"
  15. #include "tier1/utlobjectreference.h"
  16. #include "tier1/utldict.h"
  17. #include "gamestage.h"
  18. #include "tier1/UtlStringMap.h"
  19. class CGameLayer;
  20. class CGameUIScript;
  21. enum EScriptExecution;
  22. struct GameUIEvent_t;
  23. struct GameGraphicMap_t
  24. {
  25. DmObjectId_t m_Id;
  26. CGameGraphic *pGraphic;
  27. };
  28. //-----------------------------------------------------------------------------
  29. // A template describing how a gameUI will function
  30. // It loads CVguiCompiledDoc
  31. //-----------------------------------------------------------------------------
  32. class CGameUIDefinition
  33. {
  34. DECLARE_DMXELEMENT_UNPACK();
  35. DECLARE_REFERENCED_CLASS( CGameUIDefinition );
  36. public:
  37. explicit CGameUIDefinition( IGameUISystem *pGameUISystem = NULL );
  38. ~CGameUIDefinition();
  39. bool CreateDefault( const char *pName );
  40. void Shutdown();
  41. // Serialization, unserialization
  42. bool Unserialize( CDmxElement *pElement );
  43. void InitializeScripts();
  44. void CallInitFunction();
  45. // Scripts associated with the menu all live in a folder by that name.
  46. // The main script for a menu is the same name as the menu.
  47. const char *GetName() const { return m_pName; }
  48. int GetLayerCount();
  49. void InvalidateSheetSymbols();
  50. void UpdateGeometry();
  51. void UpdateRenderTransforms( const Rect_t &viewport );
  52. void GetRenderData( CUtlVector< LayerRenderLists_t > &renderLists );
  53. bool ExecuteScript( KeyValues *kvEvent, KeyValues **ppResult );
  54. void StartPlaying();
  55. void StopPlaying();
  56. void AdvanceState();
  57. void InitAnims();
  58. IGameUISystem * GetGameUISystem() { return m_pGameUISystem; }
  59. IGameUIScheme * GetScheme() { return m_hScheme; }
  60. CGameGraphic *GraphicExists( const char *pName ) const;
  61. CGameGraphic *FindGraphicByName( const char *pName ) const;
  62. bool AddGraphicToLayer( CGameGraphic *pGraphic, int nLayerType );
  63. bool RemoveGraphic( CGameGraphic *pGraphic );
  64. bool HasGraphic( CGameGraphic *pGraphic );
  65. CGameGraphic *GetGraphic( int x, int y );
  66. CHitArea *GetMouseFocus( int x, int y );
  67. CHitArea *GetNextFocus( CHitArea *pCurrentGraphic );
  68. virtual void SetVisible( bool bVisible );
  69. virtual bool GetVisible(){ return m_bVisible; }
  70. void UpdateAspectRatio( const Rect_t &viewport );
  71. void SetStageSize( int nWide, int nTall );
  72. void GetStageSize( Vector2D &stageSize );
  73. void GetMaintainAspectRatioStageSize( Vector2D &stageSize );
  74. bool CanAcceptInput() { return m_bVisible && m_bCanAcceptInput; }
  75. void SetAcceptInput( bool bAcceptInput ) { m_bCanAcceptInput = bAcceptInput; }
  76. bool IsMouseFocusEqualToKeyboardFocus(){ return bMouseFocusEqualsKeyboardFocus; }
  77. void BuildScopedGraphicName( CUtlString &name, CGameGraphic *pGraphic );
  78. CGameUIScript * GetScript() { return m_Scripts.Count() ? m_Scripts[0] : NULL; }
  79. private:
  80. bool UnserializeLayer( CDmxElement *pLayer, CUtlDict< CGameGraphic *, int > &unserializedGraphicMapping );
  81. void AddGraphic( CGameGraphic *pGraphic, int layerIndex );
  82. CUtlString m_pName;
  83. bool m_bVisible;
  84. bool m_bCanAcceptInput;
  85. CUtlVector< CGraphicGroup *> m_Groups;
  86. CUtlVector< CGameLayer *> m_Layers;
  87. CUtlVector< CGameUIScript * > m_Scripts;
  88. IGameUISystem *m_pGameUISystem;
  89. IGameUIScheme *m_hScheme;
  90. CGameStage *m_pGameStage;
  91. bool bMouseFocusEqualsKeyboardFocus;
  92. };
  93. #endif // GAMEUIDEFINITION_H