Example #1
0
        public VisualClassScriptEditorManager(Form1 _form, VisualClass _visualClass) : base(_form)
        {
            visualClass = _visualClass;

            currentNodesPanels      = new List <BaseNodePanel>();
            firstSelectedPin        = null;
            firstSelectedNode       = null;
            firstSelectedVariable   = null;
            firstSelectedFunction   = null;
            firstSelectedNodeOffset = new Size(0, 0);
            SpawnNode(new Point(50, 50), new VisualNodeCreatePanelPart(typeof(ConstructNode))); //Spawns construct node

            UpdateVariableAndFunctionPanel();
        }
Example #2
0
        public VisualFunctionScriptEditorManager(Form1 _form, VisualFunction _visualFunction) : base(_form)
        {
            visualFunction = _visualFunction;

            currentNodesPanels      = new List <BaseNodePanel>();
            firstSelectedPin        = null;
            firstSelectedNode       = null;
            firstSelectedVariable   = null;
            firstSelectedFunction   = null;
            firstSelectedNodeOffset = new Size(0, 0);
            SpawnNode(new Point(50, 50), new VisualNodeCreatePanelPart(typeof(FunctionStartNode)));
            SpawnNode(new Point(200, 200), new VisualNodeCreatePanelPart(typeof(FunctionEndNode))); //Spawns starting nodes

            UpdateVariableAndFunctionPanel();
        }
Example #3
0
        public BasePin(VisualPin _visualPin, BaseNodePanel _parentNode = null) //Fix this _parentNode stuff
        {
            visualPin  = _visualPin;
            parentNode = _parentNode;

            this.Size = new Size(23, 10);

            actualPinPanel = new Panel();
            this.Controls.Add(actualPinPanel);
            actualPinPanel.Size = new Size(10, 10);

            switch (visualPin.pinRole)
            {
            case PinRole.Input:
                actualPinPanel.Location = new Point(0, 0);
                break;

            case PinRole.Output:
                actualPinPanel.Location = new Point(this.Size.Width - 10, 0);
                break;
            }
            actualPinPanel.BackColor = GetPinColor(visualPin.pinType);
            actualPinPanel.Click    += BasePinClick;

            pinText = new Label();
            this.Controls.Add(pinText);
            pinText.Size = new Size(13, 10);

            switch (visualPin.pinRole)
            {
            case PinRole.Input:
                pinText.Location = new Point(this.Size.Width - 13, 0);
                break;

            case PinRole.Output:
                pinText.Location = new Point(0, 0);
                break;
            }
            pinText.Font = new Font("Arial", 4, FontStyle.Bold);
            pinText.Text = visualPin.pinName;
        }
Example #4
0
        public override void MainScriptingPanelMouseClick(object sender, EventArgs e)
        {
            MouseEventArgs r = (MouseEventArgs)e;

            if (r.Button == MouseButtons.Right)
            {
                if (createNodeSearchBar != null)
                {
                    createNodeSearchBar.Dispose();
                }

                if (firstSelectedPin == null) //Pin not selected
                {
                    createNodeSearchBar = new CreateNodeSearchBar(r.Location, allNodesToShow, visualFunction.visualVariables, new List <VisualFunction>());
                }
                else  //Pin selected
                {
                    List <Type>           newNodesToShow     = new List <Type>();
                    List <VisualVariable> newVariablesToShow = new List <VisualVariable>();
                    List <VisualFunction> newFunctionsToShow = new List <VisualFunction>();

                    if (firstSelectedPin.visualPin.pinRole == PinRole.Input) //Selected Input
                    {
                        foreach (Type t in allNodesToShow)
                        {
                            List <VisualNodeC> outputs = (List <VisualNodeC>)t.GetField("outputs").GetValue(null);
                            foreach (VisualNodeC pin in outputs)
                            {
                                if (pin.type == firstSelectedPin.visualPin.pinType)
                                {
                                    newNodesToShow.Add(t);
                                    break;
                                }
                            }
                        }
                        foreach (VisualVariable v in visualFunction.visualVariables)
                        {
                            if (v.variableType == firstSelectedPin.visualPin.pinType)
                            {
                                newVariablesToShow.Add(v);
                            }
                        }
                    }
                    else //Selected Output
                    {
                        foreach (Type t in allNodesToShow)
                        {
                            List <VisualNodeC> inputs = (List <VisualNodeC>)t.GetField("inputs").GetValue(null);
                            foreach (VisualNodeC pin in inputs)
                            {
                                if (pin.type == firstSelectedPin.visualPin.pinType)
                                {
                                    newNodesToShow.Add(t);
                                    break;
                                }
                            }
                        }
                    }
                    createNodeSearchBar = new CreateNodeSearchBar(r.Location, newNodesToShow, newVariablesToShow, newFunctionsToShow);
                }
                form.MainScriptingPanel.Controls.Add(createNodeSearchBar);
                createNodeSearchBar.partPressed += SpawnNode;

                firstSelectedNode = null;
            }
            else
            {
                firstSelectedNode = null;
                firstSelectedPin  = null;

                if (createNodeSearchBar != null)
                {
                    createNodeSearchBar.Dispose();
                }
                createNodeSearchBar = null;
            }

            ClearVariableFunctionInfoPanel();
            firstSelectedVariable = null;
            firstSelectedFunction = null;

            form.MainScriptingPanel.Refresh();
        }
Example #5
0
 public void StartMovingNode(BaseNodePanel _senderNode, MouseEventArgs e) //Start moving node
 {
     firstSelectedNode       = _senderNode;
     firstSelectedNodeOffset = new Size(e.Location.X * -1, e.Location.Y * -1);
     form.MainScriptingPanel.Refresh();
 }
Example #6
0
 public void StopMovingNode(BaseNodePanel _senderNode, MouseEventArgs e) //Stop moving node
 {
     firstSelectedNode = null;
     form.MainScriptingPanel.Refresh();
 }
Example #7
0
        public void SpawnNode(Point _position, BaseCreateNodePanelPart _panel) //Spawn node
        {
            BaseNodePanel newNodePanel = null;

            var CheckNode     = _panel as VisualNodeCreatePanelPart;
            var CheckVariable = _panel as VisualVariableCreatePanelPart;
            var CheckFunction = _panel as VisualFunctionCreatePanelPart;

            if (CheckNode != null) //Node selected
            {
                VisualNodeCreatePanelPart node = (VisualNodeCreatePanelPart)_panel;
                VisualNode newNode             = (VisualNode)Activator.CreateInstance(node.nodeType);
                newNodePanel            = new BaseNodePanel(newNode);
                newNodePanel.visualNode = newNode;
                newNode.baseNodePanel   = newNodePanel;
                visualFunction.visualNodes.Add(newNode);
            }
            else if (CheckVariable != null) //variable selected
            {
                VisualVariableCreatePanelPart variablePanel = (VisualVariableCreatePanelPart)_panel;
                VisualVariableNodePanel       node          = new VisualVariableNodePanel(new VisualNode(), variablePanel.visualVariable);
                newNodePanel = new VisualVariableNodePanel(variablePanel.visualVariable, variablePanel.visualVariable);
                variablePanel.visualVariable.baseNodePanel = newNodePanel;
            }
            else if (CheckFunction != null)
            {
                VisualFunctionCreatePanelPart functionPanel = (VisualFunctionCreatePanelPart)_panel;
                VisualFunctionNodePanel       node          = new VisualFunctionNodePanel(new VisualNode(), functionPanel.visualFunction);
                newNodePanel = new VisualFunctionNodePanel(functionPanel.visualFunction, functionPanel.visualFunction);
                functionPanel.visualFunction.baseNodePanel = newNodePanel;
            }

            form.MainScriptingPanel.Controls.Add(newNodePanel);
            newNodePanel.Location = _position;

            currentNodesPanels.Add(newNodePanel);
            newNodePanel.myMouseDown += StartMovingNode;
            newNodePanel.myMouseUp   += StopMovingNode;
            newNodePanel.myMouseMove += MainScriptingPanel_MouseMove;

            newNodePanel.pinPressed += PinPressed;

            if (createNodeSearchBar != null)
            {
                createNodeSearchBar.Dispose();
            }

            if (firstSelectedPin != null)
            {
                if (firstSelectedPin.visualPin.pinRole == PinRole.Input) //Selected input
                {
                    foreach (VisualPin p in newNodePanel.visualNode.visualOutputs)
                    {
                        if (p.pinType == firstSelectedPin.visualPin.pinType)
                        {
                            p.otherConnectedPin = firstSelectedPin.visualPin;
                            firstSelectedPin.visualPin.otherConnectedPin = p;
                            firstSelectedPin = null;
                            break;
                        }
                    }
                }
                else //Selected output
                {
                    foreach (VisualPin p in newNodePanel.visualNode.visualInputs)
                    {
                        if (p.pinType == firstSelectedPin.visualPin.pinType)
                        {
                            p.otherConnectedPin = firstSelectedPin.visualPin;
                            firstSelectedPin.visualPin.otherConnectedPin = p;
                            firstSelectedPin = null;
                            break;
                        }
                    }
                }
            }
            form.MainScriptingPanel.Refresh();
        }