فهرست منبع

Fixed clicking on UI elements clearing the scene node selection in the editor.

Lasse Öörni 14 سال پیش
والد
کامیت
4a34382798
3فایلهای تغییر یافته به همراه36 افزوده شده و 36 حذف شده
  1. 32 32
      Bin/Data/Scripts/Editor/EditorView.as
  2. 2 2
      Docs/ScriptAPI.dox
  3. 2 2
      Engine/Engine/UIAPI.cpp

+ 32 - 32
Bin/Data/Scripts/Editor/EditorView.as

@@ -451,51 +451,51 @@ void ViewRaycast(bool mouseClick)
     IntVector2 pos = ui.cursorPosition;
     IntVector2 pos = ui.cursorPosition;
     Component@ selected;
     Component@ selected;
 
 
-    if (ui.GetElementAt(pos, true) is null)
+    if (ui.GetElementAt(pos) !is null)
+        return;
+
+    Ray cameraRay = camera.GetScreenRay(float(pos.x) / graphics.width, float(pos.y) / graphics.height);
+
+    if (pickMode != PICK_COLLISIONSHAPES)
     {
     {
-        Ray cameraRay = camera.GetScreenRay(float(pos.x) / graphics.width, float(pos.y) / graphics.height);
+        if (editorScene.octree is null)
+            return;
 
 
-        if (pickMode != PICK_COLLISIONSHAPES)
+        Array<RayQueryResult> result = editorScene.octree.Raycast(cameraRay, RAY_TRIANGLE, camera.farClip,
+            pickModeDrawableFlags[pickMode]);
+        if (!result.empty)
         {
         {
-            if (editorScene.octree is null)
-                return;
-
-            Array<RayQueryResult> result = editorScene.octree.Raycast(cameraRay, RAY_TRIANGLE, camera.farClip,
-                pickModeDrawableFlags[pickMode]);
-            if (!result.empty)
+            for (uint i = 0; i < result.length; ++i)
             {
             {
-                for (uint i = 0; i < result.length; ++i)
+                Drawable@ drawable = result[i].drawable;
+                if (debug !is null)
                 {
                 {
-                    Drawable@ drawable = result[i].drawable;
-                    if (debug !is null)
-                    {
-                        debug.AddNode(drawable.node, false);
-                        drawable.DrawDebugGeometry(debug, false);
-                    }
-                    selected = drawable;
-                    break;
+                    debug.AddNode(drawable.node, false);
+                    drawable.DrawDebugGeometry(debug, false);
                 }
                 }
+                selected = drawable;
+                break;
             }
             }
         }
         }
-        else
-        {
-            if (editorScene.physicsWorld is null)
-                return;
+    }
+    else
+    {
+        if (editorScene.physicsWorld is null)
+            return;
 
 
-            Array<PhysicsRaycastResult> result = editorScene.physicsWorld.Raycast(cameraRay, camera.farClip);
-            if (!result.empty)
+        Array<PhysicsRaycastResult> result = editorScene.physicsWorld.Raycast(cameraRay, camera.farClip);
+        if (!result.empty)
+        {
+            CollisionShape@ shape = result[0].collisionShape;
+            if (debug !is null)
             {
             {
-                CollisionShape@ shape = result[0].collisionShape;
-                if (debug !is null)
-                {
-                    debug.AddNode(shape.node, false);
-                    shape.DrawDebugGeometry(debug, false);
-                }
-                selected = shape;
+                debug.AddNode(shape.node, false);
+                shape.DrawDebugGeometry(debug, false);
             }
             }
+            selected = shape;
         }
         }
     }
     }
-    
+
     if (mouseClick && input.mouseButtonPress[MOUSEB_LEFT])
     if (mouseClick && input.mouseButtonPress[MOUSEB_LEFT])
     {
     {
         bool multiselect = input.qualifierDown[QUAL_CTRL];
         bool multiselect = input.qualifierDown[QUAL_CTRL];

+ 2 - 2
Docs/ScriptAPI.dox

@@ -3556,8 +3556,8 @@ Methods:<br>
 - void Clear()
 - void Clear()
 - UIElement@ LoadLayout(XMLFile@)
 - UIElement@ LoadLayout(XMLFile@)
 - UIElement@ LoadLayout(XMLFile@, XMLFile@)
 - UIElement@ LoadLayout(XMLFile@, XMLFile@)
-- UIElement@ GetElementAt(const IntVector2&, bool)
-- UIElement@ GetElementAt(int, int, bool)
+- UIElement@ GetElementAt(const IntVector2&, bool arg1 = true)
+- UIElement@ GetElementAt(int, int, bool arg2 = true)
 
 
 Properties:<br>
 Properties:<br>
 - ShortStringHash type (readonly)
 - ShortStringHash type (readonly)

+ 2 - 2
Engine/Engine/UIAPI.cpp

@@ -437,8 +437,8 @@ static void RegisterUI(asIScriptEngine* engine)
     engine->RegisterObjectMethod("UI", "void Clear()", asMETHOD(UI, Clear), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "void Clear()", asMETHOD(UI, Clear), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "UIElement@ LoadLayout(XMLFile@+)", asFUNCTION(UILoadLayout), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("UI", "UIElement@ LoadLayout(XMLFile@+)", asFUNCTION(UILoadLayout), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("UI", "UIElement@ LoadLayout(XMLFile@+, XMLFile@+)", asFUNCTION(UILoadLayoutWithStyle), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("UI", "UIElement@ LoadLayout(XMLFile@+, XMLFile@+)", asFUNCTION(UILoadLayoutWithStyle), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("UI", "UIElement@+ GetElementAt(const IntVector2&in, bool)", asMETHODPR(UI, GetElementAt, (const IntVector2&, bool), UIElement*), asCALL_THISCALL);
-    engine->RegisterObjectMethod("UI", "UIElement@+ GetElementAt(int, int, bool)", asMETHODPR(UI, GetElementAt, (int, int, bool), UIElement*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("UI", "UIElement@+ GetElementAt(const IntVector2&in, bool activeOnly = true)", asMETHODPR(UI, GetElementAt, (const IntVector2&, bool), UIElement*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("UI", "UIElement@+ GetElementAt(int, int, bool activeOnly = true)", asMETHODPR(UI, GetElementAt, (int, int, bool), UIElement*), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "void set_cursor(Cursor@+)", asMETHOD(UI, SetCursor), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "void set_cursor(Cursor@+)", asMETHOD(UI, SetCursor), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "Cursor@+ get_cursor() const", asMETHOD(UI, GetCursor), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "Cursor@+ get_cursor() const", asMETHOD(UI, GetCursor), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "IntVector2 get_cursorPosition()", asMETHOD(UI, GetCursorPosition), asCALL_THISCALL);
     engine->RegisterObjectMethod("UI", "IntVector2 get_cursorPosition()", asMETHOD(UI, GetCursorPosition), asCALL_THISCALL);