Fix the editor selection tab staying open after the selection is cleared
This commit is contained in:
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 = widget.Parent.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||||
editor.DefaultBrush.UpdateSelectedTab += HandleUpdateSelectedTab;
|
editor.DefaultBrush.UpdateSelectedTab += HandleUpdateSelectedTab;
|
||||||
|
editor.DefaultBrush.SelectionChanged += HandleSelectionChanged;
|
||||||
|
|
||||||
SetupTab("SELECT_TAB", "SELECT_WIDGETS", MenuType.Select);
|
SetupTab("SELECT_TAB", "SELECT_WIDGETS", MenuType.Select);
|
||||||
SetupTab("TILES_TAB", "TILE_WIDGETS", MenuType.Tiles);
|
SetupTab("TILES_TAB", "TILE_WIDGETS", MenuType.Tiles);
|
||||||
@@ -51,6 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
editor.DefaultBrush.UpdateSelectedTab -= HandleUpdateSelectedTab;
|
editor.DefaultBrush.UpdateSelectedTab -= HandleUpdateSelectedTab;
|
||||||
|
editor.DefaultBrush.SelectionChanged -= HandleSelectionChanged;
|
||||||
|
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@@ -96,5 +98,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
OnTabChanged?.Invoke();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user