guiNavEditorCtrl.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. #include "torqueConfig.h"
  25. #ifdef TORQUE_TOOLS
  26. #ifndef _EDITTSCTRL_H_
  27. #include "gui/worldEditor/editTSCtrl.h"
  28. #endif
  29. #ifndef _UNDO_H_
  30. #include "util/undo.h"
  31. #endif
  32. #ifndef _GIZMO_H_
  33. #include "gui/worldEditor/gizmo.h"
  34. #endif
  35. #include "navMesh.h"
  36. #include "T3D/aiPlayer.h"
  37. struct ObjectRenderInst;
  38. class SceneManager;
  39. class SceneRenderState;
  40. class BaseMatInstance;
  41. class GuiNavEditorCtrl : public EditTSCtrl
  42. {
  43. typedef EditTSCtrl Parent;
  44. friend class GuiNavEditorUndoAction;
  45. public:
  46. static const String mSelectMode;
  47. static const String mLinkMode;
  48. static const String mCoverMode;
  49. static const String mTileMode;
  50. static const String mTestMode;
  51. GuiNavEditorCtrl();
  52. ~GuiNavEditorCtrl();
  53. DECLARE_CONOBJECT(GuiNavEditorCtrl);
  54. /// @name SimObject
  55. /// @{
  56. bool onAdd();
  57. static void initPersistFields();
  58. /// @}
  59. /// @name GuiControl
  60. /// @{
  61. virtual void onSleep();
  62. virtual void onRender(Point2I offset, const RectI &updateRect);
  63. /// @}
  64. /// @name EditTSCtrl
  65. /// @{
  66. void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_);
  67. bool get3DCentre(Point3F &pos);
  68. void on3DMouseDown(const Gui3DMouseEvent & event);
  69. void on3DMouseUp(const Gui3DMouseEvent & event);
  70. void on3DMouseMove(const Gui3DMouseEvent & event);
  71. void on3DMouseDragged(const Gui3DMouseEvent & event);
  72. void on3DMouseEnter(const Gui3DMouseEvent & event);
  73. void on3DMouseLeave(const Gui3DMouseEvent & event);
  74. void updateGuiInfo();
  75. void renderScene(const RectI & updateRect);
  76. /// @}
  77. /// @name GuiNavEditorCtrl
  78. /// @{
  79. bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
  80. void setMode(String mode, bool sourceShortcut);
  81. String getMode() { return mMode; }
  82. void selectMesh(NavMesh *mesh);
  83. void deselect();
  84. S32 getMeshId();
  85. S32 getPlayerId();
  86. String mSpawnClass;
  87. String mSpawnDatablock;
  88. void deleteLink();
  89. void setLinkFlags(const LinkData &d);
  90. void buildTile();
  91. void spawnPlayer(const Point3F &pos);
  92. /// @}
  93. protected:
  94. void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
  95. void submitUndo(const UTF8 *name = "Action");
  96. GFXStateBlockRef mZDisableSB;
  97. GFXStateBlockRef mZEnableSB;
  98. bool mIsDirty;
  99. String mMode;
  100. /// Currently-selected NavMesh.
  101. SimObjectPtr<NavMesh> mMesh;
  102. /// @name Link mode
  103. /// @{
  104. Point3F mLinkStart;
  105. S32 mCurLink;
  106. S32 mLink;
  107. /// @}
  108. /// @name Tile mode
  109. /// @{
  110. S32 mCurTile;
  111. S32 mTile;
  112. duDebugDrawTorque dd;
  113. /// @}
  114. /// @name Test mode
  115. /// @{
  116. SimObjectPtr<AIPlayer> mPlayer;
  117. SimObjectPtr<AIPlayer> mCurPlayer;
  118. /// @}
  119. Gui3DMouseEvent mLastMouseEvent;
  120. #define InvalidMousePoint Point2I(-100,-100)
  121. Point2I mStartDragMousePoint;
  122. };
  123. class GuiNavEditorUndoAction : public UndoAction
  124. {
  125. public:
  126. GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName), mNavEditor(NULL), mObjId(0)
  127. {
  128. }
  129. GuiNavEditorCtrl *mNavEditor;
  130. SimObjectId mObjId;
  131. virtual void undo();
  132. virtual void redo() { undo(); }
  133. };
  134. #endif
  135. #endif