private void HandleNodeViewDuplicationRequested(ChainNodeView nodeView, bool recurse) { var settings = HaxxisPackage.GetSerializationSettings(TypeNameHandling.All); var originalWrapper = new NodeDupeSerializationWrapper(nodeView.ChainNode, ChainView.Instance.GetNodeViewModels(nodeView.ChainNode, recurse)); var wrapperJson = JsonConvert.SerializeObject(originalWrapper, Formatting.Indented, settings); var duplicateWrapper = JsonConvert.DeserializeObject <NodeDupeSerializationWrapper>(wrapperJson, settings); // Should this go in Group.AddNode? duplicateWrapper.Node.InitializeSchema(); if (!recurse) { duplicateWrapper.Node.Router.UntargetAllTargets(); } Group.AddNode(duplicateWrapper.Node, recurse: recurse, isTransfer: false); foreach (var vm in duplicateWrapper.ViewModels) { vm.Position += new Vector3(20.0f, -20.0f, 0.0f); } ChainView.Instance.SetNodeViewModels(duplicateWrapper.ViewModels); BoundsDirty = true; }
private void HandleNodeViewDropped(ChainNodeView droppedNodeView) { if (!ChainView.GroupTransferModeActive) { return; } Debug.Log("node view dropped"); if (NodeViews.Contains(droppedNodeView)) { return; } droppedNodeView.RequestTransfer(this); }
private void RemoveChainNodeView(ChainNodeView view, bool destroy) { view.BoundsChanged -= HandleChildViewBoundsChanged; view.TransferRequested -= HandleChildNodeViewTransferRequested; view.DuplicationRequested -= HandleNodeViewDuplicationRequested; NodeViews.Remove(view); if (destroy) { Destroy(view.gameObject); } BoundsDirty = true; UpdateDeleteButtonState(); }
private void HandlePreviewNodeViewDrop(ChainNodeView nodeView) { if (!ChainView.GroupTransferModeActive) { return; } if (nodeView == null) { IndicateDropAcceptance(false); return; } if (NodeViews.Contains(nodeView)) { IndicateDropAcceptance(false); return; } IndicateDropAcceptance(true); }
private void AddChainNodeView(ChainNodeView view, bool isTransfer = false) { if (isTransfer) { view.transform.SetParent(NodeAttachmentPoint, true); } NodeViews.Add(view); if (!isTransfer) { view.transform.position = NewNodePosition; } view.BoundsChanged += HandleChildViewBoundsChanged; view.TransferRequested += HandleChildNodeViewTransferRequested; view.DuplicationRequested += HandleNodeViewDuplicationRequested; BoundsDirty = true; UpdateDeleteButtonState(); }
public ChainNodeViewModel(ChainNodeView chainNodeView) { ChainNode = chainNodeView.ChainNode; Position = chainNodeView.RectTransform.localPosition; }
private void AcceptNodeView(ChainNodeView nodeView) { NodeViewDropped(nodeView); }
private void HandleChildNodeViewTransferRequested(ChainNodeView movedView, ChainGroupView destinationView) { RemoveChainNodeView(movedView, destroy: false); destinationView.AddChainNodeView(movedView, isTransfer: true); }