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.

106 lines
3.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ====
  2. //
  3. // Purpose: Defines the interface to the entity sprinkle tool.
  4. //
  5. //=============================================================================
  6. #ifndef __TOOL_SPRINKLE_H
  7. #define __TOOL_SPRINKLE_H
  8. #pragma once
  9. #include "ToolInterface.h"
  10. #include "Tool3D.h"
  11. class CRender2D;
  12. class CRender3D;
  13. class CEntitySprinkleDlg;
  14. class CToolEntitySprinkle : public Tool3D
  15. {
  16. public:
  17. CToolEntitySprinkle(void);
  18. ~CToolEntitySprinkle(void);
  19. inline void GetPos(Vector &vecPos);
  20. //
  21. // CBaseTool implementation.
  22. //
  23. virtual ToolID_t GetToolID(void) { return TOOL_ENTITY_SPRINKLE; }
  24. virtual void OnActivate();
  25. virtual void OnDeactivate();
  26. virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  27. virtual bool OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  28. virtual bool OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  29. virtual bool OnLMouseUp2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  30. virtual bool OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  31. virtual bool OnMouseMove3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  32. virtual bool OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  33. virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  34. virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  35. virtual bool OnRMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  36. virtual bool OnRMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  37. virtual void RenderTool2D(CRender2D *pRender);
  38. virtual void RenderTool3D(CRender3D *pRender);
  39. protected:
  40. //
  41. // Tool3D implementation.
  42. //
  43. virtual bool UpdateTranslation(const Vector &vUpdate, UINT flags);
  44. virtual void FinishTranslation(bool bSave);
  45. virtual int HitTest(CMapView *pView, const Vector2D &vPoint, bool bTestHandles = false);
  46. private:
  47. void DetermineKeysDown( );
  48. void OnEscape( );
  49. void RemoveMapObjects( Vector &vOrigin, KeyValues *pSprinkleType, int nMode, int nDensity, CUtlVector< CMapEntity * > *pRemovedLocations = NULL, CMapEntity *pTouchedEntity = NULL );
  50. void PopulateEntity( CMapEntity *pEntity, KeyValues *pFields );
  51. void CreateMapObject( Vector &vOrigin, KeyValues *pSprinkleType, int nMode, bool bRandomYaw, CMapEntity *pExisting = NULL );
  52. bool FindWorldMousePoint( CMapView3D *pView, const Vector2D &vPoint );
  53. bool FindWorldSpot( Vector &vOrigin );
  54. bool IsInSprinkle( KeyValues *pSprinkleType, const char *pszClassname );
  55. const char *FindField( KeyValues *pSprinkleType, const char *pszClassname, const char *pszFieldName );
  56. bool DoSizing( const Vector2D &vPoint );
  57. void CalcGridInfo( KeyValues *pSprinkleType, float &flGridXSize, float &flGridYSize, float &flXSize, float &flYSize, Vector &vCenter );
  58. void PerformSprinkle( bool bInitial );
  59. Vector m_vecPos; // Current position of the marker.
  60. CEntitySprinkleDlg *pSprinkleDlg;
  61. Vector2D m_vMousePoint;
  62. Vector m_vWorldMousePoint;
  63. Vector m_vLastDrawPoint;
  64. VMatrix m_LocalMatrix;
  65. VMatrix m_LocalMatrixNeg;
  66. CMapFace *m_pHitFace;
  67. bool m_bWorldValid;
  68. bool m_InSizingMode;
  69. bool m_InDrawMode;
  70. bool m_bCtrlDown;
  71. Vector2D m_StartSizingPoint;
  72. float m_BrushSize;
  73. float m_OrigBrushSize;
  74. KeyValues *m_pSprinkleInfo;
  75. };
  76. //-----------------------------------------------------------------------------
  77. // Purpose: Returns the current position of the marker.
  78. //-----------------------------------------------------------------------------
  79. inline void CToolEntitySprinkle::GetPos(Vector &vecPos)
  80. {
  81. vecPos = m_vecPos;
  82. }
  83. #endif // __TOOL_SPRINKLE_H