private void OnConnectionPointSelected(NodePresenter nodePresenter, PortPresenter portPresenter) { if (_selectedNodePresenter != null && _selectedNodePresenter.Id != nodePresenter.Id) { var selectedConnectionPointPresenter = _selectedPointPresenter; var connectionBetweenNodes = new LinkPresenter(new LinkView(), new LinkData()); connectionBetweenNodes.SetFrom(selectedConnectionPointPresenter, _selectedNodePresenter.Id); connectionBetweenNodes.SetTo(portPresenter, nodePresenter.Id); _selectedNodePresenter.AddNextNode(nodePresenter); _connectionPresenters.Add(connectionBetweenNodes); _vntData.AddConnectionData(connectionBetweenNodes.LinkData); _selectedNodePresenter = null; return; } _selectedNodePresenter = nodePresenter; _selectedPointPresenter = portPresenter; }
public DialogueNodePresenter(DialogueNodeView nodeView, DialogueNodeData nodeData, PortPresenter portPresenter, PortPresenter portOutPresenter) : base(nodeView, nodeData, portPresenter, portOutPresenter) { _nodeView = nodeView; _nodeData = nodeData; _nodeView.Clicked += NodeViewOnClicked; }
private void OnDialogueMenuItemClicked(Vector2 mousePosition) { var nodeView = new DialogueNodeView(LocalizationStrings.DialogueNode, mousePosition); var connectionPointInPresenter = new PortPresenter(new PortView(PortType.In)); var connectionPointOutPresenter = new PortPresenter(new PortView(PortType.Out)); var go = new GameObject(LocalizationStrings.DialogueNode); var nodeData = go.AddComponent <DialogueNodeData>(); var nodePresenter = new DialogueNodePresenter(nodeView, nodeData, connectionPointInPresenter, connectionPointOutPresenter); nodePresenter.ConnectionPointSelected += OnConnectionPointSelected; nodePresenter.ConnectionPointUnSelected += OnConnectionPointUnSelected; _nodePresenters.Add(nodePresenter); _vntData.AddNodeData(nodePresenter.NodeData); }
protected NodePresenter(INodeView nodeView, NodeData nodeData, PortPresenter portPresenter, PortPresenter portOutPresenter) { _nodeView = nodeView; NodeData = nodeData; Port = portPresenter; PortOut = portOutPresenter; _nodeView.MouseClicked += OnMouseClicked; _nodeView.Selected += OnSelected; Port.Selected += ConnectionPointInPresenterOnSelected; PortOut.Selected += ConnectionPointOutPresenterOnSelected; Port.UnSelected += ConnectionPointInPresenterOnUnSelected; PortOut.UnSelected += ConnectionPointOutPresenterOnUnSelected; Id = Guid.NewGuid(); }
private void DrawToolPanel() { var createNewButton = new ToolPanelButton("Create"); var loadButton = new ToolPanelButton("Load"); var saveButton = new ToolPanelButton("Save"); createNewButton.Clicked += () => { foreach (var nodePresenter in _nodePresenters) { nodePresenter.ConnectionPointSelected -= OnConnectionPointSelected; nodePresenter.ConnectionPointUnSelected -= OnConnectionPointUnSelected; } _nodePresenters.Clear(); _connectionPresenters.Clear(); _selectedNodePresenter = null; _selectedPointPresenter = null; }; loadButton.Clicked += () => { }; saveButton.Clicked += () => { var saveFileDialog = new SaveFileDialog(); saveFileDialog.ShowDialog(); if (saveFileDialog.Result) { var path = saveFileDialog.Path; XmlReadWriter.Write <VntData>(path, _vntData); } }; var toolPanelButtons = new List <ToolPanelButton>() { createNewButton, loadButton, saveButton }; _vntView.DrawToolPanel(toolPanelButtons); }
private void OnConnectionPointUnSelected(NodePresenter nodePresenter, PortPresenter portPresenter) { _selectedNodePresenter = null; _selectedPointPresenter = null; }
public void SetTo(PortPresenter portPresenter, Guid nodeId) { PortTo = portPresenter; _linkData.To = nodeId; }
public void SetFrom(PortPresenter portPresenter, Guid nodeId) { PortFrom = portPresenter; _linkData.From = nodeId; }