diff --git a/src/Artemis.Core/VisualScripting/NodeScript.cs b/src/Artemis.Core/VisualScripting/NodeScript.cs
index b9e0c4e20..b924b0ae4 100644
--- a/src/Artemis.Core/VisualScripting/NodeScript.cs
+++ b/src/Artemis.Core/VisualScripting/NodeScript.cs
@@ -97,8 +97,11 @@ namespace Artemis.Core
///
public void Run()
{
- foreach (INode node in Nodes)
- node.Reset();
+ lock (_nodes)
+ {
+ foreach (INode node in _nodes)
+ node.Reset();
+ }
ExitNode.Evaluate();
}
@@ -106,7 +109,10 @@ namespace Artemis.Core
///
public void AddNode(INode node)
{
- _nodes.Add(node);
+ lock (_nodes)
+ {
+ _nodes.Add(node);
+ }
NodeAdded?.Invoke(this, new SingleValueEventArgs(node));
}
@@ -114,7 +120,10 @@ namespace Artemis.Core
///
public void RemoveNode(INode node)
{
- _nodes.Remove(node);
+ lock (_nodes)
+ {
+ _nodes.Remove(node);
+ }
if (node is IDisposable disposable)
disposable.Dispose();
@@ -128,10 +137,13 @@ namespace Artemis.Core
NodeTypeStore.NodeTypeAdded -= NodeTypeStoreOnNodeTypeChanged;
NodeTypeStore.NodeTypeRemoved -= NodeTypeStoreOnNodeTypeChanged;
- foreach (INode node in _nodes)
+ lock (_nodes)
{
- if (node is IDisposable disposable)
- disposable.Dispose();
+ foreach (INode node in _nodes)
+ {
+ if (node is IDisposable disposable)
+ disposable.Dispose();
+ }
}
}
@@ -142,9 +154,12 @@ namespace Artemis.Core
///
public void Load()
{
- List removeNodes = _nodes.Where(n => !n.IsExitNode).ToList();
- foreach (INode removeNode in removeNodes)
- RemoveNode(removeNode);
+ lock (_nodes)
+ {
+ List removeNodes = _nodes.Where(n => !n.IsExitNode).ToList();
+ foreach (INode removeNode in removeNodes)
+ RemoveNode(removeNode);
+ }
// Create nodes
foreach (NodeEntity entityNode in Entity.Nodes)
diff --git a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptNodeCreationBox.cs b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptNodeCreationBox.cs
index 3a266d336..999fcd440 100644
--- a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptNodeCreationBox.cs
+++ b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptNodeCreationBox.cs
@@ -51,7 +51,6 @@ namespace Artemis.VisualScripting.Editor.Controls
set => SetValue(SourcePinProperty, value);
}
-
public static readonly DependencyProperty CreateNodeCommandProperty = DependencyProperty.Register(
"CreateNodeCommand", typeof(ICommand), typeof(VisualScriptNodeCreationBox), new PropertyMetadata(default(ICommand)));
@@ -61,6 +60,15 @@ namespace Artemis.VisualScripting.Editor.Controls
set => SetValue(CreateNodeCommandProperty, value);
}
+ public static readonly DependencyProperty SearchInputProperty = DependencyProperty.Register(
+ "SearchInput", typeof(string), typeof(VisualScriptNodeCreationBox), new PropertyMetadata(default(string), OnSearchInputChanged));
+
+ public string SearchInput
+ {
+ get => (string)GetValue(SearchInputProperty);
+ set => SetValue(SearchInputProperty, value);
+ }
+
#endregion
#region Methods
@@ -70,7 +78,6 @@ namespace Artemis.VisualScripting.Editor.Controls
_searchBox = GetTemplateChild(PART_SEARCHBOX) as TextBox ?? throw new NullReferenceException($"The Element '{PART_SEARCHBOX}' is missing.");
_contentList = GetTemplateChild(PART_CONTENT) as ListBox ?? throw new NullReferenceException($"The Element '{PART_CONTENT}' is missing.");
- _searchBox.TextChanged += OnSearchBoxTextChanged;
_contentList.IsSynchronizedWithCurrentItem = false;
_contentList.SelectionChanged += OnContentListSelectionChanged;
_contentList.SelectionMode = SelectionMode.Single;
@@ -90,32 +97,29 @@ namespace Artemis.VisualScripting.Editor.Controls
_searchBox.SelectionStart = 0;
_searchBox.SelectionLength = _searchBox.Text.Length;
}
-
- private void OnSearchBoxTextChanged(object sender, TextChangedEventArgs args)
- {
- _contentView?.Refresh();
- }
-
+
private void OnContentListSelectionChanged(object sender, SelectionChangedEventArgs args)
{
if ((args == null) || (_contentList?.SelectedItem == null)) return;
CreateNodeCommand?.Execute(_contentList.SelectedItem);
+ _contentList.SelectedItem = null;
}
private bool Filter(object o)
{
- if (_searchBox == null) return false;
if (o is not NodeData nodeData) return false;
+ if (string.IsNullOrWhiteSpace(SearchInput)) return true;
- bool nameContains = nodeData.Name.Contains(_searchBox.Text, StringComparison.OrdinalIgnoreCase);
+ bool searchContains = nodeData.Name.Contains(SearchInput, StringComparison.OrdinalIgnoreCase) ||
+ nodeData.Description.Contains(SearchInput, StringComparison.OrdinalIgnoreCase);
if (SourcePin == null || SourcePin.Pin.Type == typeof(object))
- return nameContains;
+ return searchContains;
if (SourcePin.Pin.Direction == PinDirection.Input)
- return nodeData.OutputType != null && nameContains && (nodeData.OutputType == typeof(object) || nodeData.OutputType.IsAssignableTo(SourcePin.Pin.Type));
- return nodeData.InputType != null && nameContains && (nodeData.InputType == typeof(object) || nodeData.InputType.IsAssignableFrom(SourcePin.Pin.Type));
+ return nodeData.OutputType != null && searchContains && (nodeData.OutputType == typeof(object) || nodeData.OutputType.IsAssignableTo(SourcePin.Pin.Type));
+ return nodeData.InputType != null && searchContains && (nodeData.InputType == typeof(object) || nodeData.InputType.IsAssignableFrom(SourcePin.Pin.Type));
}
private void ItemsSourceChanged()
@@ -150,6 +154,8 @@ namespace Artemis.VisualScripting.Editor.Controls
private static void OnSourcePinChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as VisualScriptNodeCreationBox)?._contentView.Refresh();
+ private static void OnSearchInputChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as VisualScriptNodeCreationBox)?._contentView.Refresh();
+
#endregion
}
}
\ No newline at end of file
diff --git a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs
index a174433ee..751794540 100644
--- a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs
+++ b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs
@@ -552,7 +552,7 @@ namespace Artemis.VisualScripting.Editor.Controls
if (_creationBoxParent.ContextMenu != null)
_creationBoxParent.ContextMenu.IsOpen = false;
-
+
Script.AddNode(node);
}
diff --git a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptNodeCreationBox.xaml b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptNodeCreationBox.xaml
index 9a38dde97..15c02e1a4 100644
--- a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptNodeCreationBox.xaml
+++ b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptNodeCreationBox.xaml
@@ -2,46 +2,50 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Artemis.VisualScripting.Editor.Controls"
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
- xmlns:behaviors="clr-namespace:Artemis.VisualScripting.Behaviors">
+ xmlns:behaviors="clr-namespace:Artemis.VisualScripting.Behaviors"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
-
-
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
@@ -57,7 +61,7 @@
@@ -70,14 +74,11 @@
-
-
-
+
-