guiNavEditorCtrl.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2014 Daniel Buckmaster
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUINAVEDITORCTRL_H_
  23. #define _GUINAVEDITORCTRL_H_
  24. #ifndef _EDITTSCTRL_H_
  25. #include "gui/worldEditor/editTSCtrl.h"
  26. #endif
  27. #ifndef _UNDO_H_
  28. #include "util/undo.h"
  29. #endif
  30. #ifndef _GIZMO_H_
  31. #include "gui/worldEditor/gizmo.h"
  32. #endif
  33. #include "navMesh.h"
  34. #include "T3D/aiPlayer.h"
  35. struct ObjectRenderInst;
  36. class SceneManager;
  37. class SceneRenderState;
  38. class BaseMatInstance;
  39. class GuiNavEditorCtrl : public EditTSCtrl
  40. {
  41. typedef EditTSCtrl Parent;
  42. friend class GuiNavEditorUndoAction;
  43. public:
  44. static const String mSelectMode;
  45. static const String mLinkMode;
  46. static const String mCoverMode;
  47. static const String mTileMode;
  48. static const String mTestMode;
  49. GuiNavEditorCtrl();
  50. ~GuiNavEditorCtrl();
  51. DECLARE_CONOBJECT(GuiNavEditorCtrl);
  52. /// @name SimObject
  53. /// @{
  54. bool onAdd();
  55. static void initPersistFields();
  56. /// @}
  57. /// @name GuiControl
  58. /// @{
  59. virtual void onSleep();
  60. virtual void onRender(Point2I offset, const RectI &updateRect);
  61. /// @}
  62. /// @name EditTSCtrl
  63. /// @{
  64. void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_);
  65. bool get3DCentre(Point3F &pos);
  66. void on3DMouseDown(const Gui3DMouseEvent & event);
  67. void on3DMouseUp(const Gui3DMouseEvent & event);
  68. void on3DMouseMove(const Gui3DMouseEvent & event);
  69. void on3DMouseDragged(const Gui3DMouseEvent & event);
  70. void on3DMouseEnter(const Gui3DMouseEvent & event);
  71. void on3DMouseLeave(const Gui3DMouseEvent & event);
  72. void updateGuiInfo();
  73. void renderScene(const RectI & updateRect);
  74. /// @}
  75. /// @name GuiNavEditorCtrl
  76. /// @{
  77. bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
  78. void setMode(String mode, bool sourceShortcut);
  79. String getMode() { return mMode; }
  80. void selectMesh(NavMesh *mesh);
  81. void deselect();
  82. S32 getMeshId();
  83. S32 getPlayerId();
  84. String mSpawnClass;
  85. String mSpawnDatablock;
  86. void deleteLink();
  87. void setLinkFlags(const LinkData &d);
  88. void buildTile();
  89. void spawnPlayer(const Point3F &pos);
  90. /// @}
  91. protected:
  92. void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
  93. void submitUndo(const UTF8 *name = "Action");
  94. GFXStateBlockRef mZDisableSB;
  95. GFXStateBlockRef mZEnableSB;
  96. bool mSavedDrag;
  97. bool mIsDirty;
  98. String mMode;
  99. /// Currently-selected NavMesh.
  100. SimObjectPtr<NavMesh> mMesh;
  101. /// @name Link mode
  102. /// @{
  103. Point3F mLinkStart;
  104. S32 mCurLink;
  105. S32 mLink;
  106. /// @}
  107. /// @name Tile mode
  108. /// @{
  109. S32 mCurTile;
  110. S32 mTile;
  111. duDebugDrawTorque dd;
  112. /// @}
  113. /// @name Test mode
  114. /// @{
  115. SimObjectPtr<AIPlayer> mPlayer;
  116. SimObjectPtr<AIPlayer> mCurPlayer;
  117. /// @}
  118. Gui3DMouseEvent mLastMouseEvent;
  119. #define InvalidMousePoint Point2I(-100,-100)
  120. Point2I mStartDragMousePoint;
  121. };
  122. class GuiNavEditorUndoAction : public UndoAction
  123. {
  124. public:
  125. GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName)
  126. {
  127. }
  128. GuiNavEditorCtrl *mNavEditor;
  129. SimObjectId mObjId;
  130. F32 mMetersPerSegment;
  131. U32 mSegmentsPerBatch;
  132. virtual void undo();
  133. virtual void redo() { undo(); }
  134. };
  135. #endif