private void MainScriptingPanel_MouseClick(object sender, MouseEventArgs e) //Show node search bar { if (e.Button == MouseButtons.Right) { if (createNodeSearchBar != null) { createNodeSearchBar.Dispose(); } createNodeSearchBar = new CreateNodeSearchBar(e.Location, this); MainScriptingPanel.Controls.Add(createNodeSearchBar); createNodeSearchBar.partPressed += SpawnNode; firstSelectedNode = null; firstSelectedPin = null; } else { firstSelectedNode = null; firstSelectedPin = null; if (createNodeSearchBar != null) { createNodeSearchBar.Dispose(); } createNodeSearchBar = null; } MainScriptingPanel.Refresh(); }
private void Form1_Load(object sender, EventArgs e) { currentNodes = new List <BaseNode>(); visualVariables = new List <VisualVariable>() { new VisualVariable(typeof(bool), "Naujas") }; firstSelectedPin = null; firstSelectedNode = null; SpawnNode(new Point(50, 50), typeof(ConstructNode)); }
protected void SetupAllPins(List <Type> _inputs, List <Type> _outputs) { this.BackColor = Color.LightGray; nodeLabel = new Label(); this.Controls.Add(nodeLabel); nodeLabel.Location = new Point(0, 0); nodeLabel.Size = new Size(this.Size.Width, 13); nodeLabel.Text = this.GetType().GetField("nodeName").GetValue(null).ToString(); inputPins = new List <BasePin>(); outputPins = new List <BasePin>(); for (int i = 0; i < _inputs.Count; i++) { BasePin newPin; if (_inputs[i] == typeof(ExecutionPin)) { //newPin = new ExecutionPin(PinRole.Input, this); newPin = new BasePin(_inputs[i], PinRole.Input, this); } else { newPin = new BasePin(_inputs[i], PinRole.Input, this); } this.Controls.Add(newPin); newPin.Location = new Point(0, i * 12 + 13); inputPins.Add(newPin); //newPin.Click += PinClicked; } for (int i = 0; i < _outputs.Count; i++) { BasePin newPin; if (_outputs[i] == typeof(ExecutionPin)) { //newPin = new ExecutionPin(PinRole.Output, this); newPin = new BasePin(_outputs[i], PinRole.Output, this); } else { newPin = new BasePin(_outputs[i], PinRole.Output, this); } this.Controls.Add(newPin); newPin.Location = new Point(this.Size.Width - 10, i * 12 + 13); outputPins.Add(newPin); //newPin.Click += PinClicked; } }
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(); }
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(); }
public BasePin(Type _pinType, PinRole _pinRole, BaseNode _parentNode = null) //Fix this _parentNode stuff { otherConnectedPin = null; pinType = _pinType; pinRole = _pinRole; parentNode = _parentNode; this.Size = new Size(10, 10); Console.Out.WriteLine(pinType); this.BackColor = GetPinColor(pinType); this.Click += BasePinClick; }
void PinPressed(BasePin _pinPressed) { if (firstSelectedPin == null) { firstSelectedPin = _pinPressed; } else { if (_pinPressed.pinType == firstSelectedPin.pinType && _pinPressed.pinRole != firstSelectedPin.pinRole) { _pinPressed.otherConnectedPin = firstSelectedPin; firstSelectedPin.otherConnectedPin = _pinPressed; firstSelectedPin = null; MainScriptingPanel.Refresh(); } } }
public override void MainScriptingPanel_Paint(object sender, PaintEventArgs e) //Paint connections between pins { Graphics g; g = form.MainScriptingPanel.CreateGraphics(); Pen myPen = new Pen(BasePin.GetPinColor(typeof(ExecutionPin))); myPen.Width = 2; foreach (BaseNodePanel n in currentNodesPanels) //Painting lines { if (n.inputPins != null) { foreach (BasePin p in n.inputPins) //Paint from input { if (p.visualPin.otherConnectedPin != null) { myPen.Color = BasePin.GetPinColor(p.visualPin.pinType); Point pLoc = form.MainScriptingPanel.PointToClient(n.PointToScreen(p.Location)); Console.Out.WriteLine(p.visualPin.otherConnectedPin.visualNode.baseNodePanel + " aaaaaaa"); Point oLoc = form.MainScriptingPanel.PointToClient(p.visualPin.otherConnectedPin.visualNode.baseNodePanel.PointToScreen(p.visualPin.otherConnectedPin.basePin.Location)); g.DrawLine(myPen, pLoc.X, pLoc.Y, oLoc.X, oLoc.Y); } } } } if (firstSelectedPin != null) //Draw line if second pin not selected { myPen.Color = BasePin.GetPinColor(firstSelectedPin.visualPin.pinType); Point pLoc = form.MainScriptingPanel.PointToClient(firstSelectedPin.Parent.PointToScreen(firstSelectedPin.Location)); Point mLoc = form.MainScriptingPanel.PointToClient(Control.MousePosition); g.DrawLine(myPen, pLoc.X, pLoc.Y, mLoc.X, mLoc.Y); } if (firstSelectedNode != null) //Moving node { firstSelectedNode.Location = form.MainScriptingPanel.PointToClient(Control.MousePosition) + firstSelectedNodeOffset; } g.Dispose(); myPen.Dispose(); }
public VisualVariablePanel(VisualVariable _visualVariable) { if (_visualVariable != null) { visualVariable = _visualVariable; this.BackColor = Color.White; this.Size = new Size(200, 10); nameLabel = new Label(); this.Controls.Add(nameLabel); nameLabel.Location = new Point(0, 0); nameLabel.Size = new Size(190, 20); nameLabel.Text = visualVariable.variableName; outputPin = new BasePin(visualVariable.variableType, PinRole.Output); //Add parent here this.Controls.Add(outputPin); outputPin.Location = new Point(190, 0); } else { throw new Exception("Null variable created"); } }
private void PinClicked(BasePin _pinPressed) { pinPressed(_pinPressed); }
protected void SetupAllPins(List <VisualNodeC> _inputs, List <VisualNodeC> _outputs) { this.MouseDown += mouseDown; this.MouseUp += mouseUp; this.MouseMove += mouseMove; this.BackColor = Color.LightGray; nodeLabel = new Label(); this.Controls.Add(nodeLabel); nodeLabel.Location = new Point(0, 0); nodeLabel.Size = new Size(this.Size.Width, 13); nodeLabel.Text = visualNode.GetType().GetField("nodeName").GetValue(null).ToString(); nodeLabel.MouseDown += mouseDown; nodeLabel.MouseUp += mouseUp; nodeLabel.MouseMove += mouseMove; inputPins = new List <BasePin>(); outputPins = new List <BasePin>(); for (int i = 0; i < _inputs.Count; i++) { VisualPin newVisualPin = new VisualPin(PinRole.Input, _inputs[i].type, _inputs[i].isVariable, _inputs[i].pinName); visualNode.visualInputs.Add(newVisualPin); BasePin newPin = new BasePin(visualNode.visualInputs[i], this); /* * if (_inputs[i].pinType == typeof(ExecutionPin)) * { * //newPin = new ExecutionPin(PinRole.Input, this); * newPin = new BasePin(_inputs[i], PinRole.Input, this); * } * else * { * newPin = new BasePin(_inputs[i], PinRole.Input, this); * } */ this.Controls.Add(newPin); newPin.Location = new Point(0, i * 12 + 13); inputPins.Add(newPin); newPin.visualPin.visualNode = visualNode; visualNode.visualInputs[i].basePin = newPin; newPin.MouseMove += mouseMove; newPin.pinPressed += PinClicked; } for (int i = 0; i < _outputs.Count; i++) { VisualPin newVisualPin = new VisualPin(PinRole.Output, _outputs[i].type, _outputs[i].isVariable, _outputs[i].pinName); visualNode.visualOutputs.Add(newVisualPin); BasePin newPin = new BasePin(visualNode.visualOutputs[i], this); /* * if (_outputs[i] == typeof(ExecutionPin)) * { * newPin = new BasePin(_outputs[i], PinRole.Output, this); * } * else * { * newPin = new BasePin(_outputs[i], PinRole.Output, this); * } */ this.Controls.Add(newPin); newPin.Location = new Point(this.Size.Width - 23, i * 12 + 13); outputPins.Add(newPin); newPin.visualPin.visualNode = visualNode; visualNode.visualOutputs[i].basePin = newPin; newPin.MouseMove += mouseMove; newPin.pinPressed += PinClicked; } }
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(); }
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(); }