From c18b38111573eee8d9a7f3cd6c48f9e350821668 Mon Sep 17 00:00:00 2001 From: dexy Date: Wed, 10 Nov 2021 01:00:11 +1100 Subject: [PATCH] Fixed bug with display entity indexes option in ProjectForm so as not to lose the current selection in the project explorer (but only for entities). --- CodeWalker/Project/ProjectForm.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CodeWalker/Project/ProjectForm.cs b/CodeWalker/Project/ProjectForm.cs index d9bb851..38f1bc6 100644 --- a/CodeWalker/Project/ProjectForm.cs +++ b/CodeWalker/Project/ProjectForm.cs @@ -9441,12 +9441,27 @@ namespace CodeWalker.Project OptionsAutoCalcYmapExtentsMenu.Checked = !OptionsAutoCalcYmapExtentsMenu.Checked; autoymapextents = OptionsAutoCalcYmapExtentsMenu.Checked; } - private void OptionsDisplayEntityIndexesMenu_Click(object sender, EventArgs e) { OptionsDisplayEntityIndexesMenu.Checked = !OptionsDisplayEntityIndexesMenu.Checked; displayentityindexes = OptionsDisplayEntityIndexesMenu.Checked; ProjectExplorer?.LoadProjectTree(CurrentProjectFile); + + //make sure the current item is selected in the project explorer, let's just assume it's an entity + //(for things other than entities, they will need to be re-selected manually by the user to sync project explorer again) + if (CurrentEntity != null) + { + MloInstanceData mloInstance = CurrentEntity.MloParent?.MloInstance; + if (mloInstance != null) //indexes aren't shown for MLO entities, but just in case one was selected + { + MCEntityDef entityDef = mloInstance.TryGetArchetypeEntity(CurrentEntity); + ProjectExplorer?.TrySelectMloEntityTreeNode(entityDef); + } + else + { + ProjectExplorer?.TrySelectEntityTreeNode(CurrentEntity); + } + } } private void ToolbarNewButton_ButtonClick(object sender, EventArgs e)