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.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "cbase.h"
  8. #include "hud.h"
  9. #include "hudelement.h"
  10. #include "hud_macros.h"
  11. #include "c_tf_player.h"
  12. #include "iclientmode.h"
  13. #include "ienginevgui.h"
  14. #include <vgui/ILocalize.h>
  15. #include <vgui/ISurface.h>
  16. #include <vgui/IVGui.h>
  17. #include <vgui_controls/Label.h>
  18. #include <vgui_controls/EditablePanel.h>
  19. #include "tf_hud_training.h"
  20. #include "tf_hud_objectivestatus.h"
  21. // memdbgon must be the last include file in a .cpp file!!!
  22. #include "tier0/memdbgon.h"
  23. using namespace vgui;
  24. //-----------------------------------------------------------------------------
  25. // Purpose:
  26. //-----------------------------------------------------------------------------
  27. class CHudTrainingMsg : public CHudElement, public EditablePanel
  28. {
  29. DECLARE_CLASS_SIMPLE( CHudTrainingMsg, EditablePanel );
  30. public:
  31. CHudTrainingMsg( const char *pElementName );
  32. virtual void Init( void );
  33. virtual bool ShouldDraw( void );
  34. void MsgFunc_TrainingMsg( bf_read &msg );
  35. void MsgFunc_TrainingObjective( bf_read &msg );
  36. private:
  37. };
  38. DECLARE_HUDELEMENT( CHudTrainingMsg );
  39. DECLARE_HUD_MESSAGE( CHudTrainingMsg, TrainingMsg );
  40. DECLARE_HUD_MESSAGE( CHudTrainingMsg, TrainingObjective );
  41. //-----------------------------------------------------------------------------
  42. // Purpose:
  43. //-----------------------------------------------------------------------------
  44. CHudTrainingMsg::CHudTrainingMsg( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudTrainingMsg" )
  45. {
  46. Panel *pParent = g_pClientMode->GetViewport();
  47. SetParent( pParent );
  48. SetVisible( false );
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. //-----------------------------------------------------------------------------
  53. void CHudTrainingMsg::Init()
  54. {
  55. HOOK_HUD_MESSAGE( CHudTrainingMsg, TrainingMsg );
  56. HOOK_HUD_MESSAGE( CHudTrainingMsg, TrainingObjective );
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. //-----------------------------------------------------------------------------
  61. bool CHudTrainingMsg::ShouldDraw( void )
  62. {
  63. return false;
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose: Activates the hint display
  67. //-----------------------------------------------------------------------------
  68. void CHudTrainingMsg::MsgFunc_TrainingMsg( bf_read &msg )
  69. {
  70. if ( engine->IsPlayingDemo() )
  71. return;
  72. char szString[MAX_TRAINING_MSG_LENGTH];
  73. msg.ReadString( szString, MAX_TRAINING_MSG_LENGTH );
  74. CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
  75. if ( pStatus )
  76. {
  77. pStatus->SetTrainingText(szString);
  78. }
  79. }
  80. //-----------------------------------------------------------------------------
  81. // Purpose: Activates the hint display
  82. //-----------------------------------------------------------------------------
  83. void CHudTrainingMsg::MsgFunc_TrainingObjective( bf_read &msg )
  84. {
  85. if ( engine->IsPlayingDemo() )
  86. return;
  87. char szString[MAX_TRAINING_MSG_LENGTH];
  88. msg.ReadString( szString, MAX_TRAINING_MSG_LENGTH );
  89. CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
  90. if ( pStatus )
  91. {
  92. pStatus->SetTrainingObjective(szString);
  93. }
  94. }