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.

109 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ANALOGBAR_H
  8. #define ANALOGBAR_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui_controls/Panel.h>
  14. namespace vgui
  15. {
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Status bar that visually displays discrete analogValue in the form
  18. // of a segmented strip
  19. //-----------------------------------------------------------------------------
  20. class AnalogBar : public Panel
  21. {
  22. DECLARE_CLASS_SIMPLE( AnalogBar, Panel );
  23. public:
  24. AnalogBar(Panel *parent, const char *panelName);
  25. ~AnalogBar();
  26. // 'analogValue' is in the range [0.0f, 1.0f]
  27. MESSAGE_FUNC_FLOAT( SetAnalogValue, "SetAnalogValue", analogValue );
  28. float GetAnalogValue();
  29. virtual void SetSegmentInfo( int gap, int width );
  30. // utility function for calculating a time remaining string
  31. static bool ConstructTimeRemainingString(wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentAnalogValue, float lastAnalogValueUpdateTime, bool addRemainingSuffix);
  32. void SetBarInset( int pixels );
  33. int GetBarInset( void );
  34. virtual void ApplySettings(KeyValues *inResourceData);
  35. virtual void GetSettings(KeyValues *outResourceData);
  36. virtual const char *GetDescription();
  37. // returns the number of segment blocks drawn
  38. int GetDrawnSegmentCount();
  39. int GetTotalSegmentCount();
  40. enum AnalogValueDir_e
  41. {
  42. PROGRESS_EAST,
  43. PROGRESS_WEST,
  44. PROGRESS_NORTH,
  45. PROGRESS_SOUTH
  46. };
  47. int GetAnalogValueDirection() const { return m_iAnalogValueDirection; }
  48. void SetAnalogValueDirection( int val ) { m_iAnalogValueDirection = val; }
  49. void SetHomeValue( float val ) { m_fHomeValue = val; }
  50. const Color& GetHomeColor( void ) { return m_HomeColor; }
  51. void SetHomeColor( const Color &color ) { m_HomeColor = color; }
  52. protected:
  53. virtual void Paint();
  54. void PaintSegment( int &x, int &y, int tall, int wide, Color color, bool bHome );
  55. virtual void PaintBackground();
  56. virtual void ApplySchemeSettings(IScheme *pScheme);
  57. MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
  58. /* CUSTOM MESSAGE HANDLING
  59. "SetAnalogValue"
  60. input: "analogValue" - float value of the analogValue to set
  61. */
  62. protected:
  63. int m_iAnalogValueDirection;
  64. float _analogValue;
  65. private:
  66. int _segmentCount;
  67. int _segmentGap;
  68. int _segmentWide;
  69. int m_iBarInset;
  70. char *m_pszDialogVar;
  71. float m_fHomeValue;
  72. Color m_HomeColor;
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose: Non-segmented analogValue bar
  76. //-----------------------------------------------------------------------------
  77. class ContinuousAnalogBar : public AnalogBar
  78. {
  79. DECLARE_CLASS_SIMPLE( ContinuousAnalogBar, AnalogBar );
  80. public:
  81. ContinuousAnalogBar(Panel *parent, const char *panelName);
  82. virtual void Paint();
  83. };
  84. } // namespace vgui
  85. #endif // ANALOGBAR_H