Ver código fonte

cleanup

add select tool
cleanup more from guinaveditorctrl and scripts
marauder2k7 1 mês atrás
pai
commit
24ec55e8bc

+ 2 - 28
Engine/source/navigation/guiNavEditorCtrl.cpp

@@ -38,6 +38,7 @@
 #include "gui/worldEditor/undoActions.h"
 #include "T3D/gameBase/gameConnection.h"
 #include "T3D/AI/AIController.h"
+#include "navigation/navMeshTool.h"
 
 IMPLEMENT_CONOBJECT(GuiNavEditorCtrl);
 
@@ -47,15 +48,8 @@ ConsoleDocClass(GuiNavEditorCtrl,
                 "@internal"
                 );
 
-// Each of the mode names directly correlates with the Nav Editor's tool palette.
-const String GuiNavEditorCtrl::mSelectMode = "SelectMode";
-const String GuiNavEditorCtrl::mLinkMode = "LinkMode";
-const String GuiNavEditorCtrl::mCoverMode = "CoverMode";
-const String GuiNavEditorCtrl::mTestMode = "TestMode";
-
 GuiNavEditorCtrl::GuiNavEditorCtrl()
 {
-   mMode = mSelectMode;
    mIsDirty = false;
    mStartDragMousePoint = InvalidMousePoint;
    mMesh = NULL;
@@ -101,8 +95,6 @@ void GuiNavEditorCtrl::initPersistFields()
 void GuiNavEditorCtrl::onSleep()
 {
    Parent::onSleep();
-
-   //mMode = mSelectMode;
 }
 
 void GuiNavEditorCtrl::selectMesh(NavMesh *mesh)
@@ -311,15 +303,6 @@ bool GuiNavEditorCtrl::getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos
    return hit;
 }
 
-void GuiNavEditorCtrl::setMode(String mode, bool sourceShortcut = false)
-{
-   mMode = mode;
-   Con::executef(this, "onModeSet", mode);
-
-   if(sourceShortcut)
-      Con::executef(this, "paletteSync", mode);
-}
-
 void GuiNavEditorCtrl::submitUndo(const UTF8 *name)
 {
    // Grab the mission editor undo manager.
@@ -361,6 +344,7 @@ void GuiNavEditorCtrl::setActiveTool(NavMeshTool* tool)
 
    if (mTool)
    {
+      mTool->setActiveEditor(this);
       mTool->setActiveNavMesh(mMesh);
       mTool->onActivated(mLastEvent);
    }
@@ -386,14 +370,4 @@ DefineEngineMethod(GuiNavEditorCtrl, setActiveTool, void, (const char* toolName)
    object->setActiveTool(tool);
 }
 
-
-DefineEngineMethod(GuiNavEditorCtrl, getMode, const char*, (), , "")
-{
-   return object->getMode();
-}
-
-DefineEngineMethod(GuiNavEditorCtrl, setMode, void, (String mode),, "setMode(String mode)")
-{
-   object->setMode(mode);
-}
 #endif

+ 4 - 8
Engine/source/navigation/guiNavEditorCtrl.h

@@ -34,9 +34,9 @@
 #include "gui/worldEditor/gizmo.h"
 #endif
 
-#ifndef _NAVMESH_TOOL_H_
-#include "navigation/navMeshTool.h"
-#endif
+//#ifndef _NAVMESH_TOOL_H_
+//#include "navigation/navMeshTool.h"
+//#endif
 
 #include "navMesh.h"
 #include "T3D/aiPlayer.h"
@@ -45,6 +45,7 @@ struct ObjectRenderInst;
 class SceneManager;
 class SceneRenderState;
 class BaseMatInstance;
+class NavMeshTool;
 
 class GuiNavEditorCtrl : public EditTSCtrl
 {
@@ -99,9 +100,6 @@ public:
 
    bool getStaticPos(const Gui3DMouseEvent & event, Point3F &tpos);
 
-   void setMode(String mode, bool sourceShortcut);
-   String getMode() { return mMode; }
-
    void selectMesh(NavMesh *mesh);
 
    S32 getMeshId();
@@ -122,8 +120,6 @@ protected:
 
    bool mIsDirty;
 
-   String mMode;
-
    /// Currently-selected NavMesh.
    SimObjectPtr<NavMesh> mMesh;
 

+ 7 - 0
Engine/source/navigation/navMeshTool.h

@@ -12,6 +12,10 @@
 #include "navigation/navMesh.h"
 #endif
 
+#ifndef _GUINAVEDITORCTRL_H_
+#include "navigation/guiNavEditorCtrl.h"
+#endif
+
 class UndoAction;
 
 class NavMeshTool : public SimObject
@@ -19,6 +23,8 @@ class NavMeshTool : public SimObject
    typedef SimObject Parent;
 protected:
    SimObjectPtr<NavMesh> mNavMesh;
+   SimObjectPtr<GuiNavEditorCtrl> mCurEditor;
+
    void _submitUndo(UndoAction* action);
 
 public:
@@ -29,6 +35,7 @@ public:
    DECLARE_CONOBJECT(NavMeshTool);
 
    virtual void setActiveNavMesh(NavMesh* nav_mesh) { mNavMesh = nav_mesh; }
+   virtual void setActiveEditor(GuiNavEditorCtrl* nav_editor) { mCurEditor = nav_editor; }
 
    virtual void onActivated(const Gui3DMouseEvent& lastEvent) {}
    virtual void onDeactivated() {}

+ 112 - 0
Engine/source/navigation/navMeshTools/navMeshSelectTool.cpp

@@ -0,0 +1,112 @@
+#include "navMeshSelectTool.h"
+#include "console/consoleTypes.h"
+#include "gfx/gfxDrawUtil.h"
+
+IMPLEMENT_CONOBJECT(NavMeshSelectTool);
+
+static void renderBoxOutline(const Box3F& box, const ColorI& col)
+{
+   if (box != Box3F::Invalid)
+   {
+      GFXStateBlockDesc desc;
+      desc.setCullMode(GFXCullNone);
+      desc.setFillModeSolid();
+      desc.setZReadWrite(true, false);
+      desc.setBlend(true);
+      GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 20));
+      desc.setFillModeWireframe();
+      desc.setBlend(false);
+      GFX->getDrawUtil()->drawCube(desc, box, ColorI(col, 255));
+   }
+}
+
+NavMeshSelectTool::NavMeshSelectTool()
+{
+   mCurMesh = NULL;
+}
+
+void NavMeshSelectTool::onActivated(const Gui3DMouseEvent& evt)
+{
+   Con::executef(this, "onActivated");
+}
+
+void NavMeshSelectTool::onDeactivated()
+{
+   Con::executef(this, "onDeactivated");
+}
+
+void NavMeshSelectTool::on3DMouseDown(const Gui3DMouseEvent& evt)
+{
+   if (mCurEditor.isNull())
+      return;
+
+   Point3F startPnt = evt.pos;
+   Point3F endPnt = evt.pos + evt.vec * 1000.0f;
+
+   RayInfo ri;
+   if (gServerContainer.castRay(startPnt, endPnt, MarkerObjectType, &ri))
+   {
+      if (!ri.object)
+         return;
+
+      NavMesh* selNavMesh = dynamic_cast<NavMesh*>(ri.object);
+      if (selNavMesh)
+      {
+         mCurEditor->selectMesh(selNavMesh);
+         return;
+      }
+   }
+
+}
+
+void NavMeshSelectTool::on3DMouseMove(const Gui3DMouseEvent& evt)
+{
+   if (mCurEditor.isNull())
+      return;
+
+   Point3F startPnt = evt.pos;
+   Point3F endPnt = evt.pos + evt.vec * 1000.0f;
+
+   RayInfo ri;
+   if (gServerContainer.castRay(startPnt, endPnt, MarkerObjectType, &ri))
+   {
+      NavMesh* selNavMesh = dynamic_cast<NavMesh*>(ri.object);
+      if (selNavMesh)
+      {
+         mCurMesh = selNavMesh;
+      }
+      else
+      {
+         mCurMesh = NULL;
+      }
+   }
+   else
+   {
+      mCurMesh = NULL;
+   }
+}
+
+void NavMeshSelectTool::onRender3D()
+{
+   if (!mCurMesh.isNull())
+      renderBoxOutline(mCurMesh->getWorldBox(), ColorI::LIGHT);
+}
+
+bool NavMeshSelectTool::updateGuiInfo()
+{
+   SimObject* statusbar;
+   Sim::findObject("EditorGuiStatusBar", statusbar);
+
+   GuiTextCtrl* selectionBar;
+   Sim::findObject("EWorldEditorStatusBarSelection", selectionBar);
+
+   String text;
+
+   if (statusbar)
+      Con::executef(statusbar, "setInfo", text.c_str());
+
+   if (selectionBar)
+      selectionBar->setText(text);
+
+   return true;
+}

+ 30 - 0
Engine/source/navigation/navMeshTools/navMeshSelectTool.h

@@ -0,0 +1,30 @@
+#ifndef _NAVMESHSELECTTOOL_H_
+#define _NAVMESHSELECTTOOL_H_
+
+
+#ifndef _NAVMESH_TOOL_H_
+#include "navigation/navMeshTool.h"
+#endif
+
+class NavMeshSelectTool : public NavMeshTool
+{
+   typedef NavMeshTool Parent;
+protected:
+   SimObjectPtr<NavMesh> mCurMesh;
+public:
+   DECLARE_CONOBJECT(NavMeshSelectTool);
+
+   NavMeshSelectTool();
+   virtual ~NavMeshSelectTool() {}
+
+   void onActivated(const Gui3DMouseEvent& evt) override;
+   void onDeactivated() override;
+
+   void on3DMouseDown(const Gui3DMouseEvent& evt) override;
+   void on3DMouseMove(const Gui3DMouseEvent& evt) override;
+   void onRender3D() override;
+
+   bool updateGuiInfo() override;
+};
+
+#endif

+ 3 - 0
Engine/source/navigation/navMeshTools/navMeshTestTool.cpp

@@ -367,6 +367,9 @@ bool NavMeshTestTool::updateGuiInfo()
    if (mSpawnClass != String::EmptyString && mSpawnDatablock != String::EmptyString)
       text += " CTRL+LMB To spawn a new Bot.";
 
+   if (mSelectFollow)
+      text = "LMB To select Follow Target.";
+
    if (statusbar)
       Con::executef(statusbar, "setInfo", text.c_str());
 

+ 21 - 65
Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui

@@ -491,8 +491,8 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
                   HorizSizing = "right";
                   VertSizing = "bottom";
                   Extent = "90 18";
-                  text = "Find cover";
-                  command = "NavMeshTools->TestTool.findCover();";
+                  text = "Stop";
+                  command = "NavMeshTools->TestTool.stop();";
                };
             };
             new GuiControl() {
@@ -515,8 +515,8 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
                   HorizSizing = "right";
                   VertSizing = "bottom";
                   Extent = "90 18";
-                  text = "Stop";
-                  command = "NavMeshTools->TestTool.stop();";
+                  text = "Find cover";
+                  command = "NavMeshTools->TestTool.findCover();";
                };
             };
             new GuiControl() {
@@ -532,6 +532,23 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
                   text = "Toggle Follow";
                   command = "NavMeshTools->TestTool.toggleFollow();";
                };
+
+               new GuiTextEditSliderCtrl(CoverRadius) {
+                  position = "100 0";
+                  extent = "90 18";
+                  format = "%3.2f";
+                  range = "0 1e+03";
+                  increment = "0.1";
+                  focusOnMouseWheel = "0";
+                  historySize = "0";
+                  password = "0";
+                  tabComplete = "0";
+                  sinkAllKeyEvents = "0";
+                  hovertime = "1000";
+                  profile = "ToolsGuiTextEditProfile";
+                  tooltipProfile = "GuiToolTipProfile";
+                  toolTip = "The radius to search for cover";
+               };
             };
          };
       };
@@ -815,67 +832,6 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
                variable = "$Nav::Editor::renderVoxels";
             };
          };
-         new GuiStackControl() {
-            internalName = "TestProperties";
-            position = "7 21";
-            extent = "186 64";
-            padding = "2 2 2 2";
-            
-			new GuiTextCtrl() {
-               text = "Cover";
-               profile = "ToolsGuiTextProfile";
-               extent = "180 20";
-               minExtent = "8 2";
-               visible = "1";
-            };
-            new GuiTextEditCtrl() {
-               internalName = "CoverRadius";
-               text = "10";
-               profile = "ToolsGuiTextEditProfile";
-               extent = "40 20";
-               minExtent = "8 2";
-               visible = "1";
-               tooltipProfile = "GuiToolTipProfile";
-               toolTip = "Radius for cover-finding.";
-            };
-            new GuiTextEditCtrl() {
-               internalName = "CoverPosition";
-               text = "LocalClientConnection.getControlObject().getPosition();";
-               profile = "ToolsGuiTextEditProfile";
-               extent = "140 20";
-               minExtent = "8 2";
-               visible = "1";
-               tooltipProfile = "GuiToolTipProfile";
-               toolTip = "Position to find cover from.";
-            };
-            new GuiTextCtrl() {
-               text = "Follow";
-               profile = "ToolsuiTextProfile";
-               extent = "180 20";
-               minExtent = "8 2";
-               visible = "1";
-            };
-            new GuiTextEditCtrl() {
-               internalName = "FollowRadius";
-               text = "1";
-               profile = "ToolsGuiTextEditProfile";
-               extent = "40 20";
-               minExtent = "8 2";
-               visible = "1";
-               tooltipProfile = "GuiToolTipProfile";
-               toolTip = "Radius for following.";
-            };
-            new GuiTextEditCtrl() {
-               internalName = "FollowObject";
-               text = "LocalClientConnection.player";
-               profile = "ToolsGuiTextEditProfile";
-               extent = "140 20";
-               minExtent = "8 2";
-               visible = "1";
-               tooltipProfile = "GuiToolTipProfile";
-               toolTip = "Object to follow.";
-            };
-         };
       };
       new GuiMLTextCtrl(NavFieldInfoControl) {
          canSaveDynamicFields = "0";

+ 26 - 5
Templates/BaseGame/game/tools/navEditor/main.tscript

@@ -59,6 +59,13 @@ function initializeNavEditor()
 
    new SimSet(NavMeshTools)
    {
+      new NavMeshSelectTool()
+      {
+         internalName = "SelectTool";
+         toolTip = "Edit NavMesh";
+         buttonImage = "ToolsModule:visibility_toggle_n_image";  
+      };
+
       new OffMeshConnectionTool()
       {
          internalName = "LinkTool";
@@ -143,12 +150,11 @@ function EditorGui::SetNavPalletBar()
    
    //Adds a button to the pallete stack
                                  //Name          Icon                                     Click Command                              Tooltip text              Keybind
-   EWToolsPaletteWindow.addButton("ViewNavMesh", "ToolsModule:visibility_toggle_n_image", "NavEditorGui.prepSelectionMode();", "",   "View NavMesh",           "1"); 
+   EWToolsPaletteWindow.addButton("EditMode", "ToolsModule:visibility_toggle_n_image", "NavEditorGui.setActiveTool(NavMeshTools->SelectTool);", "", "Edit NavMesh", "1"); 
    EWToolsPaletteWindow.addButton("LinkMode",    "ToolsModule:nav_link_n_image",          "NavEditorGui.setActiveTool(NavMeshTools->LinkTool);", "", "Create off-mesh links",  "2");  
    // EWToolsPaletteWindow.addButton("CoverMode",   "ToolsModule:nav_cover_n_image",         "NavEditorGui.setMode(\"CoverMode\");", "","Edit cover",             "3");  
-   // EWToolsPaletteWindow.addButton("TileMode",    "ToolsModule:select_bounds_n_image",     "NavEditorGui.setMode(\"TileMode\");", "", "View tiles",             "4"); 
-   EWToolsPaletteWindow.addButton("TestMode",    "ToolsModule:3rd_person_camera_n_image", "NavEditorGui.setActiveTool(NavMeshTools->TestTool);", "", "Test pathfinding",       "5"); 
-   EWToolsPaletteWindow.addButton("TileMode", "ToolsModule:select_bounds_n_image", "NavEditorGui.setActiveTool(NavMeshTools->TileTool);" , "", "View and Edit Tiles", "4");
+   EWToolsPaletteWindow.addButton("TileMode", "ToolsModule:select_bounds_n_image",     "NavEditorGui.setActiveTool(NavMeshTools->TileTool);" , "", "View and Edit Tiles", "4");
+   EWToolsPaletteWindow.addButton("TestMode", "ToolsModule:3rd_person_camera_n_image", "NavEditorGui.setActiveTool(NavMeshTools->TestTool);", "", "Test pathfinding", "5"); 
    EWToolsPaletteWindow.refresh();
 }
 
@@ -160,7 +166,22 @@ function NavEditorPlugin::onActivated(%this)
    $Nav::EditorOpen = true;
 
    // Start off in Select mode.
-   ToolsPaletteArray->NavEditorSelectMode.performClick();
+      // Callback when the nav editor changes mode. Set the appropriate dynamic
+   // GUI contents in the properties/actions boxes.
+   NavInspector.setVisible(false);
+
+   %actions = NavEditorOptionsWindow->ActionsBox;
+   %actions->SelectActions.setVisible(false);
+   %actions->LinkActions.setVisible(false);
+   %actions->CoverActions.setVisible(false);
+   %actions->TileActions.setVisible(false);
+   %actions->TestActions.setVisible(false);
+
+   %properties = NavEditorOptionsWindow->PropertiesBox;
+   %properties->LinkProperties.setVisible(false);
+   %properties->TileProperties.setVisible(false);
+
+   ENavEditorSelectModeBtn.performClick();
    EditorGui.bringToFront(NavEditorGui);
 
    NavEditorGui.setVisible(true);

+ 46 - 101
Templates/BaseGame/game/tools/navEditor/navEditor.tscript

@@ -296,23 +296,37 @@ function NavEditorGui::showSidePanel()
    %parent.panelHidden = false;
 }
 
-//------------------------------------------------------------------------------
+//------------------------------------------------------
+// NAVMESHTESTTOOL
+//------------------------------------------------------
 
-function OffMeshConnectionTool::onActivated(%this)
+function NavMeshSelectTool::onActivated(%this)
 {
    NavInspector.setVisible(false);
+   %actions = NavEditorOptionsWindow->ActionsBox;
+   NavInspector.setVisible(true);
+   %actions->SelectActions.setVisible(true);
 
+   NavInspector.inspect(NavEditorGui.getMesh());
+}
+
+function NavMeshSelectTool::onDeactivated(%this)
+{
+   NavInspector.setVisible(false);
    %actions = NavEditorOptionsWindow->ActionsBox;
    %actions->SelectActions.setVisible(false);
-   %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
-   %actions->TileActions.setVisible(false);
-   %actions->TestActions.setVisible(false);
+}
+
+//------------------------------------------------------
+// OffMeshConnectionTool
+//------------------------------------------------------
+
+function OffMeshConnectionTool::onActivated(%this)
+{
+   NavInspector.setVisible(false);
 
+   %actions = NavEditorOptionsWindow->ActionsBox;
    %properties = NavEditorOptionsWindow->PropertiesBox;
-   %properties->LinkProperties.setVisible(false);
-   %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
 
    %actions->LinkActions.setVisible(true);
    %properties->LinkProperties.setVisible(true);
@@ -323,16 +337,9 @@ function OffMeshConnectionTool::onDeactivated(%this)
    NavInspector.setVisible(false);
 
    %actions = NavEditorOptionsWindow->ActionsBox;
-   %actions->SelectActions.setVisible(false);
    %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
-   %actions->TileActions.setVisible(false);
-   %actions->TestActions.setVisible(false);
-
    %properties = NavEditorOptionsWindow->PropertiesBox;
    %properties->LinkProperties.setVisible(false);
-   %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
 }
 
 function OffMeshConnectionTool::updateLinkFlags(%this)
@@ -409,6 +416,8 @@ function NavMeshLinkBiDirection::onClick(%this)
    NavMeshTools->LinkTool.updateLinkFlags();
 }
 
+//------------------------------------------------------
+// NAVMESHTESTTOOL
 //------------------------------------------------------
 
 function NavMeshTestTool::onActivated(%this)
@@ -416,19 +425,7 @@ function NavMeshTestTool::onActivated(%this)
    NavInspector.setVisible(false);
 
    %actions = NavEditorOptionsWindow->ActionsBox;
-   %actions->SelectActions.setVisible(false);
-   %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
-   %actions->TileActions.setVisible(false);
-   %actions->TestActions.setVisible(false);
-
-   %properties = NavEditorOptionsWindow->PropertiesBox;
-   %properties->LinkProperties.setVisible(false);
-   %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
-
    %actions->TestActions.setVisible(true);
-   %properties->TestProperties.setVisible(false);
 
    %classList =  enumerateConsoleClasses("Player") TAB enumerateConsoleClasses("Vehicle");
    //echo(%classList);
@@ -448,16 +445,7 @@ function NavMeshTestTool::onDeactivated(%this)
    NavInspector.setVisible(false);
 
    %actions = NavEditorOptionsWindow->ActionsBox;
-   %actions->SelectActions.setVisible(false);
-   %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
-   %actions->TileActions.setVisible(false);
    %actions->TestActions.setVisible(false);
-
-   %properties = NavEditorOptionsWindow->PropertiesBox;
-   %properties->LinkProperties.setVisible(false);
-   %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
 }
 
 function NavMeshTestTool::onPlayerSelected(%this)
@@ -503,10 +491,11 @@ function NavMeshTestTool::toggleFollow(%this)
    
    if(isObject(%this.getFollowObject()) && isObject(%this.getPlayer()))
    {
-      if(%this.getPlayer().isMemberOfClass("AIPlayer"))
-         %this.getPlayer().followObject(%this.getFollowObject(), "2.0");
+      %player = %this.getPlayer();
+      if(%player.isMemberOfClass("AIPlayer"))
+         %player.followObject(%this.getFollowObject(), "2.0");
       else
-         %this.getPlayer().getAIController().followObject(%this.getFollowObject(), %this.getPlayer().getDatablock().aiControllerData.mFollowTolerance);
+         %player.getAIController().followObject(%this.getFollowObject(), %player.getDatablock().aiControllerData.mFollowTolerance);
    }
 }
 
@@ -515,6 +504,20 @@ function NavMeshTestTool::followObject(%this)
    %this.followSelectMode();
 }
 
+function NavMeshTestTool::findCover(%this)
+{
+   if(isObject(%this.getPlayer()))
+   {
+      %player = %this.getPlayer();
+      %pos = %player.getPosition();
+
+      if(%player.isMemberOfClass("AIPlayer"))
+         %player.findCover(%pos,  CoverRadius.getText());
+      else
+         %player.getAIController().findCover(%pos, CoverRadius.getText());
+   }
+}
+
 function SpawnClassSelector::onSelect(%this, %id)
 {
    %className = %this.getTextById(%id);
@@ -546,40 +549,8 @@ function SpawnDatablockSelector::onSelect(%this, %id)
    NavMeshTools->TestTool.setSpawnDatablock(%className);
 }
 
-
-// function NavEditorGui::findCover(%this)
-// {
-//    if(%this.getMode() $= "TestMode" && isObject(%this.getPlayer()))
-//    {
-//       %pos = LocalClientConnection.getControlObject().getPosition();
-//       %text = NavEditorOptionsWindow-->TestProperties->CoverPosition.getText();
-//       if(%text !$= "")
-//          %pos = eval("return " @ %text);
-//       %this.getPlayer().getAIController().findCover(%pos, NavEditorOptionsWindow-->TestProperties->CoverRadius.getText());
-//    }
-// }
-
-// function NavEditorGui::followObject(%this)
-// {
-//    if(%this.getMode() $= "TestMode" && isObject(%this.getPlayer()))
-//    {
-//       %obj = LocalClientConnection.player;
-//       %text = NavEditorOptionsWindow-->TestProperties->FollowObject.getText();
-//       if(%text !$= "")
-//       {
-//          %command = "return " @ %text;
-//          if(!endsWith(%command, ";"))
-//             %command = %command @ ";";
-            
-//          %obj = eval(%command);
-//          if(!isObject(%obj))
-//             toolsMessageBoxOk("Error", "Cannot find object" SPC %text);
-//       }
-//       if(isObject(%obj))
-//          %this.getPlayer().getAIController().followObject(%obj, NavEditorOptionsWindow-->TestProperties->FollowRadius.getText());
-//    }
-// }
-
+//------------------------------------------------------
+// TILETOOL
 //------------------------------------------------------
 
 function TileTool::onActivated(%this)
@@ -587,17 +558,7 @@ function TileTool::onActivated(%this)
    NavInspector.setVisible(false);
 
    %actions = NavEditorOptionsWindow->ActionsBox;
-   %actions->SelectActions.setVisible(false);
-   %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
-   %actions->TileActions.setVisible(false);
-   %actions->TestActions.setVisible(false);
-
    %properties = NavEditorOptionsWindow->PropertiesBox;
-   %properties->LinkProperties.setVisible(false);
-   %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
-
    %actions->TileActions.setVisible(true);
    %properties->TileProperties.setVisible(true);
 }
@@ -607,16 +568,9 @@ function TileTool::onDeactivated(%this)
    NavInspector.setVisible(false);
 
    %actions = NavEditorOptionsWindow->ActionsBox;
-   %actions->SelectActions.setVisible(false);
-   %actions->LinkActions.setVisible(false);
-   %actions->CoverActions.setVisible(false);
    %actions->TileActions.setVisible(false);
-   %actions->TestActions.setVisible(false);
-
    %properties = NavEditorOptionsWindow->PropertiesBox;
-   %properties->LinkProperties.setVisible(false);
    %properties->TileProperties.setVisible(false);
-   %properties->TestProperties.setVisible(false);
 }
 
 //------------------------------------------------------
@@ -659,14 +613,6 @@ function NavEditorGui::onModeSet(%this, %mode)
    }
 }
 
-function NavEditorGui::paletteSync(%this, %mode)
-{
-   // Synchronise the palette (small buttons on the left) with the actual mode
-   // the nav editor is in.
-   %evalShortcut = "ToolsPaletteArray-->" @ %mode @ ".setStateOn(1);";
-   eval(%evalShortcut);
-} 
-
 function NavEditorGui::onEscapePressed(%this)
 {
    return false;
@@ -791,8 +737,7 @@ function NavTreeView::onSelect(%this, %obj)
 
 function NavEditorGui::prepSelectionMode(%this)
 {
-   %this.setMode("SelectMode");
-   ToolsPaletteArray-->NavEditorSelectMode.setStateOn(1);
+   NavEditorGui.setActiveTool(NavMeshTools->SelectTool);
 }
 
 //-----------------------------------------------------------------------------