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.

183 lines
6.8 KiB

  1. //========= Copyright 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. };
  48. enum
  49. {
  50. constrainNone = 0x00, // transformation with no constrains
  51. constrainOnlyHorz = 0x01, // only horizontal translations
  52. constrainOnlyVert = 0x02, // only vertical translations
  53. constrainSnap = 0x04, // rounds to document snap grid
  54. constrainIntSnap = 0x08, // rounds value to one unit (integer)
  55. constrainHalfSnap = 0x10, // rounds to half of snap grid
  56. constrainCenter = 0x20,
  57. constrainMoveAll = 0x40, // translate all handles
  58. };
  59. class CBaseTool
  60. {
  61. public:
  62. inline CBaseTool();
  63. virtual ~CBaseTool() {}
  64. //
  65. // Called by the tool manager to activate/deactivate tools.
  66. //
  67. virtual void Init( CMapDoc *pDocument );
  68. void Activate();
  69. void Deactivate();
  70. virtual bool CanDeactivate( void ) { return true; }
  71. virtual bool IsTranslating(void) { return false; } // return true if tool is currently changing objects
  72. inline bool IsActiveTool( void ) { return m_bActiveTool; }
  73. // true if tool has objects to work on
  74. virtual bool IsEmpty() { return m_bEmpty; }
  75. // detach tool from any object working on
  76. virtual void SetEmpty() { m_bEmpty = true; }
  77. // attach a certain object to that tool
  78. virtual void Attach(CMapClass *pObject) {};
  79. //
  80. // Notifications for tool activation/deactivation.
  81. //
  82. virtual void OnActivate() {}
  83. virtual void OnDeactivate() {}
  84. virtual ToolID_t GetToolID(void) { return TOOL_NONE; }
  85. virtual const char* GetVMFChunkName() { return NULL; }
  86. virtual ChunkFileResult_t LoadVMF(CChunkFile *pFile) { return (ChunkFileResult_t)0; /*ChunkFile_Ok*/ }
  87. virtual ChunkFileResult_t SaveVMF(CChunkFile *pFile, CSaveInfo *pSaveInfo) { return (ChunkFileResult_t)0 ; /*ChunkFile_Ok*/ }
  88. //
  89. // Messages sent by the 3D view:
  90. //
  91. virtual bool OnContextMenu3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  92. virtual bool OnLMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  93. virtual bool OnLMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  94. virtual bool OnLMouseDblClk3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  95. virtual bool OnRMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  96. virtual bool OnRMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  97. virtual bool OnMouseMove3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  98. virtual bool OnMouseWheel3D( CMapView3D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  99. virtual bool OnKeyDown3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  100. virtual bool OnKeyUp3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  101. virtual bool OnChar3D( CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  102. //
  103. // Messages sent by the 2D view:
  104. //
  105. virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  106. virtual bool OnLMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  107. virtual bool OnLMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  108. virtual bool OnLMouseDblClk2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  109. virtual bool OnRMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  110. virtual bool OnRMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  111. virtual bool OnMouseMove2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
  112. virtual bool OnMouseWheel2D( CMapView2D *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  113. virtual bool OnKeyDown2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  114. virtual bool OnKeyUp2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  115. virtual bool OnChar2D( CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  116. //
  117. // Messages sent by the logical view:
  118. //
  119. virtual bool OnContextMenuLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint) { return false; }
  120. virtual bool OnLMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  121. virtual bool OnLMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  122. virtual bool OnLMouseDblClkLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  123. virtual bool OnRMouseDownLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  124. virtual bool OnRMouseUpLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return false; }
  125. virtual bool OnMouseMoveLogical( CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint ) { return true; }
  126. virtual bool OnMouseWheelLogical( CMapViewLogical *pView, UINT nFlags, short zDelta, const Vector2D &vPoint) { return false; }
  127. virtual bool OnKeyDownLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  128. virtual bool OnKeyUpLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  129. virtual bool OnCharLogical( CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags ) { return false; }
  130. //
  131. // Rendering.
  132. //
  133. virtual void RenderTool2D( CRender2D *pRender ) {}
  134. virtual void RenderToolLogical( CRender2D *pRender ) {}
  135. virtual void RenderTool3D( CRender3D *pRender ) {}
  136. virtual void UpdateStatusBar( void ) {}
  137. protected:
  138. bool m_bActiveTool; // Set to true when this is the active tool.
  139. bool m_bEmpty; // true if the tool has objects to work on
  140. CMapDoc *m_pDocument;
  141. };
  142. //-----------------------------------------------------------------------------
  143. // Purpose: Constructor.
  144. //-----------------------------------------------------------------------------
  145. CBaseTool::CBaseTool()
  146. {
  147. m_bEmpty = true;
  148. m_bActiveTool = false;
  149. m_pDocument = NULL;
  150. }
  151. #endif // TOOLINTERFACE_H