mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Nodes - Reorganized code
This commit is contained in:
parent
69b881b044
commit
7c83d5345f
@ -23,7 +23,7 @@ namespace Artemis.Core
|
||||
return false;
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
if (obj.GetType() != this.GetType())
|
||||
if (obj.GetType() != GetType())
|
||||
return false;
|
||||
return Equals((ColorGradientStop) obj);
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ namespace Artemis.Core
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((DataModelPath) obj);
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ namespace Artemis.Core
|
||||
/// <param name="texture">The texture drawn by this brush.</param>
|
||||
public SKTextureBrush(SKTexture? texture)
|
||||
{
|
||||
this.Texture = texture;
|
||||
Texture = texture;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -90,7 +90,7 @@ namespace Artemis.Core
|
||||
public bool IsTop(T value)
|
||||
{
|
||||
bool result = false;
|
||||
if (this.Count > 0)
|
||||
if (Count > 0)
|
||||
{
|
||||
result = Peek()!.Equals(value);
|
||||
}
|
||||
@ -100,7 +100,7 @@ namespace Artemis.Core
|
||||
public bool Contains(T value)
|
||||
{
|
||||
bool result = false;
|
||||
if (this.Count > 0)
|
||||
if (Count > 0)
|
||||
{
|
||||
result = _list.Contains(value);
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
|
||||
public ExitNode(string name, string description = "")
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
Name = name;
|
||||
Description = description;
|
||||
|
||||
Input = CreateInputPin<T>();
|
||||
}
|
||||
|
||||
@ -167,6 +167,21 @@ public abstract class Node : CorePropertyChanged, INode
|
||||
return isRemoved;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an existing <paramref name="pin"/> to the <see cref="Pins" /> collection.
|
||||
/// </summary>
|
||||
/// <param name="pin">The pin to add</param>
|
||||
protected void AddPin(Pin pin)
|
||||
{
|
||||
if (pin.Node != this)
|
||||
throw new ArtemisCoreException("Can't add a pin to a node that belongs to a different node than the one it's being added to.");
|
||||
if (_pins.Contains(pin))
|
||||
return;
|
||||
|
||||
_pins.Add(pin);
|
||||
OnPropertyChanged(nameof(Pins));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new input pin collection and adds it to the <see cref="PinCollections" /> collection
|
||||
/// </summary>
|
||||
|
||||
@ -24,6 +24,7 @@ namespace Artemis.UI.Shared.Controls
|
||||
private readonly ObservableCollection<(Enum, string)> _currentValues = new();
|
||||
|
||||
private ComboBox? _enumComboBox;
|
||||
private Type _currentType;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="EnumComboBox" /> class.
|
||||
@ -69,11 +70,14 @@ namespace Artemis.UI.Shared.Controls
|
||||
private void UpdateValues()
|
||||
{
|
||||
Type? newType = Value?.GetType();
|
||||
if (_enumComboBox == null || _currentValues.Any() || newType is not {IsEnum: true})
|
||||
if (_enumComboBox == null || newType == null || _currentType == newType)
|
||||
return;
|
||||
|
||||
_currentValues.Clear();
|
||||
foreach ((Enum, string) valueDesc in EnumUtilities.GetAllValuesAndDescriptions(newType))
|
||||
_currentValues.Add(valueDesc);
|
||||
|
||||
_currentType = newType;
|
||||
}
|
||||
|
||||
private void UpdateSelection()
|
||||
|
||||
@ -45,8 +45,8 @@ public class AddNode : INodeEditorCommand, IDisposable
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isRemoved)
|
||||
_nodeScript.Dispose();
|
||||
if (_isRemoved && _node is IDisposable disposableNode)
|
||||
disposableNode.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -11,7 +11,7 @@ public class DeleteNode : INodeEditorCommand, IDisposable
|
||||
{
|
||||
private readonly INode _node;
|
||||
private readonly INodeScript _nodeScript;
|
||||
private readonly Dictionary<IPin, List<IPin>> _pinConnections = new();
|
||||
private readonly NodeConnectionStore _connections;
|
||||
private bool _isRemoved;
|
||||
|
||||
/// <summary>
|
||||
@ -23,58 +23,15 @@ public class DeleteNode : INodeEditorCommand, IDisposable
|
||||
{
|
||||
_nodeScript = nodeScript;
|
||||
_node = node;
|
||||
}
|
||||
|
||||
private void StoreConnections()
|
||||
{
|
||||
_pinConnections.Clear();
|
||||
foreach (IPin nodePin in _node.Pins)
|
||||
{
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
nodePin.DisconnectAll();
|
||||
}
|
||||
|
||||
foreach (IPinCollection nodePinCollection in _node.PinCollections)
|
||||
{
|
||||
foreach (IPin nodePin in nodePinCollection)
|
||||
{
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
nodePin.DisconnectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreConnections()
|
||||
{
|
||||
foreach (IPin nodePin in _node.Pins)
|
||||
{
|
||||
if (_pinConnections.TryGetValue(nodePin, out List<IPin>? connections))
|
||||
{
|
||||
foreach (IPin connection in connections)
|
||||
nodePin.ConnectTo(connection);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IPinCollection nodePinCollection in _node.PinCollections)
|
||||
{
|
||||
foreach (IPin nodePin in nodePinCollection)
|
||||
{
|
||||
if (_pinConnections.TryGetValue(nodePin, out List<IPin>? connections))
|
||||
{
|
||||
foreach (IPin connection in connections)
|
||||
nodePin.ConnectTo(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_pinConnections.Clear();
|
||||
_connections = new NodeConnectionStore(_node);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isRemoved)
|
||||
_nodeScript.Dispose();
|
||||
if (_isRemoved && _node is IDisposable disposableNode)
|
||||
disposableNode.Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -83,7 +40,7 @@ public class DeleteNode : INodeEditorCommand, IDisposable
|
||||
/// <inheritdoc />
|
||||
public void Execute()
|
||||
{
|
||||
StoreConnections();
|
||||
_connections.Store();
|
||||
_nodeScript.RemoveNode(_node);
|
||||
|
||||
_isRemoved = true;
|
||||
@ -93,7 +50,7 @@ public class DeleteNode : INodeEditorCommand, IDisposable
|
||||
public void Undo()
|
||||
{
|
||||
_nodeScript.AddNode(_node);
|
||||
RestoreConnections();
|
||||
_connections.Restore();
|
||||
|
||||
_isRemoved = false;
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.NodeEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a class that can store and restore a node's connections
|
||||
/// </summary>
|
||||
public class NodeConnectionStore
|
||||
{
|
||||
private readonly Dictionary<IPin, List<IPin>> _pinConnections = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="NodeConnectionStore" /> class.
|
||||
/// </summary>
|
||||
/// <param name="node">The node whose connections to store</param>
|
||||
public NodeConnectionStore(INode node)
|
||||
{
|
||||
Node = node;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node this instance will store connections for.
|
||||
/// </summary>
|
||||
public INode Node { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores and clears the current connections of the node
|
||||
/// </summary>
|
||||
public void Store()
|
||||
{
|
||||
_pinConnections.Clear();
|
||||
foreach (IPin nodePin in Node.Pins)
|
||||
{
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
nodePin.DisconnectAll();
|
||||
}
|
||||
|
||||
foreach (IPinCollection nodePinCollection in Node.PinCollections)
|
||||
{
|
||||
foreach (IPin nodePin in nodePinCollection)
|
||||
{
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
nodePin.DisconnectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores the connections of the node as they were during the last <see cref="Store" /> call.
|
||||
/// </summary>
|
||||
public void Restore()
|
||||
{
|
||||
foreach (IPin nodePin in Node.Pins)
|
||||
{
|
||||
if (_pinConnections.TryGetValue(nodePin, out List<IPin>? connections))
|
||||
foreach (IPin connection in connections)
|
||||
nodePin.ConnectTo(connection);
|
||||
}
|
||||
|
||||
foreach (IPinCollection nodePinCollection in Node.PinCollections)
|
||||
{
|
||||
foreach (IPin nodePin in nodePinCollection)
|
||||
{
|
||||
if (_pinConnections.TryGetValue(nodePin, out List<IPin>? connections))
|
||||
foreach (IPin connection in connections)
|
||||
nodePin.ConnectTo(connection);
|
||||
}
|
||||
}
|
||||
|
||||
_pinConnections.Clear();
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ public abstract class ViewModelValidationBase : ReactiveValidationObject
|
||||
public string? DisplayName
|
||||
{
|
||||
get => _displayName;
|
||||
set => this.RaiseAndSetIfChanged(ref _displayName, value);
|
||||
set => RaiseAndSetIfChanged(ref _displayName, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -30,15 +30,15 @@
|
||||
</Template>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style Selector="TreeView#NodeTree">
|
||||
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Border Classes="picker-container">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<TextBox Name="SearchBox" Text="{CompiledBinding SearchText}" Margin="0 0 0 15" Watermark="Search"></TextBox>
|
||||
<TreeView Name="NodeTree" Grid.Row="1" Items="{CompiledBinding Categories}" IsVisible="{CompiledBinding Categories.Count}" SelectedItem="{CompiledBinding SelectedNode}">
|
||||
<TreeView Name="NodeTree"
|
||||
Grid.Row="1"
|
||||
Items="{CompiledBinding Categories}"
|
||||
IsVisible="{CompiledBinding Categories.Count}"
|
||||
SelectedItem="{CompiledBinding SelectedNode}">
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="True" />
|
||||
|
||||
@ -9,6 +9,7 @@ using Artemis.UI.Screens.VisualScripting;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.VisualScripting.Nodes;
|
||||
using Artemis.VisualScripting.Nodes.Operators;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
@ -10,6 +10,7 @@ using Artemis.UI.Shared.Providers;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.PropertyInput;
|
||||
using Artemis.VisualScripting.Nodes;
|
||||
using Artemis.VisualScripting.Nodes.Mathematics;
|
||||
using Avalonia;
|
||||
using DynamicData;
|
||||
using Ninject;
|
||||
|
||||
@ -24,10 +24,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Nodes\CustomViews\StaticStringValueNodeCustomView.axaml.cs">
|
||||
<Compile Update="Nodes\Easing\Screens\EasingTypeNodeEasingView.axaml.cs">
|
||||
<DependentUpon>EasingTypeNodeEasingView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Nodes\Static\Screens\StaticStringValueNodeCustomView.axaml.cs">
|
||||
<DependentUpon>StaticStringValueNodeCustomView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Nodes\DataModel\CustomViews\DataModelNodeCustomView.axaml.cs">
|
||||
<Compile Update="Nodes\DataModel\Screens\DataModelNodeCustomView.axaml.cs">
|
||||
<DependentUpon>DataModelNodeCustomView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,299 +0,0 @@
|
||||
using System.Collections;
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
|
||||
[Node("Greater than", "Checks if the first input is greater than the second.", "Operators", InputType = typeof(object), OutputType = typeof(bool))]
|
||||
public class GreaterThanNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public GreaterThanNode()
|
||||
: base("Greater than", "Checks if the first input is greater than the second.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
if (Input1.Value is Numeric numeric1 && Input2.Value is Numeric numeric2)
|
||||
{
|
||||
Result.Value = numeric1 > numeric2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input2.Value != null && Input1.Value != null && Input1.Value.IsNumber() && Input2.Value.IsNumber())
|
||||
{
|
||||
Result.Value = Convert.ToSingle(Input1.Value) > Convert.ToSingle(Input2.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Result.Value = Comparer.DefaultInvariant.Compare(Input1.Value, Input2.Value) == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Less than", "Checks if the first input is less than the second.", "Operators", InputType = typeof(object), OutputType = typeof(bool))]
|
||||
public class LessThanNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public LessThanNode()
|
||||
: base("Less than", "Checks if the first input is less than the second.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
if (Input1.Value is Numeric numeric1 && Input2.Value is Numeric numeric2)
|
||||
{
|
||||
Result.Value = numeric1 < numeric2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input2.Value != null && Input1.Value != null && Input1.Value.IsNumber() && Input2.Value.IsNumber())
|
||||
{
|
||||
Result.Value = Convert.ToSingle(Input1.Value) < Convert.ToSingle(Input2.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Result.Value = Comparer.DefaultInvariant.Compare(Input1.Value, Input2.Value) == -1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Equals", "Checks if the two inputs are equals.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class EqualsNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public EqualsNode()
|
||||
: base("Equals", "Checks if the two inputs are equals.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
try
|
||||
{
|
||||
Result.Value = Equals(Input1.Value, Input2.Value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Negate", "Negates the boolean.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class NegateNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public NegateNode()
|
||||
: base("Negate", "Negates the boolean.")
|
||||
{
|
||||
Input = CreateInputPin<bool>();
|
||||
Output = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = !Input.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<bool> Input { get; }
|
||||
public OutputPin<bool> Output { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("And", "Checks if all inputs are true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class AndNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public AndNode()
|
||||
: base("And", "Checks if all inputs are true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.All(v => v);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Or", "Checks if any inputs are true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class OrNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public OrNode()
|
||||
: base("Or", "Checks if any inputs are true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.Any(v => v);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Exclusive Or", "Checks if one of the inputs is true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class XorNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public XorNode()
|
||||
: base("Exclusive Or", "Checks if one of the inputs is true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.Count(v => v) == 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("Enum Equals", "Determines the equality between an input and a selected enum value", "Operators", InputType = typeof(Enum), OutputType = typeof(bool))]
|
||||
public class EnumEqualsNode : Node<Enum, EnumEqualsNodeCustomViewModel>
|
||||
{
|
||||
public EnumEqualsNode() : base("Enum Equals", "Determines the equality between an input and a selected enum value")
|
||||
{
|
||||
InputPin = CreateInputPin<Enum>();
|
||||
OutputPin = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
public InputPin<Enum> InputPin { get; }
|
||||
public OutputPin<bool> OutputPin { get; }
|
||||
|
||||
#region Overrides of Node
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate()
|
||||
{
|
||||
OutputPin.Value = InputPin.Value != null && InputPin.Value.Equals(Storage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,38 +1,6 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
|
||||
[Node("To String", "Converts the input to a string.", "Conversion", InputType = typeof(object), OutputType = typeof(string))]
|
||||
public class ConvertToStringNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public ConvertToStringNode()
|
||||
: base("To String", "Converts the input to a string.")
|
||||
{
|
||||
Input = CreateInputPin<object>();
|
||||
String = CreateOutputPin<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
String.Value = Input.Value?.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input { get; }
|
||||
|
||||
public OutputPin<string> String { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
namespace Artemis.VisualScripting.Nodes.Conversion;
|
||||
|
||||
[Node("To Numeric", "Converts the input to a numeric.", "Conversion", InputType = typeof(object), OutputType = typeof(Numeric))]
|
||||
public class ConvertToNumericNode : Node
|
||||
@ -0,0 +1,35 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Conversion;
|
||||
|
||||
[Node("To String", "Converts the input to a string.", "Conversion", InputType = typeof(object), OutputType = typeof(string))]
|
||||
public class ConvertToStringNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public ConvertToStringNode()
|
||||
: base("To String", "Converts the input to a string.")
|
||||
{
|
||||
Input = CreateInputPin<object>();
|
||||
String = CreateOutputPin<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
String.Value = Input.Value?.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input { get; }
|
||||
|
||||
public OutputPin<string> String { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using DynamicData;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
|
||||
public class EnumEqualsNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly EnumEqualsNode _node;
|
||||
|
||||
public EnumEqualsNodeCustomViewModel(EnumEqualsNode node, INodeScript script) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public ObservableCollection<(Enum, string)> EnumValues { get; } = new();
|
||||
|
||||
// public override void OnActivate()
|
||||
// {
|
||||
// _node.InputPin.PinConnected += InputPinOnPinConnected;
|
||||
// _node.InputPin.PinDisconnected += InputPinOnPinDisconnected;
|
||||
//
|
||||
// if (_node.InputPin.Value != null && _node.InputPin.Value.GetType().IsEnum)
|
||||
// EnumValues.AddRange(EnumUtilities.GetAllValuesAndDescriptions(_node.InputPin.Value.GetType()));
|
||||
// base.OnActivate();
|
||||
// }
|
||||
//
|
||||
// public override void OnDeactivate()
|
||||
// {
|
||||
// _node.InputPin.PinConnected -= InputPinOnPinConnected;
|
||||
// _node.InputPin.PinDisconnected -= InputPinOnPinDisconnected;
|
||||
//
|
||||
// base.OnDeactivate();
|
||||
// }
|
||||
|
||||
private void InputPinOnPinDisconnected(object sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
EnumValues.Clear();
|
||||
}
|
||||
|
||||
private void InputPinOnPinConnected(object sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
EnumValues.Clear();
|
||||
if (_node.InputPin.Value != null && _node.InputPin.Value.GetType().IsEnum)
|
||||
EnumValues.AddRange(EnumUtilities.GetAllValuesAndDescriptions(_node.InputPin.Value.GetType()));
|
||||
}
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
|
||||
public class LayerPropertyNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly LayerPropertyNode _node;
|
||||
private ILayerProperty _selectedLayerProperty;
|
||||
|
||||
private RenderProfileElement _selectedProfileElement;
|
||||
|
||||
public LayerPropertyNodeCustomViewModel(LayerPropertyNode node, INodeScript script) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public ObservableCollection<RenderProfileElement> ProfileElements { get; } = new();
|
||||
|
||||
// public RenderProfileElement SelectedProfileElement
|
||||
// {
|
||||
// get => _selectedProfileElement;
|
||||
// set
|
||||
// {
|
||||
// if (!SetAndNotify(ref _selectedProfileElement, value)) return;
|
||||
// _node.ChangeProfileElement(_selectedProfileElement);
|
||||
// GetLayerProperties();
|
||||
// }
|
||||
// }
|
||||
|
||||
public ObservableCollection<ILayerProperty> LayerProperties { get; } = new();
|
||||
|
||||
// public ILayerProperty SelectedLayerProperty
|
||||
// {
|
||||
// get => _selectedLayerProperty;
|
||||
// set
|
||||
// {
|
||||
// if (!SetAndNotify(ref _selectedLayerProperty, value)) return;
|
||||
// _node.ChangeLayerProperty(_selectedLayerProperty);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void GetProfileElements()
|
||||
// {
|
||||
// ProfileElements.Clear();
|
||||
// if (_node.Script.Context is not Profile profile)
|
||||
// return;
|
||||
//
|
||||
// List<RenderProfileElement> elements = new(profile.GetAllRenderElements());
|
||||
//
|
||||
// ProfileElements.AddRange(elements.OrderBy(e => e.Order));
|
||||
// _selectedProfileElement = _node.ProfileElement;
|
||||
// NotifyOfPropertyChange(nameof(SelectedProfileElement));
|
||||
// }
|
||||
//
|
||||
// private void GetLayerProperties()
|
||||
// {
|
||||
// LayerProperties.Clear();
|
||||
// if (_node.ProfileElement == null)
|
||||
// return;
|
||||
//
|
||||
// LayerProperties.AddRange(_node.ProfileElement.GetAllLayerProperties().Where(l => !l.IsHidden && l.DataBindingsSupported));
|
||||
// _selectedLayerProperty = _node.LayerProperty;
|
||||
// NotifyOfPropertyChange(nameof(SelectedLayerProperty));
|
||||
// }
|
||||
//
|
||||
// public override void OnActivate()
|
||||
// {
|
||||
// GetProfileElements();
|
||||
// GetLayerProperties();
|
||||
// }
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.DataModel.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.DataModel.Screens;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel;
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:dataModelPicker="clr-namespace:Artemis.UI.Shared.Controls.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.CustomViewModels"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.CustomViews.DataModelEventNodeCustomView"
|
||||
x:DataType="customViewModels:DataModelEventNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.Screens.DataModelEventNodeCustomView"
|
||||
x:DataType="screens:DataModelEventNodeCustomViewModel">
|
||||
<dataModelPicker:DataModelPickerButton Classes="condensed"
|
||||
DataModelPath="{CompiledBinding DataModelPath}"
|
||||
Modules="{CompiledBinding Modules}"
|
||||
@ -1,10 +1,7 @@
|
||||
using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.Screens
|
||||
{
|
||||
public partial class DataModelEventNodeCustomView : ReactiveUserControl<DataModelEventNodeCustomViewModel>
|
||||
{
|
||||
@ -9,7 +9,7 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.Screens;
|
||||
|
||||
public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -3,10 +3,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:dataModelPicker="clr-namespace:Artemis.UI.Shared.Controls.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.CustomViewModels"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.CustomViews.DataModelNodeCustomView"
|
||||
x:DataType="customViewModels:DataModelNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.Screens.DataModelNodeCustomView"
|
||||
x:DataType="screens:DataModelNodeCustomViewModel">
|
||||
<dataModelPicker:DataModelPickerButton Classes="condensed"
|
||||
DataModelPath="{CompiledBinding DataModelPath}"
|
||||
Modules="{CompiledBinding Modules}"
|
||||
@ -1,10 +1,7 @@
|
||||
using Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.Screens
|
||||
{
|
||||
public partial class DataModelNodeCustomView : ReactiveUserControl<DataModelNodeCustomViewModel>
|
||||
{
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Disposables;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
@ -10,7 +9,7 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.DataModel.Screens;
|
||||
|
||||
public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -1,5 +1,5 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Easing.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.Easing.CustomViewModels"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Easing.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.CustomViews.EasingTypeNodeCustomView"
|
||||
x:DataType="customViewModels:EasingTypeNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.Screens.EasingTypeNodeCustomView"
|
||||
x:DataType="screens:EasingTypeNodeCustomViewModel">
|
||||
<ComboBox Classes="condensed" MinWidth="75" Items="{CompiledBinding EasingViewModels}" SelectedItem="{CompiledBinding SelectedEasingViewModel}" />
|
||||
</UserControl>
|
||||
@ -1,10 +1,7 @@
|
||||
using Artemis.VisualScripting.Nodes.Easing.CustomViewModels;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens
|
||||
{
|
||||
public partial class EasingTypeNodeCustomView : ReactiveUserControl<EasingTypeNodeCustomViewModel>
|
||||
{
|
||||
@ -5,7 +5,7 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
|
||||
public class EasingTypeNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -18,12 +18,12 @@ public class EasingTypeNodeCustomViewModel : CustomNodeViewModel
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(SelectedEasingViewModel));
|
||||
EasingViewModels = new ObservableCollection<NodeEasingViewModel>(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(e => new NodeEasingViewModel(e)));
|
||||
EasingViewModels = new ObservableCollection<EasingTypeNodeEasingViewModel>(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(e => new EasingTypeNodeEasingViewModel(e)));
|
||||
}
|
||||
|
||||
public ObservableCollection<NodeEasingViewModel> EasingViewModels { get; }
|
||||
public ObservableCollection<EasingTypeNodeEasingViewModel> EasingViewModels { get; }
|
||||
|
||||
public NodeEasingViewModel? SelectedEasingViewModel
|
||||
public EasingTypeNodeEasingViewModel? SelectedEasingViewModel
|
||||
{
|
||||
get => EasingViewModels.FirstOrDefault(e => e.EasingFunction == _node.Storage);
|
||||
set
|
||||
@ -2,10 +2,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.Easing.CustomViewModels"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Easing.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.CustomViews.NodeEasingView"
|
||||
x:DataType="customViewModels:NodeEasingViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.Screens.EasingTypeNodeEasingView"
|
||||
x:DataType="screens:EasingTypeNodeEasingViewModel">
|
||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||
<Polyline Stroke="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
StrokeThickness="1"
|
||||
@ -1,12 +1,11 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens
|
||||
{
|
||||
public partial class NodeEasingView : UserControl
|
||||
public partial class EasingTypeNodeEasingView : UserControl
|
||||
{
|
||||
public NodeEasingView()
|
||||
public EasingTypeNodeEasingView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@ -3,11 +3,11 @@ using Artemis.UI.Shared;
|
||||
using Avalonia;
|
||||
using Humanizer;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
|
||||
public class NodeEasingViewModel : ViewModelBase
|
||||
public class EasingTypeNodeEasingViewModel : ViewModelBase
|
||||
{
|
||||
public NodeEasingViewModel(Easings.Functions easingFunction)
|
||||
public EasingTypeNodeEasingViewModel(Easings.Functions easingFunction)
|
||||
{
|
||||
EasingFunction = easingFunction;
|
||||
Description = easingFunction.Humanize();
|
||||
@ -0,0 +1,45 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.External.Commands;
|
||||
|
||||
public class UpdateLayerPropertyNodeSelectedLayerProperty : INodeEditorCommand
|
||||
{
|
||||
private readonly LayerPropertyNode _node;
|
||||
private readonly ILayerProperty? _value;
|
||||
private readonly ILayerProperty? _oldValue;
|
||||
private readonly NodeConnectionStore _connections;
|
||||
|
||||
public UpdateLayerPropertyNodeSelectedLayerProperty(LayerPropertyNode node, ILayerProperty? value)
|
||||
{
|
||||
_node = node;
|
||||
_connections = new NodeConnectionStore(_node);
|
||||
|
||||
_value = value;
|
||||
_oldValue = _node.LayerProperty;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DisplayName => "Update node layer property";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Execute()
|
||||
{
|
||||
// Store connections as they currently are
|
||||
_connections.Store();
|
||||
|
||||
// Update the selected profile element
|
||||
_node.ChangeLayerProperty(_value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Undo()
|
||||
{
|
||||
// Restore the previous layer property
|
||||
_node.ChangeLayerProperty(_oldValue);
|
||||
|
||||
// Restore connections
|
||||
_connections.Restore();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.External.Commands;
|
||||
|
||||
public class UpdateLayerPropertyNodeSelectedProfileElement : INodeEditorCommand
|
||||
{
|
||||
private readonly LayerPropertyNode _node;
|
||||
private readonly NodeConnectionStore _connections;
|
||||
|
||||
private readonly RenderProfileElement? _value;
|
||||
private readonly RenderProfileElement? _oldValue;
|
||||
private readonly ILayerProperty? _oldLayerProperty;
|
||||
|
||||
public UpdateLayerPropertyNodeSelectedProfileElement(LayerPropertyNode node, RenderProfileElement? value)
|
||||
{
|
||||
_node = node;
|
||||
_connections = new NodeConnectionStore(_node);
|
||||
|
||||
_value = value;
|
||||
_oldValue = node.ProfileElement;
|
||||
_oldLayerProperty = node.LayerProperty;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DisplayName => "Update node profile element";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Execute()
|
||||
{
|
||||
// Store connections as they currently are
|
||||
_connections.Store();
|
||||
|
||||
// Update the selected profile element
|
||||
_node.ChangeProfileElement(_value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Undo()
|
||||
{
|
||||
// Can't undo it if that profile element is now gone :\
|
||||
if (_oldValue != null && _oldValue.Disposed)
|
||||
return;
|
||||
|
||||
// Restore the previous profile element
|
||||
_node.ChangeProfileElement(_oldValue);
|
||||
|
||||
// Restore the previous layer property
|
||||
_node.ChangeLayerProperty(_oldLayerProperty);
|
||||
|
||||
// Restore connections
|
||||
_connections.Restore();
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,21 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.External.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
namespace Artemis.VisualScripting.Nodes.External;
|
||||
|
||||
[Node("Layer/Folder Property", "Outputs the property of a selected layer or folder", "External")]
|
||||
public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNodeCustomViewModel>
|
||||
{
|
||||
private readonly object _layerPropertyLock = new();
|
||||
private readonly List<OutputPin> _pinBucket = new();
|
||||
|
||||
public INodeScript Script { get; private set; }
|
||||
public RenderProfileElement ProfileElement { get; private set; }
|
||||
public ILayerProperty LayerProperty { get; private set; }
|
||||
public LayerPropertyNode() : base("Layer/Folder Property", "Outputs the property of a selected layer or folder")
|
||||
{
|
||||
}
|
||||
|
||||
public INodeScript? Script { get; private set; }
|
||||
public RenderProfileElement? ProfileElement { get; private set; }
|
||||
public ILayerProperty? LayerProperty { get; private set; }
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
@ -51,10 +56,10 @@ public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNode
|
||||
{
|
||||
lock (_layerPropertyLock)
|
||||
{
|
||||
if (Script.Context is not Profile profile || Storage == null)
|
||||
if (Script?.Context is not Profile profile || Storage == null)
|
||||
return;
|
||||
|
||||
RenderProfileElement element = profile.GetAllRenderElements().FirstOrDefault(l => l.EntityId == Storage.ElementId);
|
||||
RenderProfileElement? element = profile.GetAllRenderElements().FirstOrDefault(l => l.EntityId == Storage.ElementId);
|
||||
|
||||
ProfileElement = element;
|
||||
LayerProperty = element?.GetAllLayerProperties().FirstOrDefault(p => p.Path == Storage.PropertyPath);
|
||||
@ -62,12 +67,12 @@ public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNode
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeProfileElement(RenderProfileElement profileElement)
|
||||
public void ChangeProfileElement(RenderProfileElement? profileElement)
|
||||
{
|
||||
lock (_layerPropertyLock)
|
||||
{
|
||||
ProfileElement = profileElement;
|
||||
LayerProperty = null;
|
||||
LayerProperty = profileElement?.GetAllLayerProperties().FirstOrDefault();
|
||||
|
||||
Storage = new LayerPropertyNodeEntity
|
||||
{
|
||||
@ -79,7 +84,7 @@ public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNode
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeLayerProperty(ILayerProperty layerProperty)
|
||||
public void ChangeLayerProperty(ILayerProperty? layerProperty)
|
||||
{
|
||||
lock (_layerPropertyLock)
|
||||
{
|
||||
@ -104,15 +109,40 @@ public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNode
|
||||
return;
|
||||
|
||||
foreach (IDataBindingProperty dataBindingRegistration in LayerProperty.BaseDataBinding.Properties)
|
||||
CreateOutputPin(dataBindingRegistration.ValueType, dataBindingRegistration.DisplayName);
|
||||
CreateOrAddOutputPin(dataBindingRegistration.ValueType, dataBindingRegistration.DisplayName);
|
||||
}
|
||||
|
||||
private void ProfileOnChildRemoved(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Creates or adds an input pin to the node using a bucket.
|
||||
/// The bucket might grow a bit over time as the user edits the node but pins won't get lost, enabling undo/redo in the
|
||||
/// editor.
|
||||
/// </summary>
|
||||
private void CreateOrAddOutputPin(Type valueType, string displayName)
|
||||
{
|
||||
if (Script.Context is not Profile profile)
|
||||
// Grab the first pin from the bucket that isn't on the node yet
|
||||
OutputPin? pin = _pinBucket.FirstOrDefault(p => !Pins.Contains(p));
|
||||
|
||||
// If there is none, create a new one and add it to the bucket
|
||||
if (pin == null)
|
||||
{
|
||||
pin = CreateOutputPin(valueType, displayName);
|
||||
_pinBucket.Add(pin);
|
||||
}
|
||||
// If there was a pin in the bucket, update it's type and display name and reuse it
|
||||
else
|
||||
{
|
||||
pin.ChangeType(valueType);
|
||||
pin.Name = displayName;
|
||||
AddPin(pin);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProfileOnChildRemoved(object? sender, EventArgs e)
|
||||
{
|
||||
if (Script?.Context is not Profile profile)
|
||||
return;
|
||||
|
||||
if (!profile.GetAllRenderElements().Contains(ProfileElement))
|
||||
if (ProfileElement == null || !profile.GetAllRenderElements().Contains(ProfileElement))
|
||||
ChangeProfileElement(null);
|
||||
}
|
||||
}
|
||||
@ -120,5 +150,5 @@ public class LayerPropertyNode : Node<LayerPropertyNodeEntity, LayerPropertyNode
|
||||
public class LayerPropertyNodeEntity
|
||||
{
|
||||
public Guid ElementId { get; set; }
|
||||
public string PropertyPath { get; set; }
|
||||
public string? PropertyPath { get; set; }
|
||||
}
|
||||
24
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomView.axaml
vendored
Normal file
24
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomView.axaml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.External.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.External.Screens.LayerPropertyNodeCustomView"
|
||||
x:DataType="screens:LayerPropertyNodeCustomViewModel">
|
||||
<Grid>
|
||||
<StackPanel Spacing="5" VerticalAlignment="Top" IsVisible="{CompiledBinding !OutsideProfileContext}">
|
||||
<ComboBox Classes="condensed" Items="{CompiledBinding ProfileElements}" SelectedItem="{CompiledBinding SelectedProfileElement}" />
|
||||
<ComboBox Classes="condensed" Items="{CompiledBinding LayerProperties}" SelectedItem="{CompiledBinding SelectedLayerProperty}" />
|
||||
</StackPanel>
|
||||
<StackPanel IsVisible="{CompiledBinding OutsideProfileContext}" VerticalAlignment="Center">
|
||||
<TextBlock Classes="BodyStrongTextBlockStyle" TextAlignment="Center">
|
||||
Node not available
|
||||
</TextBlock>
|
||||
<TextBlock Classes="BodyTextBlockStyle" Foreground="{DynamicResource TextFillColorSecondary}" TextAlignment="Center">
|
||||
This node cannot be used outside profile scripts.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
18
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomView.axaml.cs
vendored
Normal file
18
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomView.axaml.cs
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.External.Screens
|
||||
{
|
||||
public partial class LayerPropertyNodeCustomView : ReactiveUserControl<LayerPropertyNodeCustomViewModel>
|
||||
{
|
||||
public LayerPropertyNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
93
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomViewModel.cs
vendored
Normal file
93
src/Artemis.VisualScripting/Nodes/External/Screens/LayerPropertyNodeCustomViewModel.cs
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using Artemis.VisualScripting.Nodes.External.Commands;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.External.Screens;
|
||||
|
||||
public class LayerPropertyNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly LayerPropertyNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private bool _outsideProfileContext;
|
||||
|
||||
public LayerPropertyNodeCustomViewModel(LayerPropertyNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
if (_node.Script?.Context is not Profile profile)
|
||||
{
|
||||
OutsideProfileContext = true;
|
||||
return;
|
||||
}
|
||||
|
||||
OutsideProfileContext = false;
|
||||
Observable.FromEventPattern<ProfileElementEventArgs>(x => profile.DescendentAdded += x, x => profile.DescendentAdded -= x).Subscribe(_ => GetProfileElements()).DisposeWith(d);
|
||||
Observable.FromEventPattern<ProfileElementEventArgs>(x => profile.DescendentRemoved += x, x => profile.DescendentRemoved -= x).Subscribe(_ => GetProfileElements()).DisposeWith(d);
|
||||
GetProfileElements();
|
||||
GetLayerProperties();
|
||||
});
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(SelectedProfileElement));
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(SelectedLayerProperty));
|
||||
this.WhenAnyValue(vm => vm.SelectedProfileElement).Subscribe(_ => GetLayerProperties());
|
||||
}
|
||||
|
||||
public ObservableCollection<RenderProfileElement> ProfileElements { get; } = new();
|
||||
public ObservableCollection<ILayerProperty> LayerProperties { get; } = new();
|
||||
|
||||
public bool OutsideProfileContext
|
||||
{
|
||||
get => _outsideProfileContext;
|
||||
set => this.RaiseAndSetIfChanged(ref _outsideProfileContext, value);
|
||||
}
|
||||
|
||||
public RenderProfileElement? SelectedProfileElement
|
||||
{
|
||||
get => _node.ProfileElement;
|
||||
set
|
||||
{
|
||||
if (value != null && !Equals(_node.ProfileElement, value))
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateLayerPropertyNodeSelectedProfileElement(_node, value));
|
||||
}
|
||||
}
|
||||
|
||||
public ILayerProperty? SelectedLayerProperty
|
||||
{
|
||||
get => _node.LayerProperty;
|
||||
set
|
||||
{
|
||||
if (value != null && !Equals(_node.LayerProperty, value))
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateLayerPropertyNodeSelectedLayerProperty(_node, value));
|
||||
}
|
||||
}
|
||||
|
||||
private void GetProfileElements()
|
||||
{
|
||||
ProfileElements.Clear();
|
||||
if (_node.Script?.Context is not Profile profile)
|
||||
return;
|
||||
|
||||
List<RenderProfileElement> elements = new(profile.GetAllRenderElements());
|
||||
|
||||
ProfileElements.AddRange(elements.OrderBy(e => e.Order));
|
||||
SelectedProfileElement = _node.ProfileElement;
|
||||
}
|
||||
|
||||
private void GetLayerProperties()
|
||||
{
|
||||
LayerProperties.Clear();
|
||||
if (_node.ProfileElement == null)
|
||||
return;
|
||||
|
||||
LayerProperties.AddRange(_node.ProfileElement.GetAllLayerProperties().Where(l => !l.IsHidden && l.DataBindingsSupported));
|
||||
SelectedLayerProperty = _node.LayerProperty;
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,9 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Maths.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.Mathematics.Screens;
|
||||
using NoStringEvaluating.Contract;
|
||||
using NoStringEvaluating.Contract.Variables;
|
||||
using NoStringEvaluating.Models.FormulaChecker;
|
||||
using NoStringEvaluating.Models.Values;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Maths;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
[Node("Math Expression", "Outputs the result of a math expression.", "Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class MathExpressionNode : Node<string, MathExpressionNodeCustomViewModel>
|
||||
@ -119,47 +117,4 @@ public class MathExpressionNode : Node<string, MathExpressionNodeCustomViewModel
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PinsVariablesContainer : IVariablesContainer
|
||||
{
|
||||
private readonly InputPinCollection<Numeric> _values;
|
||||
|
||||
public PinsVariablesContainer(InputPinCollection<Numeric> values)
|
||||
{
|
||||
_values = values;
|
||||
}
|
||||
|
||||
#region Implementation of IVariablesContainer
|
||||
|
||||
/// <inheritdoc />
|
||||
public IVariable AddOrUpdate(string name, double value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EvaluatorValue GetValue(string name)
|
||||
{
|
||||
IPin pin = _values.FirstOrDefault(v => v.Name == name);
|
||||
if (pin?.PinValue is Numeric numeric)
|
||||
return new EvaluatorValue(numeric);
|
||||
return new EvaluatorValue(0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetValue(string name, out EvaluatorValue value)
|
||||
{
|
||||
IPin pin = _values.FirstOrDefault(v => v.Name == name);
|
||||
if (pin?.PinValue is Numeric numeric)
|
||||
{
|
||||
value = new EvaluatorValue(numeric);
|
||||
return true;
|
||||
}
|
||||
|
||||
value = new EvaluatorValue(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
using Artemis.Core;
|
||||
using NoStringEvaluating.Contract.Variables;
|
||||
using NoStringEvaluating.Models.Values;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
public class PinsVariablesContainer : IVariablesContainer
|
||||
{
|
||||
private readonly InputPinCollection<Numeric> _values;
|
||||
|
||||
public PinsVariablesContainer(InputPinCollection<Numeric> values)
|
||||
{
|
||||
_values = values;
|
||||
}
|
||||
|
||||
#region Implementation of IVariablesContainer
|
||||
|
||||
/// <inheritdoc />
|
||||
public IVariable AddOrUpdate(string name, double value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EvaluatorValue GetValue(string name)
|
||||
{
|
||||
IPin pin = _values.FirstOrDefault(v => v.Name == name);
|
||||
if (pin?.PinValue is Numeric numeric)
|
||||
return new EvaluatorValue(numeric);
|
||||
return new EvaluatorValue(0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetValue(string name, out EvaluatorValue value)
|
||||
{
|
||||
IPin pin = _values.FirstOrDefault(v => v.Name == name);
|
||||
if (pin?.PinValue is Numeric numeric)
|
||||
{
|
||||
value = new EvaluatorValue(numeric);
|
||||
return true;
|
||||
}
|
||||
|
||||
value = new EvaluatorValue(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Maths;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
[Node("Round", "Outputs a rounded numeric value.", "Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class RoundNode : Node
|
||||
@ -2,10 +2,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.Maths.CustomViewModels"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Mathematics.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Maths.CustomViews.MathExpressionNodeCustomView"
|
||||
x:DataType="customViewModels:MathExpressionNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Mathematics.Screens.MathExpressionNodeCustomView"
|
||||
x:DataType="screens:MathExpressionNodeCustomViewModel">
|
||||
<TextBox VerticalAlignment="Top"
|
||||
MinWidth="75"
|
||||
Classes="condensed"
|
||||
@ -1,9 +1,8 @@
|
||||
using Artemis.VisualScripting.Nodes.Maths.CustomViewModels;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Maths.CustomViews;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics.Screens;
|
||||
|
||||
public class MathExpressionNodeCustomView : ReactiveUserControl<MathExpressionNodeCustomViewModel>
|
||||
{
|
||||
@ -6,11 +6,9 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Validation.Components.Abstractions;
|
||||
using ReactiveUI.Validation.Extensions;
|
||||
using ReactiveUI.Validation.Helpers;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Maths.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics.Screens;
|
||||
|
||||
public class MathExpressionNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
[Node("Sum", "Sums the connected numeric values.", "Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class SumNumericsNode : Node
|
||||
34
src/Artemis.VisualScripting/Nodes/Operators/AndNode.cs
Normal file
34
src/Artemis.VisualScripting/Nodes/Operators/AndNode.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("And", "Checks if all inputs are true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class AndNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public AndNode()
|
||||
: base("And", "Checks if all inputs are true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.All(v => v);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.VisualScripting.Nodes.Operators.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Enum Equals", "Determines the equality between an input and a selected enum value", "Operators", InputType = typeof(Enum), OutputType = typeof(bool))]
|
||||
public class EnumEqualsNode : Node<Enum, EnumEqualsNodeCustomViewModel>
|
||||
{
|
||||
public EnumEqualsNode() : base("Enum Equals", "Determines the equality between an input and a selected enum value")
|
||||
{
|
||||
InputPin = CreateInputPin<Enum>();
|
||||
OutputPin = CreateOutputPin<bool>();
|
||||
|
||||
InputPin.PinConnected += InputPinOnPinConnected;
|
||||
}
|
||||
|
||||
private void InputPinOnPinConnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (Storage?.GetType() != InputPin.ConnectedTo.First().Type)
|
||||
Storage = Enum.GetValues(InputPin.ConnectedTo.First().Type).Cast<Enum>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public InputPin<Enum> InputPin { get; }
|
||||
public OutputPin<bool> OutputPin { get; }
|
||||
|
||||
#region Overrides of Node
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate()
|
||||
{
|
||||
OutputPin.Value = InputPin.Value != null && InputPin.Value.Equals(Storage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
44
src/Artemis.VisualScripting/Nodes/Operators/EqualsNode.cs
Normal file
44
src/Artemis.VisualScripting/Nodes/Operators/EqualsNode.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Equals", "Checks if the two inputs are equals.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class EqualsNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public EqualsNode()
|
||||
: base("Equals", "Checks if the two inputs are equals.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
try
|
||||
{
|
||||
Result.Value = Equals(Input1.Value, Input2.Value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Greater than", "Checks if the first input is greater than the second.", "Operators", InputType = typeof(object), OutputType = typeof(bool))]
|
||||
public class GreaterThanNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public GreaterThanNode()
|
||||
: base("Greater than", "Checks if the first input is greater than the second.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
if (Input1.Value is Numeric numeric1 && Input2.Value is Numeric numeric2)
|
||||
{
|
||||
Result.Value = numeric1 > numeric2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input2.Value != null && Input1.Value != null && Input1.Value.IsNumber() && Input2.Value.IsNumber())
|
||||
{
|
||||
Result.Value = Convert.ToSingle(Input1.Value) > Convert.ToSingle(Input2.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Result.Value = Comparer.DefaultInvariant.Compare(Input1.Value, Input2.Value) == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
57
src/Artemis.VisualScripting/Nodes/Operators/LessThanNode.cs
Normal file
57
src/Artemis.VisualScripting/Nodes/Operators/LessThanNode.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Less than", "Checks if the first input is less than the second.", "Operators", InputType = typeof(object), OutputType = typeof(bool))]
|
||||
public class LessThanNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public LessThanNode()
|
||||
: base("Less than", "Checks if the first input is less than the second.")
|
||||
{
|
||||
Input1 = CreateInputPin<object>();
|
||||
Input2 = CreateInputPin<object>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
if (Input1.Value is Numeric numeric1 && Input2.Value is Numeric numeric2)
|
||||
{
|
||||
Result.Value = numeric1 < numeric2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input2.Value != null && Input1.Value != null && Input1.Value.IsNumber() && Input2.Value.IsNumber())
|
||||
{
|
||||
Result.Value = Convert.ToSingle(Input1.Value) < Convert.ToSingle(Input2.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Result.Value = Comparer.DefaultInvariant.Compare(Input1.Value, Input2.Value) == -1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Result.Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<object> Input1 { get; }
|
||||
public InputPin<object> Input2 { get; }
|
||||
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
34
src/Artemis.VisualScripting/Nodes/Operators/NegateNode.cs
Normal file
34
src/Artemis.VisualScripting/Nodes/Operators/NegateNode.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Negate", "Negates the boolean.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class NegateNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public NegateNode()
|
||||
: base("Negate", "Negates the boolean.")
|
||||
{
|
||||
Input = CreateInputPin<bool>();
|
||||
Output = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = !Input.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPin<bool> Input { get; }
|
||||
public OutputPin<bool> Output { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
34
src/Artemis.VisualScripting/Nodes/Operators/OrNode.cs
Normal file
34
src/Artemis.VisualScripting/Nodes/Operators/OrNode.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Or", "Checks if any inputs are true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class OrNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public OrNode()
|
||||
: base("Or", "Checks if any inputs are true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.Any(v => v);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Operators.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Operators.Screens.EnumEqualsNodeCustomView"
|
||||
x:DataType="screens:EnumEqualsNodeCustomViewModel">
|
||||
<ComboBox IsEnabled="{CompiledBinding EnumValues.Count}"
|
||||
Items="{CompiledBinding EnumValues}"
|
||||
SelectedItem="{CompiledBinding CurrentValue}"
|
||||
PlaceholderText="Connect a pin..."
|
||||
Classes="condensed"
|
||||
VerticalAlignment="Center" />
|
||||
</UserControl>
|
||||
@ -0,0 +1,18 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators.Screens
|
||||
{
|
||||
public partial class EnumEqualsNodeCustomView : ReactiveUserControl<EnumEqualsNodeCustomViewModel>
|
||||
{
|
||||
public EnumEqualsNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators.Screens;
|
||||
|
||||
public class EnumEqualsNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly EnumEqualsNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public EnumEqualsNodeCustomViewModel(EnumEqualsNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
if (_node.InputPin.ConnectedTo.Any())
|
||||
{
|
||||
EnumValues.Clear();
|
||||
EnumValues.AddRange(Enum.GetValues(_node.InputPin.ConnectedTo.First().Type).Cast<Enum>());
|
||||
|
||||
this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
Observable.FromEventPattern<SingleValueEventArgs<IPin>>(x => _node.InputPin.PinConnected += x, x => _node.InputPin.PinConnected -= x)
|
||||
.Subscribe(p =>
|
||||
{
|
||||
EnumValues.AddRange(Enum.GetValues(p.EventArgs.Value.Type).Cast<Enum>());
|
||||
this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
})
|
||||
.DisposeWith(d);
|
||||
Observable.FromEventPattern<SingleValueEventArgs<IPin>>(x => _node.InputPin.PinDisconnected += x, x => _node.InputPin.PinDisconnected -= x)
|
||||
.Subscribe(_ => EnumValues.Clear())
|
||||
.DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public ObservableCollection<Enum> EnumValues { get; } = new();
|
||||
|
||||
public Enum? CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set
|
||||
{
|
||||
if (value != null && !Equals(_node.Storage, value))
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<Enum>(_node, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
34
src/Artemis.VisualScripting/Nodes/Operators/XorNode.cs
Normal file
34
src/Artemis.VisualScripting/Nodes/Operators/XorNode.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Exclusive Or", "Checks if one of the inputs is true.", "Operators", InputType = typeof(bool), OutputType = typeof(bool))]
|
||||
public class XorNode : Node
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public XorNode()
|
||||
: base("Exclusive Or", "Checks if one of the inputs is true.")
|
||||
{
|
||||
Input = CreateInputPinCollection<bool>();
|
||||
Result = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = Input.Values.Count(v => v) == 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public InputPinCollection<bool> Input { get; set; }
|
||||
public OutputPin<bool> Result { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -2,13 +2,13 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.CustomViewModels"
|
||||
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticNumericValueNodeCustomView"
|
||||
x:DataType="customViewModels:StaticNumericValueNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticNumericValueNodeCustomView"
|
||||
x:DataType="screens:StaticNumericValueNodeCustomViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:NumericConverter x:Key="NumericConverter" />
|
||||
</UserControl.Resources>
|
||||
@ -1,9 +1,7 @@
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens
|
||||
{
|
||||
public partial class StaticNumericValueNodeCustomView : ReactiveUserControl<StaticNumericValueNodeCustomViewModel>
|
||||
{
|
||||
@ -4,7 +4,7 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticNumericValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -24,24 +24,4 @@ public class StaticNumericValueNodeCustomViewModel : CustomNodeViewModel
|
||||
get => _node.Storage;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<Numeric>(_node, value ?? new Numeric()));
|
||||
}
|
||||
}
|
||||
|
||||
public class StaticStringValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticStringValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public StaticStringValueNodeCustomViewModel(StaticStringValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
public string? CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<string>(_node, value));
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.Color.CustomViewModels"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Color.CustomViews.StaticSKColorValueNodeCustomView"
|
||||
x:DataType="customViewModels:StaticSKColorValueNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticSKColorValueNodeCustomView"
|
||||
x:DataType="screens:StaticSKColorValueNodeCustomViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:SKColorToStringConverter x:Key="SKColorToStringConverter" />
|
||||
<converters:SKColorToColor2Converter x:Key="SKColorToColor2Converter" />
|
||||
@ -1,9 +1,8 @@
|
||||
using Artemis.VisualScripting.Nodes.Color.CustomViewModels;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Color.CustomViews;
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticSKColorValueNodeCustomView : ReactiveUserControl<StaticSKColorValueNodeCustomViewModel>
|
||||
{
|
||||
@ -5,7 +5,7 @@ using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Color.CustomViewModels;
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticSKColorValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
@ -2,11 +2,11 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.CustomViewModels"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticStringValueNodeCustomView"
|
||||
x:DataType="customViewModels:StaticStringValueNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticStringValueNodeCustomView"
|
||||
x:DataType="screens:StaticStringValueNodeCustomViewModel">
|
||||
<TextBox VerticalAlignment="Center" MinWidth="75" Classes="condensed">
|
||||
<Interaction.Behaviors>
|
||||
<behaviors:LostFocusTextBoxBindingBehavior Text="{CompiledBinding CurrentValue}"/>
|
||||
@ -1,9 +1,7 @@
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViews
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens
|
||||
{
|
||||
public partial class StaticStringValueNodeCustomView : ReactiveUserControl<StaticStringValueNodeCustomViewModel>
|
||||
{
|
||||
@ -0,0 +1,27 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticStringValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticStringValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public StaticStringValueNodeCustomViewModel(StaticStringValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
public string? CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<string>(_node, value));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("Numeric-Value", "Outputs a configurable static numeric value.", "Static", OutputType = typeof(Numeric))]
|
||||
public class StaticNumericValueNode : Node<Numeric, StaticNumericValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticNumericValueNode()
|
||||
: base("Numeric", "Outputs a configurable numeric value.")
|
||||
{
|
||||
Output = CreateOutputPin<Numeric>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<Numeric> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Color.CustomViewModels;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Color;
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("Color-Value", "Outputs a configurable color value.", "Static", InputType = typeof(SKColor), OutputType = typeof(SKColor))]
|
||||
public class StaticSKColorValueNode : Node<SKColor, StaticSKColorValueNodeCustomViewModel>
|
||||
@ -0,0 +1,33 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("String-Value", "Outputs a configurable static string value.", "Static", OutputType = typeof(string))]
|
||||
public class StaticStringValueNode : Node<string, StaticStringValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticStringValueNode()
|
||||
: base("String", "Outputs a configurable string value.")
|
||||
{
|
||||
Output = CreateOutputPin<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<string> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
|
||||
[Node("Numeric-Value", "Outputs a configurable static numeric value.", "Static", OutputType = typeof(Numeric))]
|
||||
public class StaticNumericValueNode : Node<Numeric, StaticNumericValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticNumericValueNode()
|
||||
: base("Numeric", "Outputs a configurable numeric value.")
|
||||
{
|
||||
Output = CreateOutputPin<Numeric>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<Numeric> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Node("String-Value", "Outputs a configurable static string value.", "Static", OutputType = typeof(string))]
|
||||
public class StaticStringValueNode : Node<string, StaticStringValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticStringValueNode()
|
||||
: base("String", "Outputs a configurable string value.")
|
||||
{
|
||||
Output = CreateOutputPin<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<string> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes;
|
||||
namespace Artemis.VisualScripting.Nodes.Text;
|
||||
|
||||
[Node("Format", "Formats the input string.", "Text", InputType = typeof(object), OutputType = typeof(string))]
|
||||
public class StringFormatNode : Node
|
||||
Loading…
x
Reference in New Issue
Block a user