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.

113 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. //
  9. // Train.cpp
  10. //
  11. // implementation of CHudAmmo class
  12. //
  13. #include "cbase.h"
  14. #include "hudelement.h"
  15. #include "hud_macros.h"
  16. #include "iclientmode.h"
  17. #include <vgui_controls/Controls.h>
  18. #include <vgui_controls/Panel.h>
  19. #include <vgui/ISurface.h>
  20. // memdbgon must be the last include file in a .cpp file!!!
  21. #include "tier0/memdbgon.h"
  22. using namespace vgui;
  23. class CHudTrain: public CHudElement, public vgui::Panel
  24. {
  25. DECLARE_CLASS_SIMPLE( CHudTrain, vgui::Panel );
  26. public:
  27. CHudTrain( const char *pElementName );
  28. void Init( void );
  29. void VidInit( void );
  30. bool ShouldDraw( void );
  31. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  32. virtual void Paint( void );
  33. void MsgFunc_Train(bf_read &msg);
  34. private:
  35. int m_iPos;
  36. };
  37. //
  38. //-----------------------------------------------------
  39. //
  40. DECLARE_HUDELEMENT( CHudTrain );
  41. DECLARE_HUD_MESSAGE( CHudTrain, Train )
  42. //-----------------------------------------------------------------------------
  43. // Purpose:
  44. //-----------------------------------------------------------------------------
  45. CHudTrain::CHudTrain( const char *pElementName ) :
  46. CHudElement( pElementName ), BaseClass( NULL, "HudTrain" )
  47. {
  48. vgui::Panel *pParent = g_pClientMode->GetViewport();
  49. SetParent( pParent );
  50. SetHiddenBits( HIDEHUD_MISCSTATUS );
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. // Input : *scheme -
  55. //-----------------------------------------------------------------------------
  56. void CHudTrain::ApplySchemeSettings( IScheme *scheme )
  57. {
  58. BaseClass::ApplySchemeSettings( scheme );
  59. SetPaintBackgroundEnabled( false );
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. //-----------------------------------------------------------------------------
  64. void CHudTrain::Init(void)
  65. {
  66. HOOK_HUD_MESSAGE( CHudTrain, Train );
  67. m_iPos = 0;
  68. }
  69. //-----------------------------------------------------------------------------
  70. // Purpose:
  71. //-----------------------------------------------------------------------------
  72. void CHudTrain::VidInit(void)
  73. {
  74. }
  75. //-----------------------------------------------------------------------------
  76. // Purpose:
  77. //-----------------------------------------------------------------------------
  78. bool CHudTrain::ShouldDraw( void )
  79. {
  80. return ( CHudElement::ShouldDraw() && m_iPos );
  81. }
  82. //-----------------------------------------------------------------------------
  83. // Purpose:
  84. //-----------------------------------------------------------------------------
  85. void CHudTrain::Paint()
  86. {
  87. // FIXME: Rewrite using vgui materials if we still do this type of train UI!!!
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose:
  91. //-----------------------------------------------------------------------------
  92. void CHudTrain::MsgFunc_Train( bf_read &msg )
  93. {
  94. // update Train data
  95. m_iPos = msg.ReadByte();
  96. }