guiNavEditorCtrl.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. #ifdef TORQUE_TOOLS
  25. #ifndef _EDITTSCTRL_H_
  26. #include "gui/worldEditor/editTSCtrl.h"
  27. #endif
  28. #ifndef _UNDO_H_
  29. #include "util/undo.h"
  30. #endif
  31. #ifndef _GIZMO_H_
  32. #include "gui/worldEditor/gizmo.h"
  33. #endif
  34. #include "navMesh.h"
  35. #include "T3D/aiPlayer.h"
  36. struct ObjectRenderInst;
  37. class SceneManager;
  38. class SceneRenderState;
  39. class BaseMatInstance;
  40. class GuiNavEditorCtrl : public EditTSCtrl
  41. {
  42. typedef EditTSCtrl Parent;
  43. friend class GuiNavEditorUndoAction;
  44. public:
  45. static const String mSelectMode;
  46. static const String mLinkMode;
  47. static const String mCoverMode;
  48. static const String mTileMode;
  49. static const String mTestMode;
  50. GuiNavEditorCtrl();
  51. ~GuiNavEditorCtrl();
  52. DECLARE_CONOBJECT(GuiNavEditorCtrl);
  53. /// @name SimObject
  54. /// @{
  55. bool onAdd();
  56. static void initPersistFields();
  57. /// @}
  58. /// @name GuiControl
  59. /// @{
  60. virtual void onSleep();
  61. virtual void onRender(Point2I offset, const RectI &updateRect);
  62. /// @}
  63. /// @name EditTSCtrl
  64. /// @{
  65. void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_);
  66. bool get3DCentre(Point3F &pos);
  67. void on3DMouseDown(const Gui3DMouseEvent & event);
  68. void on3DMouseUp(const Gui3DMouseEvent & event);
  69. void on3DMouseMove(const Gui3DMouseEvent & event);
  70. void on3DMouseDragged(const Gui3DMouseEvent & event);
  71. void on3DMouseEnter(const Gui3DMouseEvent & event);
  72. void on3DMouseLeave(const Gui3DMouseEvent & event);
  73. void updateGuiInfo();
  74. void renderScene(const RectI & updateRect);
  75. /// @}
  76. /// @name GuiNavEditorCtrl
  77. /// @{
  78. bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
  79. void setMode(String mode, bool sourceShortcut);
  80. String getMode() { return mMode; }
  81. void selectMesh(NavMesh *mesh);
  82. void deselect();
  83. S32 getMeshId();
  84. S32 getPlayerId();
  85. String mSpawnClass;
  86. String mSpawnDatablock;
  87. void deleteLink();
  88. void setLinkFlags(const LinkData &d);
  89. void buildTile();
  90. void spawnPlayer(const Point3F &pos);
  91. /// @}
  92. protected:
  93. void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
  94. void submitUndo(const UTF8 *name = "Action");
  95. GFXStateBlockRef mZDisableSB;
  96. GFXStateBlockRef mZEnableSB;
  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), mNavEditor(NULL), mObjId(0)
  126. {
  127. }
  128. GuiNavEditorCtrl *mNavEditor;
  129. SimObjectId mObjId;
  130. virtual void undo();
  131. virtual void redo() { undo(); }
  132. };
  133. #endif
  134. #endif