Updating selection graphics whenever using widgets

This commit is contained in:
dexy 2020-01-14 13:26:38 +11:00
parent acba388358
commit 12235a0682
3 changed files with 123 additions and 73 deletions

View File

@ -27,79 +27,8 @@ namespace CodeWalker.Project
protected void UpdateGraphics(WorldForm wf) protected void UpdateGraphics(WorldForm wf)
{ {
Selection.UpdateGraphics(wf);
Dictionary<YndFile, int> pathYnds = new Dictionary<YndFile, int>();
Dictionary<YnvFile, int> navYnvs = new Dictionary<YnvFile, int>();
Dictionary<TrainTrack, int> trainTracks = new Dictionary<TrainTrack, int>();
Dictionary<YmtFile, int> scenarioYmts = new Dictionary<YmtFile, int>();
Dictionary<Bounds, int> bounds = new Dictionary<Bounds, int>();
if (Selection.MultipleSelectionItems != null)
{
foreach (var item in Selection.MultipleSelectionItems)
{
if (item.PathNode != null)
{
pathYnds[item.PathNode.Ynd] = 1;
}
if (item.NavPoly != null)
{
navYnvs[item.NavPoly.Ynv] = 1;
}
if (item.NavPoint != null)
{
navYnvs[item.NavPoint.Ynv] = 1;
}
if (item.NavPortal != null)
{
navYnvs[item.NavPortal.Ynv] = 1;
}
if (item.TrainTrackNode != null)
{
trainTracks[item.TrainTrackNode.Track] = 1;
}
if (item.ScenarioNode != null)
{
scenarioYmts[item.ScenarioNode.Ymt] = 1;
}
if (item.CollisionBounds != null)
{
bounds[item.CollisionBounds] = 1;
}
if (item.CollisionPoly?.Owner != null)
{
bounds[item.CollisionPoly.Owner] = 1;
}
if (item.CollisionVertex?.Owner != null)
{
bounds[item.CollisionVertex.Owner] = 1;
}
}
}
foreach (var kvp in bounds)
{
wf.UpdateCollisionBoundsGraphics(kvp.Key);
}
foreach (var kvp in pathYnds)
{
wf.UpdatePathYndGraphics(kvp.Key, true);
}
foreach (var kvp in navYnvs)
{
wf.UpdateNavYnvGraphics(kvp.Key, true);
}
foreach (var kvp in trainTracks)
{
wf.UpdateTrainTrackGraphics(kvp.Key, false);
}
foreach (var kvp in scenarioYmts)
{
wf.UpdateScenarioGraphics(kvp.Key, false);
}
} }
} }
public class MultiPositionUndoStep : MultiItemUndoStep public class MultiPositionUndoStep : MultiItemUndoStep
{ {

View File

@ -1144,6 +1144,121 @@ namespace CodeWalker
public void UpdateGraphics(WorldForm wf)
{
if (MultipleSelectionItems != null)
{
Dictionary<YndFile, int> pathYnds = new Dictionary<YndFile, int>();
Dictionary<YnvFile, int> navYnvs = new Dictionary<YnvFile, int>();
Dictionary<TrainTrack, int> trainTracks = new Dictionary<TrainTrack, int>();
Dictionary<YmtFile, int> scenarioYmts = new Dictionary<YmtFile, int>();
Dictionary<Bounds, int> bounds = new Dictionary<Bounds, int>();
foreach (var item in MultipleSelectionItems)
{
if (item.PathNode != null)
{
pathYnds[item.PathNode.Ynd] = 1;
}
if (item.NavPoly != null)
{
navYnvs[item.NavPoly.Ynv] = 1;
}
if (item.NavPoint != null)
{
navYnvs[item.NavPoint.Ynv] = 1;
}
if (item.NavPortal != null)
{
navYnvs[item.NavPortal.Ynv] = 1;
}
if (item.TrainTrackNode != null)
{
trainTracks[item.TrainTrackNode.Track] = 1;
}
if (item.ScenarioNode != null)
{
scenarioYmts[item.ScenarioNode.Ymt] = 1;
}
if (item.CollisionBounds != null)
{
bounds[item.CollisionBounds] = 1;
}
if (item.CollisionPoly?.Owner != null)
{
bounds[item.CollisionPoly.Owner] = 1;
}
if (item.CollisionVertex?.Owner != null)
{
bounds[item.CollisionVertex.Owner] = 1;
}
}
foreach (var kvp in bounds)
{
wf.UpdateCollisionBoundsGraphics(kvp.Key);
}
foreach (var kvp in pathYnds)
{
wf.UpdatePathYndGraphics(kvp.Key, true);
}
foreach (var kvp in navYnvs)
{
wf.UpdateNavYnvGraphics(kvp.Key, true);
}
foreach (var kvp in trainTracks)
{
wf.UpdateTrainTrackGraphics(kvp.Key, false);
}
foreach (var kvp in scenarioYmts)
{
wf.UpdateScenarioGraphics(kvp.Key, false);
}
}
else
{
if (PathNode != null)
{
wf.UpdatePathYndGraphics(PathNode.Ynd, true);
}
if (NavPoly != null)
{
wf.UpdateNavYnvGraphics(NavPoly.Ynv, true);
}
if (NavPoint != null)
{
wf.UpdateNavYnvGraphics(NavPoint.Ynv, true);
}
if (NavPortal != null)
{
wf.UpdateNavYnvGraphics(NavPortal.Ynv, true);
}
if (TrainTrackNode != null)
{
wf.UpdateTrainTrackGraphics(TrainTrackNode.Track, false);
}
if (ScenarioNode != null)
{
wf.UpdateScenarioGraphics(ScenarioNode.Ymt, false);
}
if (CollisionVertex?.Owner != null)
{
wf.UpdateCollisionBoundsGraphics(CollisionVertex.Owner);
}
else if (CollisionPoly?.Owner != null)
{
wf.UpdateCollisionBoundsGraphics(CollisionPoly.Owner);
}
else if (CollisionBounds != null)
{
wf.UpdateCollisionBoundsGraphics(CollisionBounds);
}
}
}
public override string ToString() public override string ToString()
{ {
return GetFullNameString("[Empty]"); return GetFullNameString("[Empty]");

View File

@ -1658,6 +1658,8 @@ namespace CodeWalker
SelectedItem.SetPosition(newpos, EditEntityPivot); SelectedItem.SetPosition(newpos, EditEntityPivot);
SelectedItem.UpdateGraphics(this);
if (ProjectForm != null) if (ProjectForm != null)
{ {
ProjectForm.OnWorldSelectionModified(SelectedItem); ProjectForm.OnWorldSelectionModified(SelectedItem);
@ -1670,6 +1672,8 @@ namespace CodeWalker
SelectedItem.SetRotation(newrot, EditEntityPivot); SelectedItem.SetRotation(newrot, EditEntityPivot);
SelectedItem.UpdateGraphics(this);
if (ProjectForm != null) if (ProjectForm != null)
{ {
ProjectForm.OnWorldSelectionModified(SelectedItem); ProjectForm.OnWorldSelectionModified(SelectedItem);
@ -1682,6 +1686,8 @@ namespace CodeWalker
SelectedItem.SetScale(newscale, EditEntityPivot); SelectedItem.SetScale(newscale, EditEntityPivot);
SelectedItem.UpdateGraphics(this);
if (ProjectForm != null) if (ProjectForm != null)
{ {
ProjectForm.OnWorldSelectionModified(SelectedItem); ProjectForm.OnWorldSelectionModified(SelectedItem);