diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs index 6f1464f..a2254a3 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs @@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic editor = widget.Parent.Parent.Get("MAP_EDITOR"); editor.DefaultBrush.UpdateSelectedTab += HandleUpdateSelectedTab; + editor.DefaultBrush.SelectionChanged += HandleSelectionChanged; SetupTab("SELECT_TAB", "SELECT_WIDGETS", MenuType.Select); SetupTab("TILES_TAB", "TILE_WIDGETS", MenuType.Tiles); @@ -51,6 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic protected override void Dispose(bool disposing) { editor.DefaultBrush.UpdateSelectedTab -= HandleUpdateSelectedTab; + editor.DefaultBrush.SelectionChanged -= HandleSelectionChanged; base.Dispose(disposing); } @@ -96,5 +98,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic OnTabChanged?.Invoke(); } + + void HandleSelectionChanged() + { + // Editor actions (e.g. deleting the selected actor or undo/redo) can clear the selection + // without going through UpdateSelectedTab, so make sure we don't stay on the disabled tab. + if (menuType == MenuType.Select && !editor.DefaultBrush.Selection.HasSelection) + { + menuType = lastSelectedTab; + OnTabChanged?.Invoke(); + } + } } }