public PathNodePositionUndoStep(YndNode pathnode, Vector3 startpos, WorldForm wf) { PathNode = pathnode; StartPosition = startpos; EndPosition = pathnode?.Position ?? Vector3.Zero; UpdateGraphics(wf); //forces the update of the path graphics when it's moved... }
public void SetPathNode(YndNode node) { CurrentPathNode = node; CurrentPathLink = null; CurrentYndFile = node?.Ynd; Tag = node; UpdateFormTitle(); UpdateYndNodeUI(); }
public void UpdatePathNodeTreeNode(YndNode node) { var tn = FindPathNodeTreeNode(node); if (tn != null) { tn.Text = node._RawData.ToString(); } }
public void RemovePathNodeTreeNode(YndNode node) { var tn = FindPathNodeTreeNode(node); if ((tn != null) && (tn.Parent != null)) { tn.Parent.Text = "Nodes (" + node.Ynd.Nodes.Length.ToString() + ")"; tn.Parent.Nodes.Remove(tn); } }
public void TrySelectPathNodeTreeNode(YndNode node) { TreeNode tnode = FindPathNodeTreeNode(node); if (tnode == null) { tnode = FindYndTreeNode(node?.Ynd); } if (tnode != null) { ProjectTreeView.SelectedNode = tnode; } }
private void UpdatePathNodeLinkage() { if (CurrentPathLink == null) { return; } if (CurrentYndFile == null) { return; } YndNode linknode = null; ushort areaid = CurrentPathLink._RawData.AreaID; ushort nodeid = CurrentPathLink._RawData.NodeID; if (areaid == CurrentYndFile.AreaID) { //link to the same ynd. find the new node in the current ynd. if ((CurrentYndFile.Nodes != null) && (nodeid < CurrentYndFile.Nodes.Length)) { linknode = CurrentYndFile.Nodes[nodeid]; } } else { //try lookup the link node from the space. if (ProjectForm.WorldForm != null) { linknode = ProjectForm.WorldForm.GetPathNodeFromSpace(areaid, nodeid); } } if (linknode == null) { PathNodeLinkageStatusLabel.Text = "Unable to find node " + areaid.ToString() + ":" + nodeid.ToString() + "."; } else { PathNodeLinkageStatusLabel.Text = ""; } CurrentPathLink.Node2 = linknode; CurrentPathLink.UpdateLength(); ////need to rebuild the link verts.. updating the graphics should do it... if (ProjectForm.WorldForm != null) { ProjectForm.WorldForm.UpdatePathYndGraphics(CurrentYndFile, false); } }
public TreeNode FindPathNodeTreeNode(YndNode n) { if (n == null) { return(null); } TreeNode yndnode = FindYndTreeNode(n.Ynd); var nodesnode = GetChildTreeNode(yndnode, "Nodes"); if (nodesnode == null) { return(null); } for (int i = 0; i < nodesnode.Nodes.Count; i++) { TreeNode nnode = nodesnode.Nodes[i]; if (nnode.Tag == n) { return(nnode); } } return(null); }
private void yndMove_Click(object sender, EventArgs e) { if (populatingui) { return; } if (Ynd == null) { return; } int x = (int)YndAreaIDXUpDown.Value; int y = (int)YndAreaIDYUpDown.Value; lock (ProjectForm.ProjectSyncRoot) { int shiftX = x - Ynd.CellX; int shiftY = y - Ynd.CellY; var areaid = y * 32 + x; if (Ynd.AreaID != areaid && ProjectForm.WorldForm != null) { YndNode[] yndNodes = Ynd.Nodes; for (int i = 0; i < yndNodes.Length; i++) { YndNode yndNode = yndNodes[i]; // a node is 512x512 yndNode.SetPosition(yndNode.Position + new SharpDX.Vector3(512 * shiftX, 512 * shiftY, 0.0f)); yndNode.AreaID = (ushort)areaid; ProjectForm.WorldForm.SetWidgetPosition(yndNode.Position); ProjectForm.WorldForm.UpdatePathNodeGraphics(yndNode, false); } YndJunction[] yndJunctions = Ynd.Junctions; if (yndJunctions != null && yndJunctions.Length != 0) { for (int i = 0; i < yndJunctions.Length; i++) { YndJunction yndJunction = yndJunctions[i]; yndJunction.PositionX += (short)(512 * shiftX); yndJunction.PositionY += (short)(512 * shiftY); } } // Editing links is not needed since they are already loaded as node above Ynd.AreaID = areaid; Ynd.Name = "nodes" + areaid.ToString() + ".ynd"; YndAreaIDInfoLabel.Text = "AID: " + areaid.ToString(); Ynd.UpdateAllNodePositions(); Ynd.UpdateBoundingBox(); Ynd.UpdateTriangleVertices(); ProjectForm.SetYndHasChanged(true); MessageBox.Show("Don't forget to remove the former ynd!"); } } UpdateFormTitleYndChanged(); }