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.

102 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_HUD_ANNOTATIONSPANEL_H
  7. #define TF_HUD_ANNOTATIONSPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/EditablePanel.h>
  12. #include <game/client/iviewport.h>
  13. #include <vgui/IScheme.h>
  14. #include "hud.h"
  15. #include "hudelement.h"
  16. #include "tf_imagepanel.h"
  17. #include "tf_hud_playerstatus.h"
  18. #include "vgui_avatarimage.h"
  19. #include "item_model_panel.h"
  20. using namespace vgui;
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. //-----------------------------------------------------------------------------
  24. class CTFAnnotationsPanelCallout : public EditablePanel
  25. {
  26. DECLARE_CLASS_SIMPLE( CTFAnnotationsPanelCallout, EditablePanel );
  27. public:
  28. CTFAnnotationsPanelCallout( Panel *parent, const char *name, int id, Vector &location, const char *text );
  29. ~CTFAnnotationsPanelCallout();
  30. virtual void ApplySettings( KeyValues *pInResourceData );
  31. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  32. virtual void PerformLayout( void );
  33. bool UpdateCallout();
  34. inline int GetAnnotationID(){ return m_ID; }
  35. inline void Touch();
  36. inline void SetLocation( const Vector &location ) { m_Location = location; }
  37. inline void SetFollowEntity( CBaseEntity *pFollowEntity ) { m_FollowEntity = pFollowEntity; }
  38. inline void SetVisibilityBitfield( int iVisibilityBitfield ) { m_iVisibilityBitfield = iVisibilityBitfield; }
  39. void SetShowDistance( bool bShowDistance );
  40. void SetLifetime( float flLifetime );
  41. void SetText( const char *text );
  42. void FadeAndRemove();
  43. private:
  44. int m_ID;
  45. Vector m_Location;
  46. CHandle< CBaseEntity > m_FollowEntity;
  47. Label *m_pAnnotationLabel;
  48. Label *m_pDistanceLabel;
  49. ImagePanel *m_pArrow;
  50. const char *m_Text;
  51. float m_DeathTime;
  52. float m_flLerpPercentage;
  53. int m_iVisibilityBitfield;
  54. bool m_bWasOffscreen;
  55. bool m_bShowDistance;
  56. Panel *m_pBackground;
  57. KeyValues *m_pArrowImages;
  58. float m_flAlpha[2];
  59. };
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. //-----------------------------------------------------------------------------
  63. class CTFAnnotationsPanel : public EditablePanel, public CHudElement
  64. {
  65. private:
  66. DECLARE_CLASS_SIMPLE( CTFAnnotationsPanel, EditablePanel );
  67. public:
  68. CTFAnnotationsPanel( const char *pElementName );
  69. virtual ~CTFAnnotationsPanel();
  70. virtual void Reset();
  71. virtual void Init();
  72. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  73. virtual void FireGameEvent( IGameEvent * event );
  74. void UpdateAnnotations( void );
  75. void AddAnnotation( IGameEvent * event );
  76. void HideAnnotation( int id );
  77. void RemoveAll();
  78. virtual bool ShouldDraw( void );
  79. void OnThink( void );
  80. protected:
  81. CTFAnnotationsPanelCallout *TestAndAddCallout( int id, Vector &origin, const char *text );
  82. private:
  83. bool m_bShouldBeVisible;
  84. CUtlVector<CTFAnnotationsPanelCallout*> m_pCalloutPanels;
  85. vgui::Panel *m_pFreezePanelBG;
  86. };
  87. #endif // TF_HUD_ANNOTATIONSPANEL_H