Walking is blocked while an on-demand overlay (trade window, workbench) is open

This commit is contained in:
cthangover committed 2026-10-22 17:09:39 +02:00
1 parent 002cd09495
commit ec787f3e2f
1 file changed
+7 -2
+7 -2
View File
@@ -11,7 +11,8 @@ namespace Cthangover.Mods.Rpg
/// they are on a Russian or any other layout; the arrows work too. /// they are on a Russian or any other layout; the arrows work too.
/// <para/> /// <para/>
/// The world must not walk while something else owns the keyboard or the /// The world must not walk while something else owns the keyboard or the
/// player's attention: a dialog, a toolbar panel (inventory, journal), a /// player's attention: a dialog, a toolbar panel (inventory, journal) or a
/// window-like overlay opened by a scenario (a trade window, a workbench), a
/// focused editor window or text field, a paused tree, a scene transition. /// focused editor window or text field, a paused tree, a scene transition.
/// <see cref="IsWalkBlocked"/> collects those checks in one place. /// <see cref="IsWalkBlocked"/> collects those checks in one place.
/// </summary> /// </summary>
@@ -61,13 +62,17 @@ namespace Cthangover.Mods.Rpg
return IsPanelOpen(); return IsPanelOpen();
} }
// Panels and "once" overlays opened on demand are window-like entries on the
// host layer. Overlays shown from the start (a HUD strip) do not block walking.
private static bool IsPanelOpen() private static bool IsPanelOpen()
{ {
var host = UiHost.Instance; var host = UiHost.Instance;
if (host == null) if (host == null)
return false; return false;
foreach (var entry in UiRegistry.PanelEntries) foreach (var entry in UiRegistry.Entries)
{ {
if (!UiRegistry.IsPanel(entry) && !(entry.Once && !entry.ShowOnStart))
continue;
if (host.TryGetInstance(entry.Id, out var panel) && panel.IsVisibleInTree()) if (host.TryGetInstance(entry.Id, out var panel) && panel.IsVisibleInTree())
return true; return true;
} }