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.

216 lines
6.9 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef GAMEUISYSTEMMANAGER_H
  8. #define GAMEUISYSTEMMANAGER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlvector.h"
  13. #include "tier1/timeutils.h"
  14. #include "rendersystem/vertexdata.h"
  15. #include "rendersystem/indexdata.h"
  16. #include "inputsystem/buttoncode.h"
  17. #include "gameuischeme.h"
  18. #include "igameuisystemmgr.h"
  19. #include "appframework/iappsystem.h"
  20. #include "tier3/tier3dm.h"
  21. #include "tier1/utlstring.h"
  22. #include "tier1/utlmap.h"
  23. #include "gameuidynamictextures.h"
  24. //-----------------------------------------------------------------------------
  25. // Forward declarations
  26. //-----------------------------------------------------------------------------
  27. class IGameUIScreenController;
  28. class IRenderContext;
  29. class CGameUISystem;
  30. class CGameGraphic;
  31. class CHitArea;
  32. class CGameText;
  33. class CGameUIDefinition;
  34. FORWARD_DECLARE_HANDLE( InputContextHandle_t );
  35. //-----------------------------------------------------------------------------
  36. // Global interfaces...
  37. //-----------------------------------------------------------------------------
  38. class IScriptManager;
  39. extern IScriptManager *g_pScriptManager;
  40. abstract_class IGameUIGraphicClassFactory
  41. {
  42. public:
  43. // Returns an instance of a graphic interface (keyvalues owned by caller)
  44. virtual CGameGraphic * CreateNewGraphicClass( KeyValues *kvRequest, CGameUIDefinition *pMenu ) = 0;
  45. };
  46. //-----------------------------------------------------------------------------
  47. //
  48. // Game UI system manager
  49. //
  50. //-----------------------------------------------------------------------------
  51. class CGameUISystemMgr : public CTier3AppSystem< IGameUISystemMgr >
  52. {
  53. typedef CTier3AppSystem< IGameUISystemMgr > BaseClass;
  54. public:
  55. // Constructor, destructor
  56. CGameUISystemMgr();
  57. virtual ~CGameUISystemMgr();
  58. virtual bool Connect( CreateInterfaceFn factory );
  59. virtual void Disconnect();
  60. virtual const AppSystemInfo_t* GetDependencies();
  61. virtual void *QueryInterface( const char *pInterfaceName );
  62. virtual InitReturnVal_t Init( );
  63. virtual void Shutdown();
  64. virtual void SetGameUIVisible( bool bVisible );
  65. virtual bool GetGameUIVisible(){ return IsMenuVisible(); }
  66. // Load the game UI menu screen
  67. // key values are owned and released by caller
  68. virtual IGameUISystem * LoadGameUIScreen( KeyValues *kvScreenLoadSettings );
  69. virtual void ReleaseAllGameUIScreens();
  70. virtual void RunFrame();
  71. virtual void RegisterScreenControllerFactory( char const *szControllerName, IGameUIScreenControllerFactory *pFactory );
  72. virtual IGameUIScreenControllerFactory * GetScreenControllerFactory( char const *szControllerName );
  73. virtual IGameUISystemSurface * GetSurface();
  74. virtual IGameUISchemeMgr * GetSchemeMgr();
  75. virtual IGameUIMiscUtils * GetMiscUtils();
  76. virtual void Render( const Rect_t &viewport, DmeTime_t flCurrentTime );
  77. virtual void Render( IRenderContext *pRenderContext, PlatWindow_t hWnd, const Rect_t &viewport, DmeTime_t flCurrentTime );
  78. virtual void UseGameInputSystemEventQueue( bool bEnable );
  79. virtual void RegisterInputEvent( const InputEvent_t &iEvent );
  80. virtual void SendEventToAllScreens( KeyValues *kvGlobalEvent );
  81. virtual void PostEventToAllScreens( KeyValues *kvGlobalEvent );
  82. virtual void SetSoundPlayback( IGameUISoundPlayback *pPlayback );
  83. virtual bool IsMenuVisible() const;
  84. virtual void SetInputContext( InputContextHandle_t hInputContext );
  85. CHitArea *GetMouseFocus();
  86. CHitArea *GetMouseFocus( int x, int y );
  87. CHitArea *GetKeyFocus();
  88. CHitArea *GetRequestedKeyFocus();
  89. void RequestKeyFocus( CHitArea *pGraphic, KeyValues *args = NULL );
  90. void GetScreenHeightForFontLoading( int &nTall );
  91. void SetScheme( IGameUIScheme * scheme );
  92. IGameUIScheme * GetCurrentScheme();
  93. DmeTime_t GetTime();
  94. // Render system stuff
  95. RenderInputLayout_t m_hInputLayout;
  96. RenderShaderHandle_t m_hVertexShader;
  97. RenderShaderHandle_t m_hPixelShader;
  98. ConstantBufferHandle_t m_hConstBuffer;
  99. void OnMouseFocusGained( CHitArea *mouseFocus );
  100. void OnMouseFocusLost( CHitArea *mouseFocus );
  101. bool OnKeyCodeTyped( const ButtonCode_t &code );
  102. bool OnKeyTyped( const wchar_t &unichar );
  103. bool OnGameGraphicScriptEvent( CGameGraphic *pGraphic, KeyValues *kvEvent );
  104. // Force focus to update on the next frame
  105. void ForceFocusUpdate(){ m_bForceFocusUpdate = true; }
  106. void PlayMenuSound( const char *pSoundFileName );
  107. void StopMenuSound( const char *pSoundFileName );
  108. void SetWindowSize( int nWidth, int nHeight );
  109. void GetWindowSize( int &nWidth, int &nHeight );
  110. void SetViewportSize( int nWidth, int nHeight );
  111. void GetViewportSize( int &nWidth, int &nHeight );
  112. // Returns the input context to use to control the cursor
  113. InputContextHandle_t GetInputContext( ) const;
  114. void OnScreenReleased( CGameUISystem *pScreen );
  115. // Dynamic texture management.
  116. void InitImageAlias( const char *pAlias );
  117. void LoadImageAliasTexture( const char *pAlias, const char *pBaseTextureName );
  118. void ReleaseImageAlias( const char *pAlias);
  119. IMaterial *GetImageAliasMaterial( const char *pAlias );
  120. ImageAliasData_t *GetImageAliasData( const char *pAlias );
  121. void TexCoordsToSheetTexCoords( const char *pAlias, Vector2D texCoords, Vector2D &sheetTexCoords );
  122. void DrawDynamicTexture( const char *pAlias, int x, int y );
  123. void ShowCursorCoords();
  124. void ShowGraphicName();
  125. virtual void RegisterGraphicClassFactory( char const *szGraphicClassName, IGameUIGraphicClassFactory *pFactory );
  126. virtual IGameUIGraphicClassFactory *GetGraphicClassFactory( char const *szGraphicClassName );
  127. virtual void InitRenderTargets();
  128. virtual IMaterialProxy *CreateProxy( const char *proxyName );
  129. private:
  130. void GetScreenSize( int &nWide, int &nTall );
  131. Vector2D CursorToStage( Vector2D cursorPos );
  132. // We may wind up with multiple viewports and multiple lists?
  133. Rect_t m_Viewport;
  134. int m_nWindowWidth, m_nWindowHeight;
  135. CUtlVector< CGameUISystem * > m_ActiveMenuList;
  136. CUtlVector< CGameUISystem * > m_ReleasedMenuList;
  137. DmeTime_t m_flCurrentTime;
  138. IGameUIScheme *m_Scheme;
  139. CHitArea *m_RequestedKeyFocus;
  140. bool m_bForceFocusUpdate;
  141. bool m_bUseGameInputQueue;
  142. InputContextHandle_t m_hInputContext;
  143. IGameUISoundPlayback *m_pSoundPlayback;
  144. CUtlVector< InputEvent_t > m_InputQueue;
  145. CUtlVector< KeyValues * > m_GameUIEventMainQueue;
  146. CUtlVector< CUtlString > m_MenuFileNames;
  147. CUtlMap< CUtlString, void * > m_MenuSoundMap;
  148. typedef CUtlMap< CUtlString, IGameUIScreenControllerFactory * > ScreenControllerFactoryMap;
  149. ScreenControllerFactoryMap m_ScreenControllerMap;
  150. typedef CUtlMap< CUtlString, IGameUIGraphicClassFactory * > GameUIGraphicClassFactoryMap;
  151. GameUIGraphicClassFactoryMap m_GraphicClassMap;
  152. bool m_bVisible;
  153. bool m_bSetReleaseTimer;
  154. DmeTime_t m_ReleaseStartTime;
  155. DmeTime_t m_ReleaseTime;
  156. CGameText *m_pCursorText;
  157. };
  158. extern CGameUISystemMgr *g_pGameUISystemMgrImpl;
  159. bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs );
  160. #endif // GAMEUISYSTEMMANAGER_H