From 966fb0275ba17b199c90f03df8edabeed229f35b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 8 Nov 2023 11:52:31 +0100 Subject: [PATCH] Add `SortScore` to Visject node archetypes and use it to favor method overrides in Visual Script --- Source/Editor/Surface/Archetypes/Function.cs | 1 + Source/Editor/Surface/ContextMenu/VisjectCMItem.cs | 1 + Source/Editor/Surface/NodeArchetype.cs | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Surface/Archetypes/Function.cs b/Source/Editor/Surface/Archetypes/Function.cs index b7df90728..53950dad2 100644 --- a/Source/Editor/Surface/Archetypes/Function.cs +++ b/Source/Editor/Surface/Archetypes/Function.cs @@ -2470,6 +2470,7 @@ namespace FlaxEditor.Surface.Archetypes Title = string.Empty, Description = "Overrides the base class method with custom implementation", Flags = NodeFlags.VisualScriptGraph | NodeFlags.NoSpawnViaGUI | NodeFlags.NoSpawnViaPaste, + SortScore = 10, IsInputCompatible = MethodOverrideNode.IsInputCompatible, IsOutputCompatible = MethodOverrideNode.IsOutputCompatible, Size = new Float2(240, 60), diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs index 37da7d74d..207875a92 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs @@ -78,6 +78,7 @@ namespace FlaxEditor.Surface.ContextMenu if (!Visible) return; + SortScore += _archetype.SortScore; if (selectedBox != null && CanConnectTo(selectedBox)) SortScore += 1; if (Data != null) diff --git a/Source/Editor/Surface/NodeArchetype.cs b/Source/Editor/Surface/NodeArchetype.cs index 0284fc76d..3a77cef84 100644 --- a/Source/Editor/Surface/NodeArchetype.cs +++ b/Source/Editor/Surface/NodeArchetype.cs @@ -149,6 +149,11 @@ namespace FlaxEditor.Surface /// public object Tag; + /// + /// Custom score value to use when sorting node archetypes in Editor. If positive (eg. 1, 2) can be used to add more importance for a specific node type. + /// + public float SortScore; + /// /// Default node values. This array supports types: bool, int, float, Vector2, Vector3, Vector4, Color, Rectangle, Guid, string, Matrix and byte[]. /// @@ -204,14 +209,17 @@ namespace FlaxEditor.Surface Size = Size, Flags = Flags, Title = Title, - Description = Title, + SubTitle = SubTitle, + Description = Description, AlternativeTitles = (string[])AlternativeTitles?.Clone(), Tag = Tag, + SortScore = SortScore, DefaultValues = (object[])DefaultValues?.Clone(), DefaultType = DefaultType, ConnectionsHints = ConnectionsHints, IndependentBoxes = (int[])IndependentBoxes?.Clone(), DependentBoxes = (int[])DependentBoxes?.Clone(), + DependentBoxFilter = DependentBoxFilter, Elements = (NodeElementArchetype[])Elements?.Clone(), TryParseText = TryParseText, };