Fix scene tree menu options being enabled when not supposed to be

This commit is contained in:
Chandler Cox
2024-11-21 20:24:16 -06:00
parent d4b663cd1a
commit 2a7dcff5c4
2 changed files with 7 additions and 6 deletions

View File

@@ -81,6 +81,7 @@ namespace FlaxEditor.SceneGraph.Actors
if (Level.ScenesCount > 1) if (Level.ScenesCount > 1)
contextMenu.AddButton("Unload all but this scene", OnUnloadAllButSelectedScene).LinkTooltip("Unloads all of the active scenes except for the selected scene.").Enabled = Editor.Instance.StateMachine.CurrentState.CanChangeScene; contextMenu.AddButton("Unload all but this scene", OnUnloadAllButSelectedScene).LinkTooltip("Unloads all of the active scenes except for the selected scene.").Enabled = Editor.Instance.StateMachine.CurrentState.CanChangeScene;
contextMenu.MaximumItemsInViewCount += 3;
base.OnContextMenu(contextMenu, window); base.OnContextMenu(contextMenu, window);
} }

View File

@@ -55,9 +55,9 @@ namespace FlaxEditor.Windows
b = contextMenu.AddButton("Rename", inputOptions.Rename, Rename); b = contextMenu.AddButton("Rename", inputOptions.Rename, Rename);
b = contextMenu.AddButton("Duplicate", inputOptions.Duplicate, Editor.SceneEditing.Duplicate); b = contextMenu.AddButton("Duplicate", inputOptions.Duplicate, Editor.SceneEditing.Duplicate);
b.Enabled = hasSthSelected; b.Enabled = hasSthSelected && ((ActorNode)Editor.SceneEditing.Selection[0]).CanDuplicate;
if (isSingleActorSelected) if (isSingleActorSelected && ((ActorNode)Editor.SceneEditing.Selection[0]).Actor is not Scene)
{ {
var convertMenu = contextMenu.AddChildMenu("Convert"); var convertMenu = contextMenu.AddChildMenu("Convert");
convertMenu.ContextMenu.AutoSort = true; convertMenu.ContextMenu.AutoSort = true;
@@ -117,24 +117,24 @@ namespace FlaxEditor.Windows
} }
} }
b = contextMenu.AddButton("Delete", inputOptions.Delete, Editor.SceneEditing.Delete); b = contextMenu.AddButton("Delete", inputOptions.Delete, Editor.SceneEditing.Delete);
b.Enabled = hasSthSelected; b.Enabled = hasSthSelected && ((ActorNode)Editor.SceneEditing.Selection[0]).CanDelete;
contextMenu.AddSeparator(); contextMenu.AddSeparator();
b = contextMenu.AddButton("Copy", inputOptions.Copy, Editor.SceneEditing.Copy); b = contextMenu.AddButton("Copy", inputOptions.Copy, Editor.SceneEditing.Copy);
b.Enabled = hasSthSelected && ((ActorNode)Editor.SceneEditing.Selection[0]).CanCopyPaste;
b.Enabled = hasSthSelected;
contextMenu.AddButton("Paste", inputOptions.Paste, Editor.SceneEditing.Paste); contextMenu.AddButton("Paste", inputOptions.Paste, Editor.SceneEditing.Paste);
b = contextMenu.AddButton("Cut", inputOptions.Cut, Editor.SceneEditing.Cut); b = contextMenu.AddButton("Cut", inputOptions.Cut, Editor.SceneEditing.Cut);
b.Enabled = canEditScene; b.Enabled = canEditScene && ((ActorNode)Editor.SceneEditing.Selection[0]).CanCopyPaste;
// Create option // Create option
contextMenu.AddSeparator(); contextMenu.AddSeparator();
b = contextMenu.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors); b = contextMenu.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors);
b.Enabled = canEditScene && hasSthSelected; b.Enabled = canEditScene && hasSthSelected && ((ActorNode)Editor.SceneEditing.Selection[0]).Actor is not Scene;
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab); b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
b.Enabled = isSingleActorSelected && b.Enabled = isSingleActorSelected &&