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.

84 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DRAWING_PANEL_H
  8. #define DRAWING_PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Panel.h>
  13. #define DRAWN_LINE_SOLID_TIME 15.0f
  14. #define DRAWN_LINE_FADE_TIME 3.0f
  15. class MapLine
  16. {
  17. public:
  18. MapLine()
  19. {
  20. worldpos.Init( 0, 0 );
  21. linkpos.Init( 0, 0 );
  22. created_time = 0;
  23. bSetLinkBlipCentre = false;
  24. bSetBlipCentre = false;
  25. blipcentre.Init( 0, 0 );
  26. linkblipcentre.Init( 0, 0 );
  27. bLink = false;
  28. }
  29. Vector2D worldpos; // blip in world space
  30. Vector2D blipcentre; // blip in map texture space
  31. Vector2D linkpos; // link blip in world space
  32. Vector2D linkblipcentre; // link blip in map texture space
  33. bool bLink;
  34. bool bSetBlipCentre; // have we calculated the blip in map texture space yet?
  35. bool bSetLinkBlipCentre; // have we calculated the link blip in map texture space yet?
  36. float created_time;
  37. };
  38. class CDrawingPanel : public vgui::Panel, public CGameEventListener
  39. {
  40. DECLARE_CLASS_SIMPLE( CDrawingPanel, vgui::Panel );
  41. public:
  42. CDrawingPanel( Panel *parent, const char *name );
  43. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  44. void SendMapLine( int x, int y, bool bInitial );
  45. virtual void OnMouseReleased( vgui::MouseCode code );
  46. virtual void OnMousePressed( vgui::MouseCode code );
  47. virtual void OnCursorExited();
  48. virtual void OnCursorMoved( int x, int y );
  49. virtual void Paint();
  50. virtual void OnThink();
  51. virtual void SetVisible( bool bState ) OVERRIDE;
  52. void ClearLines( int iIndex );
  53. void ClearAllLines();
  54. const CUtlVector<MapLine>& GetLines( int iIndex ) const { return m_vecDrawnLines[iIndex]; }
  55. void SetType( int iPanelType ){ m_iPanelType = iPanelType; }
  56. virtual void FireGameEvent( IGameEvent *event );
  57. private:
  58. void ReadColor( const char* pszToken, Color& color );
  59. bool m_bDrawingLines;
  60. float m_fLastMapLine;
  61. int m_iMouseX, m_iMouseY;
  62. int m_nWhiteTexture;
  63. Color m_colorLine;
  64. CUtlVector<MapLine> m_vecDrawnLines[MAX_PLAYERS+1];
  65. int m_iPanelType;
  66. bool m_bTeamColors;
  67. };
  68. #endif // DRAWING_PANEL_H