Editing points and portals in navmesh, improved DX error message

This commit is contained in:
dexyfex
2018-03-14 12:36:43 +11:00
Unverified
parent 761278fd0b
commit 8b72fc1220
20 changed files with 2931 additions and 169 deletions
+171 -1
View File
@@ -50,6 +50,8 @@ namespace CodeWalker.Project
private YnvFile CurrentYnvFile;
private YnvPoly CurrentNavPoly;
private YnvPoint CurrentNavPoint;
private YnvPortal CurrentNavPortal;
private TrainTrack CurrentTrainTrack;
private TrainTrackNode CurrentTrainNode;
@@ -373,6 +375,20 @@ namespace CodeWalker.Project
(panel) => { panel.SetYnvPoly(CurrentNavPoly); }, //updateFunc
(panel) => { return panel.YnvPoly == CurrentNavPoly; }); //findFunc
}
private void ShowEditYnvPointPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPointPanel(this); }, //createFunc
(panel) => { panel.SetYnvPoint(CurrentNavPoint); }, //updateFunc
(panel) => { return panel.YnvPoint == CurrentNavPoint; }); //findFunc
}
private void ShowEditYnvPortalPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPortalPanel(this); }, //createFunc
(panel) => { panel.SetYnvPortal(CurrentNavPortal); }, //updateFunc
(panel) => { return panel.YnvPortal == CurrentNavPortal; }); //findFunc
}
private void ShowEditTrainTrackPanel(bool promote)
{
ShowPanel(promote,
@@ -436,6 +452,14 @@ namespace CodeWalker.Project
{
ShowEditYnvPolyPanel(promote);
}
else if (CurrentNavPoint != null)
{
ShowEditYnvPointPanel(promote);
}
else if (CurrentNavPortal != null)
{
ShowEditYnvPortalPanel(promote);
}
else if (CurrentYnvFile != null)
{
ShowEditYnvPanel(promote);
@@ -485,6 +509,8 @@ namespace CodeWalker.Project
CurrentPathNode = item as YndNode;
CurrentYnvFile = item as YnvFile;
CurrentNavPoly = item as YnvPoly;
CurrentNavPoint = item as YnvPoint;
CurrentNavPortal = item as YnvPortal;
CurrentTrainTrack = item as TrainTrack;
CurrentTrainNode = item as TrainTrackNode;
CurrentScenario = item as YmtFile;
@@ -511,6 +537,14 @@ namespace CodeWalker.Project
{
CurrentYnvFile = CurrentNavPoly.Ynv;
}
if (CurrentNavPoint != null)
{
CurrentYnvFile = CurrentNavPoint.Ynv;
}
if (CurrentNavPortal != null)
{
CurrentYnvFile = CurrentNavPortal.Ynv;
}
if (CurrentTrainNode != null)
{
CurrentTrainTrack = CurrentTrainNode.Track;
@@ -2165,6 +2199,30 @@ namespace CodeWalker.Project
return poly == CurrentNavPoly;
}
public void NewNavPoint(YnvPoint copy = null, bool copyposition = false)//TODO!
{
}
public bool DeleteNavPoint()//TODO!
{
return false;
}
public bool IsCurrentNavPoint(YnvPoint point)
{
return point == CurrentNavPoint;
}
public void NewNavPortal(YnvPortal copy = null, bool copyposition = false)//TODO!
{
}
public bool DeleteNavPortal()//TODO!
{
return false;
}
public bool IsCurrentNavPortal(YnvPortal portal)
{
return portal == CurrentNavPortal;
}
public void NewTrainTrack()
@@ -3759,12 +3817,14 @@ namespace CodeWalker.Project
var pathnode = sel.PathNode;
var pathlink = sel.PathLink;
var navpoly = sel.NavPoly;
var navpoint = sel.NavPoint;
var navportal = sel.NavPortal;
var trainnode = sel.TrainTrackNode;
var scenariond = sel.ScenarioNode;
var scenarioedge = sel.ScenarioEdge;
YmapFile ymap = ent?.Ymap ?? cargen?.Ymap ?? grassbatch?.Ymap;
YndFile ynd = pathnode?.Ynd;
YnvFile ynv = navpoly?.Ynv;
YnvFile ynv = navpoly?.Ynv ?? navpoint?.Ynv ?? navportal?.Ynv;
TrainTrack traintrack = trainnode?.Track;
YmtFile scenario = scenariond?.Ymt ?? scenarioedge?.Region?.Ymt;
bool showcurrent = false;
@@ -3793,6 +3853,14 @@ namespace CodeWalker.Project
{
ProjectExplorer?.TrySelectNavPolyTreeNode(navpoly);
}
if (navpoint != CurrentNavPoint)
{
ProjectExplorer?.TrySelectNavPointTreeNode(navpoint);
}
if (navportal != CurrentNavPortal)
{
ProjectExplorer?.TrySelectNavPortalTreeNode(navportal);
}
}
else if (TrainTrackExistsInProject(traintrack))
{
@@ -3825,6 +3893,8 @@ namespace CodeWalker.Project
CurrentPathLink = pathlink;
CurrentYnvFile = ynv;
CurrentNavPoly = navpoly;
CurrentNavPoint = navpoint;
CurrentNavPortal = navportal;
CurrentTrainTrack = traintrack;
CurrentTrainNode = trainnode;
CurrentScenario = scenario;
@@ -3863,6 +3933,14 @@ namespace CodeWalker.Project
{
OnWorldNavPolyModified(sel.NavPoly);
}
else if (sel.NavPoint != null)
{
OnWorldNavPointModified(sel.NavPoint);
}
else if (sel.NavPortal != null)
{
OnWorldNavPortalModified(sel.NavPortal);
}
else if (sel.TrainTrackNode != null)
{
OnWorldTrainNodeModified(sel.TrainTrackNode);
@@ -4064,6 +4142,98 @@ namespace CodeWalker.Project
}
catch { }
}
private void OnWorldNavPointModified(YnvPoint point)
{
try
{
if (InvokeRequired)
{
BeginInvoke(new Action(() => { OnWorldNavPointModified(point); }));
}
else
{
if (point?.Ynv == null) return;
if (CurrentProjectFile == null)
{
NewProject();
}
if (!YnvExistsInProject(point.Ynv))
{
point.Ynv.HasChanged = true;
AddYnvToProject(point.Ynv);
ProjectExplorer?.TrySelectNavPointTreeNode(point);
}
if (point != CurrentNavPoint)
{
CurrentNavPoint = point;
ProjectExplorer?.TrySelectNavPointTreeNode(point);
}
if (point == CurrentNavPoint)
{
ShowEditYnvPointPanel(false);
//////UpdateNavPointTreeNode(poly);
if (point.Ynv != null)
{
SetYnvHasChanged(true);
}
}
}
}
catch { }
}
private void OnWorldNavPortalModified(YnvPortal portal)
{
try
{
if (InvokeRequired)
{
BeginInvoke(new Action(() => { OnWorldNavPortalModified(portal); }));
}
else
{
if (portal?.Ynv == null) return;
if (CurrentProjectFile == null)
{
NewProject();
}
if (!YnvExistsInProject(portal.Ynv))
{
portal.Ynv.HasChanged = true;
AddYnvToProject(portal.Ynv);
ProjectExplorer?.TrySelectNavPortalTreeNode(portal);
}
if (portal != CurrentNavPortal)
{
CurrentNavPortal = portal;
ProjectExplorer?.TrySelectNavPortalTreeNode(portal);
}
if (portal == CurrentNavPortal)
{
ShowEditYnvPortalPanel(false);
//////UpdateNavPortalTreeNode(poly);
if (portal.Ynv != null)
{
SetYnvHasChanged(true);
}
}
}
}
catch { }
}
private void OnWorldTrainNodeModified(TrainTrackNode node)
{
try