Skip to content

Commit

Permalink
Disable nested input managers on edited screen when skin editor is open
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Feb 19, 2024
1 parent 444ac5e commit 9ee0cad
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
Expand Down Expand Up @@ -66,6 +68,7 @@ public partial class SkinEditorOverlay : OverlayContainer, IKeyBindingHandler<Gl
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;

private OsuScreen? lastTargetScreen;
private InvokeOnDisposal? nestedInputManagerDisable;

private Vector2 lastDrawSize;

Expand Down Expand Up @@ -105,6 +108,7 @@ protected override void PopIn()

if (skinEditor != null)
{
disableNestedInputManagers();
skinEditor.Show();
return;
}
Expand Down Expand Up @@ -132,6 +136,7 @@ protected override void PopOut()
{
skinEditor?.Save(false);
skinEditor?.Hide();
nestedInputManagerDisable?.Dispose();

globallyReenableBeatmapSkinSetting();
}
Expand Down Expand Up @@ -243,6 +248,9 @@ public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
/// </summary>
public void SetTarget(OsuScreen screen)
{
nestedInputManagerDisable?.Dispose();
nestedInputManagerDisable = null;

lastTargetScreen = screen;

if (skinEditor == null) return;
Expand Down Expand Up @@ -271,6 +279,7 @@ private void setTarget(OsuScreen? target)
{
skinEditor.Save(false);
skinEditor.UpdateTargetScreen(target);
disableNestedInputManagers();
}
else
{
Expand All @@ -280,6 +289,21 @@ private void setTarget(OsuScreen? target)
}
}

private void disableNestedInputManagers()
{
if (lastTargetScreen == null)
return;

var nestedInputManagers = lastTargetScreen.ChildrenOfType<PassThroughInputManager>().Where(manager => manager.UseParentInput).ToArray();
foreach (var inputManager in nestedInputManagers)
inputManager.UseParentInput = false;
nestedInputManagerDisable = new InvokeOnDisposal(() =>
{
foreach (var inputManager in nestedInputManagers)
inputManager.UseParentInput = true;
});
}

private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private LeasedBindable<bool>? leasedBeatmapSkins;

Expand Down

0 comments on commit 9ee0cad

Please sign in to comment.