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.

103 lines
2.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef HITAREA_H
  8. #define HITAREA_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "gamegraphic.h"
  13. #include "dmxloader/dmxelement.h"
  14. #include "tier1/utlvector.h"
  15. #include "vstdlib/ieventsystem.h"
  16. //-----------------------------------------------------------------------------
  17. //
  18. //-----------------------------------------------------------------------------
  19. class CHitArea : public CGameGraphic
  20. {
  21. DECLARE_DMXELEMENT_UNPACK()
  22. public:
  23. CHitArea( const char *pName );
  24. virtual ~CHitArea();
  25. bool Unserialize( CDmxElement *pGraphic );
  26. // Update geometry and execute scripting.
  27. virtual void UpdateGeometry();
  28. virtual void UpdateRenderData( color32 parentColor, CUtlVector< RenderGeometryList_t > &renderGeometryLists, int firstListIndex );
  29. virtual bool HitTest( int x, int y );
  30. // Cursor events
  31. // AUTO_GAINMOUSEFOCUS
  32. void OnCursorEnter();
  33. // AUTO_LOSEMOUSEFOCUS
  34. void OnCursorExit();
  35. void OnCursorMove( const int &cursorX, const int &cursorY );
  36. // Mouse events
  37. // AUTO_MOUSELEFTDOWN
  38. // AUTO_MOUSERIGHTDOWN
  39. // AUTO_MOUSEMIDDLEDOWN
  40. void OnMouseDown( const ButtonCode_t &code );
  41. // AUTO_MOUSELEFTUP
  42. // AUTO_MOUSERIGHTUP
  43. // AUTO_MOUSEMIDDLEUP
  44. void OnMouseUp( const ButtonCode_t &code, bool bFireScripts = true );
  45. // AUTO_MOUSEDOUBLECLICK
  46. void OnMouseDoubleClick( const ButtonCode_t &code );
  47. void OnMouseWheel( const int &delta ){}
  48. // Keyboard events
  49. // AUTO_KEYDOWN
  50. void OnKeyDown( const ButtonCode_t &code );
  51. // AUTO_KEYUP
  52. void OnKeyUp( const ButtonCode_t &code );
  53. void OnKeyCodeTyped( const ButtonCode_t &code );
  54. void OnKeyTyped( const wchar_t &unichar );
  55. // AUTO_GAINKEYFOCUS
  56. void OnGainKeyFocus();
  57. // AUTO_LOSEKEYFOCUS
  58. void OnLoseKeyFocus();
  59. // Calls to scripting.
  60. void OnDragStartCallScriptEvent( const int &cursorX, const int &cursorY );
  61. void OnDragCallScriptEvent( const int &cursorX, const int &cursorY );
  62. void OnDragStopCallScriptEvent( const int &cursorX, const int &cursorY );
  63. virtual void SetVisible( bool bVisible );
  64. virtual bool IsHitArea() const { return true; }
  65. virtual KeyValues *HandleScriptCommand( KeyValues *args );
  66. private:
  67. CHitArea();
  68. CUtlVector< Vector2D > m_ScreenPositions;
  69. bool m_bDragEnabled;
  70. bool m_bCanStartDragging;
  71. bool m_IsDragging;
  72. int m_DragStartCursorPos[2];
  73. int m_DragCurrentCursorPos[2];
  74. CUtlString m_OnMouseLeftClickedScriptCommand;
  75. };
  76. #endif // HITAREA_H