Fix the editor selection tab staying open after the selection is cleared

This commit is contained in:
dualfroz committed 2026-10-14 18:55:22 +02:00
1 parent 6a61ac82fc
commit b29ff7b642
1 file changed
+13
@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
editor = widget.Parent.Parent.Get<EditorViewportControllerWidget>("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();
}
}
}
}