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.

186 lines
6.9 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Defines the interface that tools implement to allow views to call
  4. // through them.
  5. //
  6. //===========================================================================//
  7. #ifndef TOOLINTERFACE_H
  8. #define TOOLINTERFACE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. class CMapView2D;
  13. class CMapView3D;
  14. class CMapViewLogical;
  15. class CRender2D;
  16. class CRender3D;
  17. class CMapDoc;
  18. class CMapClass;
  19. class Vector2D;
  20. class CChunkFile;
  21. class CSaveInfo;
  22. #define HANDLE_RADIUS 4
  23. enum ChunkFileResult_t;
  24. enum ToolID_t
  25. {
  26. TOOL_NONE = -1,
  27. TOOL_POINTER,
  28. TOOL_BLOCK,
  29. TOOL_ENTITY,
  30. TOOL_CAMERA,
  31. TOOL_DECAL,
  32. TOOL_MAGNIFY,
  33. TOOL_MORPH,
  34. TOOL_CLIPPER,
  35. TOOL_EDITCORDON,
  36. TOOL_FACEEDIT_MATERIAL,
  37. TOOL_FACEEDIT_DISP,
  38. TOOL_OVERLAY,
  39. TOOL_AXIS_HANDLE,
  40. TOOL_POINT_HANDLE,
  41. TOOL_SPHERE,
  42. TOOL_PICK_FACE,
  43. TOOL_PICK_ENTITY,
  44. TOOL_PICK_ANGLES,
  45. TOOL_SWEPT_HULL,
  46. TOOL_PLAYERHULL_HANDLE,
  47. TOOL_ENTITY_SPRINKLE,
  48. };
  49. enum
  50. {
  51. constrainNone = 0x00, // transformation with no constrains
  52. constrainOnlyHorz = 0x01, // only horizontal translations
  53. constrainOnlyVert = 0x02, // only vertical translations
  54. constrainSnap = 0x04, // rounds to document snap grid
  55. constrainIntSnap = 0x08, // rounds value to one unit (integer)
  56. constrainHalfSnap = 0x10, // rounds to half of snap grid
  57. constrainCenter = 0x20,
  58. constrainMoveAll = 0x40, // translate all handles
  59. };
  60. class CBaseTool
  61. {
  62. public:
  63. inline CBaseTool();
  64. virtual ~CBaseTool() {}
  65. //
  66. // Called by the tool manager to activate/deactivate tools.
  67. //
  68. virtual void Init( CMapDoc *pDocument );
  69. void Activate();
  70. void Deactivate();
  71. virtual bool CanDeactivate( void ) { return true; }
  72. virtual bool IsTranslating(void) { return false; } // return true if tool is currently changing objects
  73. inline bool IsActiveTool( void ) { return m_bActiveTool; }
  74. // true if tool has objects to work on
  75. virtual bool IsEmpty() { return m_bEmpty; }
  76. // detach tool from any object working on
  77. virtual void SetEmpty() { m_bEmpty = true; }
  78. // attach a certain object to that tool
  79. virtual void Attach(CMapClass *pObject) {};
  80. //
  81. // Notifications for tool activation/deactivation.
  82. //
  83. virtual void OnActivate() {}
  84. virtual void OnDeactivate() {}
  85. virtual void RefreshToolState() {}
  86. virtual ToolID_t GetToolID(void) { return TOOL_NONE; }
  87. virtual const char* GetVMFChunkName() { return NULL; }
  88. virtual ChunkFileResult_t LoadVMF(CChunkFile *pFile) { return (ChunkFileResult_t)0; /*ChunkFile_Ok*/ }
  89. virtual ChunkFileResult_t SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo) { return (ChunkFileResult_t)0 ; /*ChunkFile_Ok*/ }
  90. //
  91. // Messages sent by the 3D view:
  92. //
  93. virtual bool OnContextMenu3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  94. virtual bool OnLMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  95. virtual bool OnLMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  96. virtual bool OnLMouseDblClk3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  97. virtual bool OnRMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  98. virtual bool OnRMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  99. virtual bool OnMouseMove3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  100. virtual bool OnMouseWheel3D( CMapView3D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  101. virtual bool OnKeyDown3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  102. virtual bool OnKeyUp3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  103. virtual bool OnChar3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  104. //
  105. // Messages sent by the 2D view:
  106. //
  107. virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  108. virtual bool OnLMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  109. virtual bool OnLMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  110. virtual bool OnLMouseDblClk2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  111. virtual bool OnRMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  112. virtual bool OnRMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  113. virtual bool OnMouseMove2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
  114. virtual bool OnMouseWheel2D( CMapView2D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  115. virtual bool OnKeyDown2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  116. virtual bool OnKeyUp2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  117. virtual bool OnChar2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  118. //
  119. // Messages sent by the logical view:
  120. //
  121. virtual bool OnContextMenuLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  122. virtual bool OnLMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  123. virtual bool OnLMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  124. virtual bool OnLMouseDblClkLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  125. virtual bool OnRMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  126. virtual bool OnRMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  127. virtual bool OnMouseMoveLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
  128. virtual bool OnMouseWheelLogical( CMapViewLogical *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  129. virtual bool OnKeyDownLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  130. virtual bool OnKeyUpLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  131. virtual bool OnCharLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  132. //
  133. // Rendering.
  134. //
  135. virtual void RenderTool2D( CRender2D *pRender ) {}
  136. virtual void RenderToolLogical( CRender2D *pRender ) {}
  137. virtual void RenderTool3D( CRender3D *pRender ) {}
  138. virtual void UpdateStatusBar( void ) {}
  139. protected:
  140. bool m_bActiveTool; // Set to true when this is the active tool.
  141. bool m_bEmpty; // true if the tool has objects to work on
  142. CMapDoc *m_pDocument;
  143. };
  144. //-----------------------------------------------------------------------------
  145. // Purpose: Constructor.
  146. //-----------------------------------------------------------------------------
  147. CBaseTool::CBaseTool()
  148. {
  149. m_bEmpty = true;
  150. m_bActiveTool = false;
  151. m_pDocument = NULL;
  152. }
  153. #endif // TOOLINTERFACE_H