Tool.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // Tool.h
  19. // Tool classes for worldbuilder.
  20. // Author: John Ahlquist, April 2001
  21. #pragma once
  22. #ifndef TOOL_H
  23. #define TOOL_H
  24. #include "Lib\BaseType.h"
  25. #include "Common/STLTypedefs.h"
  26. enum TTrackingMode {
  27. TRACK_NONE,
  28. TRACK_L,
  29. TRACK_M,
  30. TRACK_R
  31. };
  32. #include <vector>
  33. typedef std::vector<CPoint> VecHeightMapIndexes;
  34. #define MAGIC_GROUND_Z (0)
  35. //#define IS_MAGIC_GROUND(z) ((z)==MAGIC_GROUND_Z)
  36. // for backwards compatibility with existing maps:
  37. #define IS_MAGIC_GROUND(z) ((z)==0)
  38. class CWorldBuilderDoc;
  39. class CWorldBuilderView;
  40. class WorldHeightMapEdit;
  41. class WbView;
  42. /*************************************************************************
  43. ** Tool
  44. ***************************************************************************/
  45. class Tool
  46. {
  47. protected:
  48. Int m_toolID; //< Tool button ui id in resource.
  49. Int m_cursorID; //< Tool button ui id in resource.
  50. HCURSOR m_cursor;
  51. Int m_prevXIndex;
  52. Int m_prevYIndex;
  53. public:
  54. Tool(Int toolID, Int cursorID);
  55. virtual ~Tool(void);
  56. public:
  57. Int getToolID(void) {return m_toolID;}
  58. virtual void setCursor(void);
  59. virtual void activate(); ///< Become the current tool.
  60. virtual void deactivate(){}; ///< Become not the current tool.
  61. virtual Bool followsTerrain(void) {return true;}; ///< True if the tool tracks the terrain, generally false if it modifies the terrain heights.
  62. virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {}
  63. virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {}
  64. virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {}
  65. virtual WorldHeightMapEdit *getHeightMap(void) {return NULL;}
  66. static Real calcRoundBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth);
  67. static Real calcSquareBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth);
  68. static void getCenterIndex(Coord3D *docLocP, Int brushWidth, CPoint *center, CWorldBuilderDoc *pDoc);
  69. static void getAllIndexesIn(const Coord3D *bl, const Coord3D *br,
  70. const Coord3D *tl, const Coord3D *tr,
  71. Int widthOutside, CWorldBuilderDoc *pDoc,
  72. VecHeightMapIndexes* allIndices);
  73. };
  74. #endif //TOOL_H