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.

145 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef VGUI_BASEBUDGETPANEL_H
  7. #define VGUI_BASEBUDGETPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/Frame.h>
  12. #include <vgui/IScheme.h>
  13. #include "vgui_budgethistorypanel.h"
  14. #include "vgui_budgetbargraphpanel.h"
  15. #include "utlsymbol.h"
  16. //#include "hudelement.h"
  17. #define BUDGET_HISTORY_COUNT 1024
  18. class CBudgetGroupInfo
  19. {
  20. public:
  21. CUtlSymbol m_Name;
  22. Color m_Color;
  23. };
  24. // Derived classes supply this configuration data with OnConfigDataChanged.
  25. class CBudgetPanelConfigData
  26. {
  27. public:
  28. // NOTE: nothing can ever be removed from this list once you've called
  29. // OnConfigDataChanged. Elements can only be added to it.
  30. CUtlVector<CBudgetGroupInfo> m_BudgetGroupInfo;
  31. float m_flHistoryRange;
  32. float m_flBottomOfHistoryFraction;
  33. CUtlVector<float> m_HistoryLabelValues; // A label will be placed at each of these values.
  34. // How much range the bar graph represents.
  35. float m_flBarGraphRange;
  36. // Controls how many labels are shown.
  37. float m_flTimeLabelInterval;
  38. int m_nLinesPerTimeLabel; // How many vertical lines per time label?
  39. // How translucent is the background.
  40. float m_flBackgroundAlpha;
  41. // Where to position it on the screen.
  42. int m_xCoord;
  43. int m_yCoord;
  44. int m_Width;
  45. int m_Height;
  46. };
  47. class CBaseBudgetPanel : public vgui::Panel
  48. {
  49. typedef vgui::Panel BaseClass;
  50. public:
  51. CBaseBudgetPanel( vgui::Panel *pParent, const char *pElementName );
  52. ~CBaseBudgetPanel();
  53. // This should be called when starting up and whenever this data changes.
  54. void OnConfigDataChanged( const CBudgetPanelConfigData &data );
  55. // Call this to reset everything.
  56. virtual void ResetAll();
  57. // The derived class should implement this and set the text in the time labels.
  58. virtual void SetTimeLabelText() {}
  59. virtual void SetHistoryLabelText() {}
  60. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  61. virtual void Paint();
  62. virtual void PaintBackground();
  63. virtual void PerformLayout();
  64. void MarkAsDedicatedServer() { m_bDedicated = true; } // plays nicer as part of a vgui window setup
  65. bool IsDedicated() const { return m_bDedicated; }
  66. const double *GetBudgetGroupData( int &nGroups, int &nSamplesPerGroup, int &nSampleOffset ) const;
  67. void GetGraphLabelScreenSpaceTopAndBottom( int id, int &top, int &bottom );
  68. // What percentage is the specified value of the (bargraph) range?
  69. float GetBudgetGroupPercent( float value );
  70. // Get the current config data.
  71. const CBudgetPanelConfigData& GetConfigData() const;
  72. // Returns the number of budget groups in the last OnConfigDataChanged call.
  73. int GetNumCachedBudgetGroups() const;
  74. // (Used by dedicated server, mark everything for a repaint).
  75. void MarkForFullRepaint();
  76. protected:
  77. void UpdateWindowGeometry();
  78. void ClearTimesForAllGroupsForThisFrame( void );
  79. void ClearAllTimesForGroup( int groupID );
  80. void Rebuild( const CBudgetPanelConfigData &data );
  81. protected:
  82. int m_BudgetHistoryOffset;
  83. // This defines all the positioning, label names, etc.
  84. CBudgetPanelConfigData m_ConfigData;
  85. CUtlVector<vgui::Label *> m_GraphLabels;
  86. CUtlVector<vgui::Label *> m_TimeLabels;
  87. CUtlVector<vgui::Label *> m_HistoryLabels;
  88. CBudgetHistoryPanel *m_pBudgetHistoryPanel;
  89. CBudgetBarGraphPanel *m_pBudgetBarGraphPanel;
  90. struct BudgetGroupTimeData_t
  91. {
  92. double m_Time[BUDGET_HISTORY_COUNT];
  93. };
  94. CUtlVector<BudgetGroupTimeData_t> m_BudgetGroupTimes; // [m_CachedNumBudgetGroups][BUDGET_HISTORY_COUNT]
  95. int m_CachedNumTimeLabels;
  96. vgui::HFont m_hFont;
  97. bool m_bDedicated;
  98. };
  99. inline const CBudgetPanelConfigData& CBaseBudgetPanel::GetConfigData() const
  100. {
  101. return m_ConfigData;
  102. }
  103. inline int CBaseBudgetPanel::GetNumCachedBudgetGroups() const
  104. {
  105. return m_ConfigData.m_BudgetGroupInfo.Count();
  106. }
  107. #endif // VGUI_BASEBUDGETPANEL_H