- Now using the connectionhints when no connectionstype is available

- Some special treatment for Array and Dictionary Constants, kinda dirty
This commit is contained in:
Nils Hausfeld
2024-06-14 20:39:39 +02:00
parent 67f3f89bf7
commit 804e652b6d

View File

@@ -8,6 +8,7 @@ using System.Reflection;
using FlaxEditor.GUI.ContextMenu; using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.GUI.Input; using FlaxEditor.GUI.Input;
using FlaxEditor.Scripting; using FlaxEditor.Scripting;
using FlaxEditor.Surface.Archetypes;
using FlaxEngine; using FlaxEngine;
using FlaxEngine.GUI; using FlaxEngine.GUI;
using FlaxEngine.Utilities; using FlaxEngine.Utilities;
@@ -702,7 +703,7 @@ namespace FlaxEditor.Surface.ContextMenu
_surfaceStyle.GetConnectionColor(param.Type, archetype.ConnectionsHints, out typeColor); _surfaceStyle.GetConnectionColor(param.Type, archetype.ConnectionsHints, out typeColor);
if (param.IsOut) if (param.IsOut)
{ {
AddOutputElement(spriteHandle, typeColor, $"{param.Name} ({param.Type.Name})"); AddOutputElement(spriteHandle, typeColor, $">{param.Name} ({param.Type.Name})");
continue; continue;
} }
@@ -751,23 +752,48 @@ namespace FlaxEditor.Surface.ContextMenu
{ {
if (element.Type == NodeElementType.Input) if (element.Type == NodeElementType.Input)
{ {
_surfaceStyle.GetConnectionColor(element.ConnectionsType, archetype.ConnectionsHints, out typeColor); var connectionsType = element.ConnectionsType;
AddInputElement(spriteHandle, typeColor, $"{element.Text} ({element.Type.ToString()})"); _surfaceStyle.GetConnectionColor(connectionsType, archetype.ConnectionsHints, out typeColor);
if (connectionsType == null)
{
if(archetype == Archetypes.Constants.Nodes[12])
AddInputElement(spriteHandle, typeColor, $"-{element.Text} ({ConnectionsHint.Array.ToString()})");
else if (archetype == Archetypes.Constants.Nodes[13])
AddInputElement(spriteHandle, typeColor, $"-{element.Text} ({ConnectionsHint.Dictionary.ToString()})");
else
AddInputElement(spriteHandle, typeColor, $"-{element.Text} ({archetype.ConnectionsHints.ToString()})");
continue;
}
AddInputElement(spriteHandle, typeColor, $"{element.Text} ({element.ConnectionsType.Name})");
} }
else if (element.Type == NodeElementType.Output) else if (element.Type == NodeElementType.Output)
{ {
// TODO: better check for enums // TODO: better check for enums
switch (archetype.TypeID) if (archetype == Archetypes.Constants.Nodes[10])
{ {
case 11:
var t = new ScriptType(archetype.DefaultValues[0].GetType()); var t = new ScriptType(archetype.DefaultValues[0].GetType());
_surfaceStyle.GetConnectionColor(t, archetype.ConnectionsHints, out typeColor); _surfaceStyle.GetConnectionColor(t, archetype.ConnectionsHints, out typeColor);
AddOutputElement(spriteHandle, typeColor, $"{t.Name}"); AddOutputElement(spriteHandle, typeColor, $"{t.Name}");
break; }
default: else
_surfaceStyle.GetConnectionColor(element.ConnectionsType, archetype.ConnectionsHints, out typeColor); {
AddOutputElement(spriteHandle, typeColor, $"{element.Text} ({element.Type.ToString()})"); var connectionsType = element.ConnectionsType;
break; _surfaceStyle.GetConnectionColor(connectionsType, archetype.ConnectionsHints, out typeColor);
if (connectionsType == null)
{
if(archetype == Archetypes.Constants.Nodes[12])
AddOutputElement(spriteHandle, typeColor, $"-{element.Text} ({ConnectionsHint.Array.ToString()})");
else if (archetype == Archetypes.Constants.Nodes[13])
AddOutputElement(spriteHandle, typeColor, $"-{element.Text} ({ConnectionsHint.Dictionary.ToString()})");
else
AddOutputElement(spriteHandle, typeColor, $"-{element.Text} ({archetype.ConnectionsHints.ToString()})");
continue;
}
AddOutputElement(spriteHandle, typeColor, $"-{element.Text} ({connectionsType.Name})");
} }
} }
} }