mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Nodes - Added help URL and help button
This commit is contained in:
1 parent
ba45bdd99d
commit
7ada77f5e3
6 files changed
+68
-10
No files matched your search
@@ -75,8 +75,9 @@ internal class NodeService : INodeService
|
||||
string name = nodeAttribute?.Name ?? nodeType.Name;
|
||||
string description = nodeAttribute?.Description ?? string.Empty;
|
||||
string category = nodeAttribute?.Category ?? string.Empty;
|
||||
|
||||
NodeData nodeData = new(plugin, nodeType, name, description, category, nodeAttribute?.InputType, nodeAttribute?.OutputType, (s, e) => CreateNode(s, e, nodeType));
|
||||
string helpUrl = nodeAttribute?.HelpUrl ?? string.Empty;
|
||||
|
||||
NodeData nodeData = new(plugin, nodeType, name, description, category, helpUrl, nodeAttribute?.InputType, nodeAttribute?.OutputType, (s, e) => CreateNode(s, e, nodeType));
|
||||
return NodeTypeStore.Add(nodeData);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ public interface INode : INotifyPropertyChanged, IBreakableModel
|
||||
/// <summary>
|
||||
/// Gets the name of the node
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of the node
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the node is the exit node of the script
|
||||
@@ -44,6 +44,11 @@ public interface INode : INotifyPropertyChanged, IBreakableModel
|
||||
/// Gets or sets the Y-position of the node
|
||||
/// </summary>
|
||||
public double Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the help URL of the node
|
||||
/// </summary>
|
||||
string HelpUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only collection of the pins on this node
|
||||
|
||||
@@ -24,6 +24,11 @@ public class NodeAttribute : Attribute
|
||||
/// </summary>
|
||||
public string Category { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the help URL of the node
|
||||
/// </summary>
|
||||
public string HelpUrl { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the primary input type of the node
|
||||
/// </summary>
|
||||
@@ -65,5 +70,16 @@ public class NodeAttribute : Attribute
|
||||
Category = category;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="NodeAttribute" /> class
|
||||
/// </summary>
|
||||
public NodeAttribute(string name, string description, string category, string helpUrl)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
Category = category;
|
||||
HelpUrl = helpUrl;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
using Castle.Core.Internal;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
@@ -10,13 +11,14 @@ public class NodeData
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
internal NodeData(Plugin plugin, Type type, string name, string description, string category, Type? inputType, Type? outputType, Func<INodeScript, NodeEntity?, INode> create)
|
||||
internal NodeData(Plugin plugin, Type type, string name, string description, string category, string helpUrl, Type? inputType, Type? outputType, Func<INodeScript, NodeEntity?, INode> create)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Type = type;
|
||||
Name = name;
|
||||
Description = description;
|
||||
Category = category;
|
||||
HelpUrl = helpUrl;
|
||||
InputType = inputType;
|
||||
OutputType = outputType;
|
||||
_create = create;
|
||||
@@ -34,7 +36,15 @@ public class NodeData
|
||||
/// <returns>The returning node of type <see cref="Type" /></returns>
|
||||
public INode CreateNode(INodeScript script, NodeEntity? entity)
|
||||
{
|
||||
return _create(script, entity);
|
||||
INode node = _create(script, entity);
|
||||
if (string.IsNullOrWhiteSpace(node.Name))
|
||||
node.Name = Name;
|
||||
if (string.IsNullOrWhiteSpace(node.Description))
|
||||
node.Description = Description;
|
||||
if (string.IsNullOrWhiteSpace(node.HelpUrl))
|
||||
node.HelpUrl = HelpUrl;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -101,6 +111,11 @@ public class NodeData
|
||||
/// </summary>
|
||||
public string Category { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the help URL of the node this data represents
|
||||
/// </summary>
|
||||
public string HelpUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the primary input type of the node this data represents
|
||||
/// </summary>
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class Node : BreakableModel, INode
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
protected set => SetAndNotify(ref _name, value);
|
||||
set => SetAndNotify(ref _name, value);
|
||||
}
|
||||
|
||||
private string _description;
|
||||
@@ -55,7 +55,7 @@ public abstract class Node : BreakableModel, INode
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
protected set => SetAndNotify(ref _description, value);
|
||||
set => SetAndNotify(ref _description, value);
|
||||
}
|
||||
|
||||
private double _x;
|
||||
@@ -76,6 +76,13 @@ public abstract class Node : BreakableModel, INode
|
||||
set => SetAndNotify(ref _y, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string HelpUrl
|
||||
{
|
||||
get => _helpUrl;
|
||||
set => SetAndNotify(ref _helpUrl, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual bool IsExitNode => false;
|
||||
|
||||
@@ -88,6 +95,7 @@ public abstract class Node : BreakableModel, INode
|
||||
public IReadOnlyCollection<IPin> Pins => new ReadOnlyCollection<IPin>(_pins);
|
||||
|
||||
private readonly List<IPinCollection> _pinCollections = new();
|
||||
private string _helpUrl;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<IPinCollection> PinCollections => new ReadOnlyCollection<IPinCollection>(_pinCollections);
|
||||
@@ -106,6 +114,7 @@ public abstract class Node : BreakableModel, INode
|
||||
{
|
||||
_name = string.Empty;
|
||||
_description = string.Empty;
|
||||
_helpUrl = string.Empty;
|
||||
_id = Guid.NewGuid();
|
||||
}
|
||||
|
||||
@@ -116,6 +125,7 @@ public abstract class Node : BreakableModel, INode
|
||||
{
|
||||
_name = name;
|
||||
_description = description;
|
||||
_helpUrl = string.Empty;
|
||||
_id = Guid.NewGuid();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user