Team Fortress 2 Source Code as on 22/4/2020
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.

95 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: The main manager of the UI
  4. //
  5. // $Revision: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #ifndef UIMANAGER_H
  9. #define UIMANAGER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "gamemanager.h"
  14. #include "vgui/vgui.h"
  15. #include "tier1/convar.h"
  16. #include "vgui_controls/panel.h"
  17. #include "vgui_controls/phandle.h"
  18. //-----------------------------------------------------------------------------
  19. // Forward declarations
  20. //-----------------------------------------------------------------------------
  21. struct InputEvent_t;
  22. class CLegionConsoleDialog;
  23. namespace vgui
  24. {
  25. class Panel;
  26. }
  27. //-----------------------------------------------------------------------------
  28. // Enum indicating the various main UI panels
  29. // NOTE: The order in which they appear here is the order in which they will draw
  30. //-----------------------------------------------------------------------------
  31. enum UIRootPanel_t
  32. {
  33. UI_ROOT_GAME = 0,
  34. UI_ROOT_MENU,
  35. UI_ROOT_TOOLS,
  36. UI_ROOT_PANEL_COUNT,
  37. };
  38. //-----------------------------------------------------------------------------
  39. // UI management
  40. //-----------------------------------------------------------------------------
  41. class CUIManager : public CGameManager<>
  42. {
  43. public:
  44. CUIManager();
  45. // Inherited from IGameManager
  46. virtual bool Init();
  47. virtual void Update( );
  48. virtual void Shutdown();
  49. // Root panels
  50. vgui::Panel *GetRootPanel( UIRootPanel_t id );
  51. // Sets particular root panels to be visible
  52. void EnablePanel( UIRootPanel_t id, bool bEnable );
  53. // Attempt to process an input event, return true if it sholdn't be chained to the rest of the game
  54. bool ProcessInputEvent( const InputEvent_t& event );
  55. // Draws the UI
  56. void DrawUI();
  57. // Hides the console
  58. void HideConsole();
  59. private:
  60. CON_COMMAND_MEMBER_F( CUIManager, "toggleconsole", ToggleConsole, "Toggle Console", 0 );
  61. vgui::VPANEL m_hEmbeddedPanel;
  62. vgui::Panel *m_pRootPanels[ UI_ROOT_PANEL_COUNT ];
  63. int m_nWindowWidth;
  64. int m_nWindowHeight;
  65. vgui::DHANDLE< CLegionConsoleDialog > m_hConsole;
  66. };
  67. //-----------------------------------------------------------------------------
  68. // Singleton accessor
  69. //-----------------------------------------------------------------------------
  70. extern CUIManager *g_pUIManager;
  71. #endif // UIMANAGER_H