Example #1
0
 private static NodeArchetype Op1(ushort id, string title, string desc, ConnectionsHint hints = ConnectionsHint.Numeric, Type type = null)
 {
     return(new NodeArchetype
     {
         TypeID = id,
         Title = title,
         Description = desc,
         Flags = NodeFlags.AllGraphs,
         Size = new Vector2(110, 20),
         DefaultType = new ScriptType(type),
         ConnectionsHints = hints,
         IndependentBoxes = new[] { 0 },
         DependentBoxes = new[] { 1 },
         Elements = new[]
         {
             NodeElementArchetype.Factory.Input(0, "A", true, type, 0),
             NodeElementArchetype.Factory.Output(0, "Result", type, 1)
         }
     });
 }
Example #2
0
 /// <summary>
 /// Gets the color for the connection.
 /// </summary>
 /// <param name="type">The connection type.</param>
 /// <param name="hint">The connection hint.</param>
 /// <param name="color">The color.</param>
 public void GetConnectionColor(ScriptType type, ConnectionsHint hint, out Color color)
 {
     if (type == ScriptType.Null)
     {
         color = Colors.Default;
     }
     else if (type.IsPointer || type.IsReference)
     {
         // Find underlying type without `*` or `&`
         var typeName = type.TypeName;
         type = TypeUtils.GetType(typeName.Substring(0, typeName.Length - 1));
         GetConnectionColor(type, hint, out color);
     }
     else if (type.IsArray)
     {
         GetConnectionColor(new ScriptType(type.GetElementType()), hint, out color);
     }
     else if (type.Type == typeof(void))
     {
         color = Colors.Impulse;
     }
     else if (type.Type == typeof(bool))
     {
         color = Colors.Bool;
     }
     else if (type.Type == typeof(byte) || type.Type == typeof(sbyte) || type.Type == typeof(char) || type.Type == typeof(short) || type.Type == typeof(ushort) || type.Type == typeof(int) || type.Type == typeof(uint) || type.Type == typeof(long) || type.Type == typeof(ulong))
     {
         color = Colors.Integer;
     }
     else if (type.Type == typeof(float) || type.Type == typeof(double) || hint == ConnectionsHint.Scalar)
     {
         color = Colors.Float;
     }
     else if (type.Type == typeof(Vector2) || type.Type == typeof(Vector3) || type.Type == typeof(Vector4) || type.Type == typeof(Color))
     {
         color = Colors.Vector;
     }
     else if (type.Type == typeof(string))
     {
         color = Colors.String;
     }
     else if (type.Type == typeof(Quaternion))
     {
         color = Colors.Rotation;
     }
     else if (type.Type == typeof(Transform))
     {
         color = Colors.Transform;
     }
     else if (type.Type == typeof(BoundingBox) || type.Type == typeof(BoundingSphere) || type.Type == typeof(BoundingFrustum))
     {
         color = Colors.Bounds;
     }
     else if (type.IsEnum || hint == ConnectionsHint.Enum)
     {
         color = Colors.Enum;
     }
     else if (type.IsValueType)
     {
         color = Colors.Structures;
     }
     else if (new ScriptType(typeof(FlaxEngine.Object)).IsAssignableFrom(type) || type.IsInterface)
     {
         color = Colors.Object;
     }
     else if (hint == ConnectionsHint.Vector)
     {
         color = Colors.Vector;
     }
     else
     {
         color = Colors.Default;
     }
 }
Example #3
0
 private static NodeArchetype Op2(ushort id, string title, string desc, string[] altTitles, ConnectionsHint hints = ConnectionsHint.Numeric, Type inputType = null, Type outputType = null, bool isOutputDependant = true, object[] defaultValues = null)
 {
     return(new NodeArchetype
     {
         TypeID = id,
         Title = title,
         Description = desc,
         Flags = NodeFlags.AllGraphs,
         AlternativeTitles = altTitles,
         Size = new Vector2(110, 40),
         DefaultType = new ScriptType(inputType),
         ConnectionsHints = hints,
         IndependentBoxes = new[]
         {
             0,
             1
         },
         DependentBoxes = isOutputDependant ? new[] { 2 } : null,
         DefaultValues = defaultValues ?? new object[]
         {
             0.0f,
             0.0f,
         },
         Elements = new[]
         {
             NodeElementArchetype.Factory.Input(0, "A", true, inputType, 0, 0),
             NodeElementArchetype.Factory.Input(1, "B", true, inputType, 1, 1),
             NodeElementArchetype.Factory.Output(0, "Result", outputType, 2)
         }
     });
 }
Example #4
0
 private static NodeArchetype Op2(ushort id, string title, string desc, ConnectionsHint hints = ConnectionsHint.Numeric, Type inputType = null, Type outputType = null, bool isOutputDependant = true, object[] defaultValues = null)
 {
     return(Op2(id, title, desc, null, hints, inputType, outputType, isOutputDependant, defaultValues));
 }