123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2014 Daniel Buckmaster
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #ifndef _GUINAVEDITORCTRL_H_
- #define _GUINAVEDITORCTRL_H_
- #include "torqueConfig.h"
- #ifdef TORQUE_TOOLS
- #ifndef _EDITTSCTRL_H_
- #include "gui/worldEditor/editTSCtrl.h"
- #endif
- #ifndef _UNDO_H_
- #include "util/undo.h"
- #endif
- #ifndef _GIZMO_H_
- #include "gui/worldEditor/gizmo.h"
- #endif
- #include "navMesh.h"
- #include "T3D/aiPlayer.h"
- struct ObjectRenderInst;
- class SceneManager;
- class SceneRenderState;
- class BaseMatInstance;
- class GuiNavEditorCtrl : public EditTSCtrl
- {
- typedef EditTSCtrl Parent;
- friend class GuiNavEditorUndoAction;
- public:
- static const String mSelectMode;
- static const String mLinkMode;
- static const String mCoverMode;
- static const String mTileMode;
- static const String mTestMode;
- GuiNavEditorCtrl();
- ~GuiNavEditorCtrl();
- DECLARE_CONOBJECT(GuiNavEditorCtrl);
- /// @name SimObject
- /// @{
- bool onAdd();
- static void initPersistFields();
- /// @}
- /// @name GuiControl
- /// @{
- virtual void onSleep();
- virtual void onRender(Point2I offset, const RectI &updateRect);
- /// @}
- /// @name EditTSCtrl
- /// @{
- void get3DCursor(GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_);
- bool get3DCentre(Point3F &pos);
- void on3DMouseDown(const Gui3DMouseEvent & event);
- void on3DMouseUp(const Gui3DMouseEvent & event);
- void on3DMouseMove(const Gui3DMouseEvent & event);
- void on3DMouseDragged(const Gui3DMouseEvent & event);
- void on3DMouseEnter(const Gui3DMouseEvent & event);
- void on3DMouseLeave(const Gui3DMouseEvent & event);
- void updateGuiInfo();
- void renderScene(const RectI & updateRect);
- /// @}
- /// @name GuiNavEditorCtrl
- /// @{
- bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
- void setMode(String mode, bool sourceShortcut);
- String getMode() { return mMode; }
- void selectMesh(NavMesh *mesh);
- void deselect();
- S32 getMeshId();
- S32 getPlayerId();
- String mSpawnClass;
- String mSpawnDatablock;
- void deleteLink();
- void setLinkFlags(const LinkData &d);
- void buildTile();
- void spawnPlayer(const Point3F &pos);
- /// @}
- protected:
- void _prepRenderImage(SceneManager* sceneGraph, const SceneRenderState* sceneState);
- void submitUndo(const UTF8 *name = "Action");
- GFXStateBlockRef mZDisableSB;
- GFXStateBlockRef mZEnableSB;
- bool mIsDirty;
- String mMode;
- /// Currently-selected NavMesh.
- SimObjectPtr<NavMesh> mMesh;
- /// @name Link mode
- /// @{
- Point3F mLinkStart;
- S32 mCurLink;
- S32 mLink;
- /// @}
- /// @name Tile mode
- /// @{
- S32 mCurTile;
- S32 mTile;
- duDebugDrawTorque dd;
- /// @}
- /// @name Test mode
- /// @{
- SimObjectPtr<AIPlayer> mPlayer;
- SimObjectPtr<AIPlayer> mCurPlayer;
- /// @}
- Gui3DMouseEvent mLastMouseEvent;
- #define InvalidMousePoint Point2I(-100,-100)
- Point2I mStartDragMousePoint;
- };
- class GuiNavEditorUndoAction : public UndoAction
- {
- public:
- GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName), mNavEditor(NULL), mObjId(0)
- {
- }
- GuiNavEditorCtrl *mNavEditor;
- SimObjectId mObjId;
- virtual void undo();
- virtual void redo() { undo(); }
- };
- #endif
- #endif
|