1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Disable nested input managers on edited screen when skin editor is open

This commit is contained in:
Bartłomiej Dach 2024-02-19 09:45:03 +01:00
parent 444ac5ed4d
commit 1ca566c6b0
No known key found for this signature in database

View File

@ -10,9 +10,11 @@ using osu.Framework.Bindables;
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;
@ -66,6 +68,7 @@ namespace osu.Game.Overlays.SkinEditor
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
private OsuScreen? lastTargetScreen;
private InvokeOnDisposal? nestedInputManagerDisable;
private Vector2 lastDrawSize;
@ -105,6 +108,7 @@ namespace osu.Game.Overlays.SkinEditor
if (skinEditor != null)
{
disableNestedInputManagers();
skinEditor.Show();
return;
}
@ -132,6 +136,8 @@ namespace osu.Game.Overlays.SkinEditor
{
skinEditor?.Save(false);
skinEditor?.Hide();
nestedInputManagerDisable?.Dispose();
nestedInputManagerDisable = null;
globallyReenableBeatmapSkinSetting();
}
@ -243,6 +249,9 @@ namespace osu.Game.Overlays.SkinEditor
/// </summary>
public void SetTarget(OsuScreen screen)
{
nestedInputManagerDisable?.Dispose();
nestedInputManagerDisable = null;
lastTargetScreen = screen;
if (skinEditor == null) return;
@ -271,6 +280,7 @@ namespace osu.Game.Overlays.SkinEditor
{
skinEditor.Save(false);
skinEditor.UpdateTargetScreen(target);
disableNestedInputManagers();
}
else
{
@ -280,6 +290,21 @@ namespace osu.Game.Overlays.SkinEditor
}
}
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;