mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Nodes - Fixed some connections not saving on dynamic incoming pins
Nodes - Fixed undo/redo when deleting a node with dynamic incoming pins Nodes - Disabled layer property node for now until I have time to finish it
This commit is contained in:
parent
c45e879eef
commit
30be7a9915
@ -341,8 +341,14 @@ public abstract class NodeScript : CorePropertyChanged, INodeScript, IStorageMod
|
||||
private void SavePins(INode node, int collectionId, IEnumerable<IPin> pins)
|
||||
{
|
||||
int sourcePinId = 0;
|
||||
foreach (IPin sourcePin in pins.Where(p => p.Direction == PinDirection.Input))
|
||||
foreach (IPin sourcePin in pins)
|
||||
{
|
||||
if (sourcePin.Direction == PinDirection.Output)
|
||||
{
|
||||
sourcePinId++;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (IPin targetPin in sourcePin.ConnectedTo)
|
||||
{
|
||||
int targetPinCollectionId = -1;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.NodeEditor;
|
||||
@ -30,20 +31,18 @@ public class NodeConnectionStore
|
||||
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)
|
||||
{
|
||||
// Iterate to save
|
||||
foreach (IPin nodePin in Node.Pins.ToList())
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
foreach (IPin nodePin in Node.PinCollections.ToList().SelectMany(nodePinCollection => nodePinCollection))
|
||||
_pinConnections.Add(nodePin, new List<IPin>(nodePin.ConnectedTo));
|
||||
|
||||
// Iterate to disconnect
|
||||
foreach (IPin nodePin in Node.Pins.ToList())
|
||||
nodePin.DisconnectAll();
|
||||
foreach (IPin nodePin in Node.PinCollections.ToList().SelectMany(nodePinCollection => nodePinCollection))
|
||||
nodePin.DisconnectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -51,23 +50,10 @@ public class NodeConnectionStore
|
||||
/// </summary>
|
||||
public void Restore()
|
||||
{
|
||||
foreach (IPin nodePin in Node.Pins)
|
||||
foreach ((IPin? pin, List<IPin>? connections) in _pinConnections)
|
||||
{
|
||||
if (!_pinConnections.TryGetValue(nodePin, out List<IPin>? connections))
|
||||
continue;
|
||||
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))
|
||||
continue;
|
||||
foreach (IPin connection in connections)
|
||||
nodePin.ConnectTo(connection);
|
||||
}
|
||||
pin.ConnectTo(connection);
|
||||
}
|
||||
|
||||
_pinConnections.Clear();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Controllers;
|
||||
@ -106,6 +107,9 @@ public class RegistrationService : IRegistrationService
|
||||
_nodeService.RegisterTypeColor(Constants.CorePlugin, typeof(Enum), new SKColor(0xFF1E90FF));
|
||||
|
||||
foreach (Type nodeType in typeof(SumNumericsNode).Assembly.GetTypes().Where(t => typeof(INode).IsAssignableFrom(t) && t.IsPublic && !t.IsAbstract && !t.IsInterface))
|
||||
{
|
||||
if (nodeType.GetCustomAttribute(typeof(NodeAttribute)) != null)
|
||||
_nodeService.RegisterNodeType(Constants.CorePlugin, nodeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ using Artemis.VisualScripting.Nodes.External.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.External;
|
||||
|
||||
[Node("Layer/Folder Property", "Outputs the property of a selected layer or folder", "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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user