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.

163 lines
4.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BASEVIEWPORT_H
  8. #define BASEVIEWPORT_H
  9. // viewport interface for the rest of the dll
  10. #include "game/client/iviewport.h"
  11. #include <utlqueue.h> // a vector based queue template to manage our VGUI menu queue
  12. #include "vgui_controls/Frame.h"
  13. #include "vguitextwindow.h"
  14. #include "vgui/ISurface.h"
  15. #include "commandmenu.h"
  16. #include "igameevents.h"
  17. using namespace vgui;
  18. class IBaseFileSystem;
  19. class IGameUIFuncs;
  20. class IGameEventManager;
  21. //==============================================================================
  22. class CBaseViewport : public vgui::EditablePanel, public IViewPort, public CGameEventListener
  23. {
  24. DECLARE_CLASS_SIMPLE( CBaseViewport, vgui::EditablePanel );
  25. public:
  26. CBaseViewport();
  27. virtual ~CBaseViewport();
  28. virtual IViewPortPanel* CreatePanelByName(const char *szPanelName);
  29. virtual IViewPortPanel* FindPanelByName(const char *szPanelName);
  30. virtual IViewPortPanel* GetActivePanel( void );
  31. virtual void LevelInit( void );
  32. virtual void RemoveAllPanels( void);
  33. virtual void RecreatePanel( const char *szPanelName );
  34. virtual void ShowPanel( const char *pName, bool state, KeyValues *data, bool autoDeleteData );
  35. virtual void ShowPanel( const char *pName, bool state );
  36. virtual void ShowPanel( IViewPortPanel* pPanel, bool state );
  37. virtual bool AddNewPanel( IViewPortPanel* pPanel, char const *pchDebugName );
  38. virtual void CreateDefaultPanels( void );
  39. virtual void UpdateAllPanels( void );
  40. virtual void PostMessageToPanel( const char *pName, KeyValues *pKeyValues );
  41. virtual void Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 *pGameEventManager );
  42. virtual void SetParent(vgui::VPANEL parent);
  43. virtual void ReloadScheme(const char *fromFile);
  44. virtual void ActivateClientUI();
  45. virtual void HideClientUI();
  46. virtual bool AllowedToPrintText( void );
  47. void LoadHudLayout( void );
  48. virtual vgui::VPANEL GetSchemeSizingVPanel( void );
  49. virtual int GetViewPortScheme() { return m_pBackGround->GetScheme(); }
  50. virtual VPANEL GetViewPortPanel() { return m_pBackGround->GetVParent(); }
  51. virtual AnimationController *GetAnimationController() { return m_pAnimController; }
  52. virtual void ShowBackGround(bool bShow)
  53. {
  54. m_pBackGround->SetVisible( bShow );
  55. }
  56. virtual int GetDeathMessageStartHeight( void );
  57. // virtual void ChatInputPosition( int *x, int *y );
  58. public: // IGameEventListener:
  59. virtual void FireGameEvent( IGameEvent * event);
  60. protected:
  61. bool LoadHudAnimations( void );
  62. class CBackGroundPanel : public vgui::Frame
  63. {
  64. private:
  65. typedef vgui::Frame BaseClass;
  66. public:
  67. CBackGroundPanel( vgui::Panel *parent) : Frame( parent, "ViewPortBackGround" )
  68. {
  69. SetScheme("ClientScheme");
  70. SetTitleBarVisible( false );
  71. SetMoveable(false);
  72. SetSizeable(false);
  73. SetProportional(true);
  74. }
  75. private:
  76. virtual void ApplySchemeSettings(IScheme *pScheme)
  77. {
  78. BaseClass::ApplySchemeSettings(pScheme);
  79. SetBgColor(pScheme->GetColor("ViewportBG", Color( 0,0,0,0 ) ));
  80. }
  81. virtual void PerformLayout()
  82. {
  83. int w,h;
  84. GetHudSize(w, h);
  85. // fill the screen
  86. SetBounds(0,0,w,h);
  87. BaseClass::PerformLayout();
  88. }
  89. virtual void OnMousePressed(MouseCode code) { }// don't respond to mouse clicks
  90. virtual vgui::VPANEL IsWithinTraverse( int x, int y, bool traversePopups )
  91. {
  92. return NULL;
  93. }
  94. };
  95. protected:
  96. virtual void Paint();
  97. virtual void OnThink();
  98. virtual void OnScreenSizeChanged(int iOldWide, int iOldTall);
  99. void PostMessageToPanel( IViewPortPanel* pPanel, KeyValues *pKeyValues );
  100. void SetAsFullscreenViewportInterface( void );
  101. bool IsFullscreenViewport() const;
  102. protected:
  103. IGameUIFuncs* m_GameuiFuncs; // for key binding details
  104. IGameEventManager2* m_GameEventManager;
  105. CBackGroundPanel *m_pBackGround;
  106. CUtlDict<IViewPortPanel*,int> m_Panels;
  107. CUtlVector< IViewPortPanel* > m_UnorderedPanels;
  108. bool m_bHasParent; // Used to track if child windows have parents or not.
  109. bool m_bInitialized;
  110. bool m_bFullscreenViewport;
  111. IViewPortPanel *m_pActivePanel;
  112. #if !defined( CSTRIKE15 )
  113. IViewPortPanel *m_pLastActivePanel;
  114. #endif
  115. vgui::HCursor m_hCursorNone;
  116. vgui::AnimationController *m_pAnimController;
  117. int m_OldSize[2];
  118. private:
  119. virtual void InitViewportSingletons( void );
  120. };
  121. #endif // BASEVIEWPORT_H