Esempio n. 1
0
 public Connection(Connection.Point inPoint, Connection.Point outPoint, Action <Connection> onClickRemoveConnection, Func <List <NodeWindow> > getEvents)
 {
     this.inPoint  = inPoint;
     this.outPoint = outPoint;
     this.onClickRemoveConnection = onClickRemoveConnection;
     this.getEvents = getEvents;
 }
Esempio n. 2
0
        public NodeWindow(String baseClassName, string initialName, Vector2 position, float width,
                          GUIStyle inPointStyle,
                          GUIStyle outPointStyle, Action <Connection.Point> onClickInPoint, Action <Connection.Point> onClickOutPoint, Action <NodeWindow> onClickRemove, Action onClickGroup, Func <string, NodeWindow, string> getNewName, Func <List <NodeWindow> > getSelectedNodes, Func <List <Connection> > getSelectedConnections)
        {
            Type t = null;

            this.baseClassName          = baseClassName;
            this.onClickRemove          = onClickRemove;
            this.onClickGroup           = onClickGroup;
            this.getNewName             = getNewName;
            this.getSelectedNodes       = getSelectedNodes;
            this.getSelectedConnections = getSelectedConnections;
            this.inPointStyle           = inPointStyle;
            this.outPointStyle          = outPointStyle;
            nodeName     = initialName;
            editNodeName = nodeName;
            if (baseClassName.Contains("Event"))
            {
                t       = Type.GetType("Assets.Core.Event." + baseClassName);
                isEvent = true;
            }
            else if (baseClassName == "")
            {
                style       = (GUIStyle)"flow node 0";
                isWorkspace = true;
            }
            else //Handler
            {
                t       = Type.GetType("Assets.Core.Handler." + baseClassName);
                isEvent = false;
            }
            ResetStyle();

            if (t != null)
            {
                IDefaultParamProvider p = Activator.CreateInstance(t) as IDefaultParamProvider;
                foreach (var pair in p.GetDefaultParams())
                {
                    paramPairs.Add(pair);
                }
            }

            style.border = new RectOffset(12, 12, 12, 12);
            rect         = new Rect(position.x, position.y, width, 40f + paramPairs.Count * 20f);
            inPoint      = new Connection.Point(this, Connection.Point.Type.IN, inPointStyle, onClickInPoint);
            outPoint     = new Connection.Point(this, Connection.Point.Type.OUT, outPointStyle, onClickOutPoint);
        }
Esempio n. 3
0
        public Group(List <NodeWindow> initialNodes, List <Connection> initialConnections, string initialName, Vector2 position, float width, GUIStyle inPointStyle, GUIStyle outPointStyle,
                     Action <Connection.Point> onClickInPoint, Action <Connection.Point> onClickOutPoint, Action <NodeWindow> onClickRemove, Action onClickGroup, Func <List <NodeWindow> > getEvents, Action <Group> onClickDegroup, Action save, Func <string, NodeWindow, string> getNewName, Func <List <NodeWindow> > getSelectedNodes, Func <List <Connection> > getSelectedConnections)
            : base("", initialName, position, 200f, inPointStyle, outPointStyle, onClickInPoint, onClickOutPoint, onClickRemove, onClickGroup, getNewName, getSelectedNodes, getSelectedConnections)
        {
            this.nodes          = initialNodes;
            this.connections    = initialConnections;
            this.getNewName     = getNewName;
            this.save           = save;
            this.isWorkspace    = true;
            this.getEvents      = getEvents;
            this.onClickDegroup = onClickDegroup;
            foreach (var c in connections)
            {
                c.onClickRemoveConnection = null;
            }
            foreach (var n in nodes)
            {
                n.inPoint.onClickConnectionPoint  = null;
                n.outPoint.onClickConnectionPoint = null;
                n.style         = (GUIStyle)"VCS_StickyNote";
                n.selectedStyle = (GUIStyle)"VCS_StickyNote";
            }
            if (initialName.Count() != 0)
            {
                float minX = initialNodes.Aggregate(float.MaxValue, (acc, n) => Math.Min(acc, n.rect.xMin));
                float minY = initialNodes.Aggregate(float.MaxValue, (acc, n) => Math.Min(acc, n.rect.yMin));
                float maxX = initialNodes.Aggregate(float.MinValue, (acc, n) => Math.Max(acc, n.rect.xMax));
                float maxY = initialNodes.Aggregate(float.MinValue, (acc, n) => Math.Max(acc, n.rect.yMax));
                float w    = Math.Abs(minX - maxX);
                float h    = Math.Abs(minY - maxY);
                startPoint = new Connection.GroupPoint(this, Connection.Point.Type.OUT, new GUIStyle(), (_) => { });
                endPoint   = new Connection.GroupPoint(this, Connection.Point.Type.IN, new GUIStyle(), (_) => { });

                rect = new Rect(minX - initialPaddingX, minY - initialPaddingY, w + 2 * initialPaddingX, h + 2 * initialPaddingY);
            }
            var emptyStartPoint = nodes.Find(n => !connections.Any(c => c.inPoint == n.inPoint)).inPoint;
            var emptyEndPoint   = nodes.Find(n => !connections.Any(c => c.outPoint == n.outPoint)).outPoint;

            connections.Add(new Connection(emptyStartPoint, startPoint, null, null));
            connections.Add(new Connection(endPoint, emptyEndPoint, null, null));
            Debug.Log(connections.Count);
        }