Moved UpdateEntityTreeNode code into ProjectExplorer

This commit is contained in:
dexy 2021-11-13 22:44:39 +11:00
parent 7922cff694
commit 89e838550f
2 changed files with 28 additions and 20 deletions

View File

@ -234,26 +234,6 @@ namespace CodeWalker.Project.Panels
EntityArchetypeHashLabel.Text += " (not found)"; EntityArchetypeHashLabel.Text += " (not found)";
} }
TreeNode tn = ProjectForm.ProjectExplorer?.FindEntityTreeNode(CurrentEntity);
if (tn != null)
{
if (ProjectForm.displayentityindexes)
tn.Text = $"[{tn.Index}] {name}";
else
tn.Text = name;
}
else
{
tn = ProjectForm.ProjectExplorer?.FindMloEntityTreeNode(CurrentMCEntity);
if (tn != null)
{
if (ProjectForm.displayentityindexes)
tn.Text = $"[{tn.Index}] {name}";
else
tn.Text = name;
}
}
if (CurrentEntity != null) if (CurrentEntity != null)
{ {
lock (ProjectForm.ProjectSyncRoot) lock (ProjectForm.ProjectSyncRoot)
@ -278,6 +258,8 @@ namespace CodeWalker.Project.Panels
} }
} }
} }
ProjectForm.ProjectExplorer?.UpdateEntityTreeNode(CurrentEntity);
} }
private void ProjectItemChanged() private void ProjectItemChanged()

View File

@ -2092,6 +2092,32 @@ namespace CodeWalker.Project.Panels
tn.Text = archetype._BaseArchetypeDef.ToString(); tn.Text = archetype._BaseArchetypeDef.ToString();
} }
} }
public void UpdateEntityTreeNode(YmapEntityDef ent)
{
if (ent == null) return;
var tn = FindEntityTreeNode(ent);
var name = ent.CEntityDef.archetypeName.ToString();
if (tn != null)
{
if (ProjectForm.displayentityindexes)
tn.Text = $"[{tn.Index}] {name}";
else
tn.Text = name;
}
else
{
var instance = ent.MloParent?.MloInstance;
var mcent = instance?.TryGetArchetypeEntity(ent);
tn = FindMloEntityTreeNode(mcent);
if (tn != null)
{
if (ProjectForm.displayentityindexes)
tn.Text = $"[{tn.Index}] {name}";
else
tn.Text = name;
}
}
}
public void UpdateCarGenTreeNode(YmapCarGen cargen) public void UpdateCarGenTreeNode(YmapCarGen cargen)
{ {
var tn = FindCarGenTreeNode(cargen); var tn = FindCarGenTreeNode(cargen);