mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 02:43:16 +08:00
Merge pull request #27238 from bdach/disable-nested-managers-when-skin-editor-open
Disable nested input managers on edited screen when skin editor is open
This commit is contained in:
commit
398eaee5d0
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
@ -301,6 +302,25 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
switchToGameplayScene();
|
switchToGameplayScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRulesetInputDisabledWhenSkinEditorOpen()
|
||||||
|
{
|
||||||
|
advanceToSongSelect();
|
||||||
|
openSkinEditor();
|
||||||
|
|
||||||
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
|
||||||
|
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||||
|
|
||||||
|
switchToGameplayScene();
|
||||||
|
AddUntilStep("nested input disabled", () => ((Player)Game.ScreenStack.CurrentScreen).ChildrenOfType<PassThroughInputManager>().All(manager => !manager.UseParentInput));
|
||||||
|
|
||||||
|
toggleSkinEditor();
|
||||||
|
AddUntilStep("nested input enabled", () => ((Player)Game.ScreenStack.CurrentScreen).ChildrenOfType<PassThroughInputManager>().Any(manager => manager.UseParentInput));
|
||||||
|
|
||||||
|
toggleSkinEditor();
|
||||||
|
AddUntilStep("nested input disabled", () => ((Player)Game.ScreenStack.CurrentScreen).ChildrenOfType<PassThroughInputManager>().All(manager => !manager.UseParentInput));
|
||||||
|
}
|
||||||
|
|
||||||
private void advanceToSongSelect()
|
private void advanceToSongSelect()
|
||||||
{
|
{
|
||||||
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
|
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
|
||||||
|
@ -10,9 +10,11 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -66,6 +68,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||||
|
|
||||||
private OsuScreen? lastTargetScreen;
|
private OsuScreen? lastTargetScreen;
|
||||||
|
private InvokeOnDisposal? nestedInputManagerDisable;
|
||||||
|
|
||||||
private Vector2 lastDrawSize;
|
private Vector2 lastDrawSize;
|
||||||
|
|
||||||
@ -105,6 +108,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
|
|
||||||
if (skinEditor != null)
|
if (skinEditor != null)
|
||||||
{
|
{
|
||||||
|
disableNestedInputManagers();
|
||||||
skinEditor.Show();
|
skinEditor.Show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -132,6 +136,8 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
skinEditor?.Save(false);
|
skinEditor?.Save(false);
|
||||||
skinEditor?.Hide();
|
skinEditor?.Hide();
|
||||||
|
nestedInputManagerDisable?.Dispose();
|
||||||
|
nestedInputManagerDisable = null;
|
||||||
|
|
||||||
globallyReenableBeatmapSkinSetting();
|
globallyReenableBeatmapSkinSetting();
|
||||||
}
|
}
|
||||||
@ -243,6 +249,9 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetTarget(OsuScreen screen)
|
public void SetTarget(OsuScreen screen)
|
||||||
{
|
{
|
||||||
|
nestedInputManagerDisable?.Dispose();
|
||||||
|
nestedInputManagerDisable = null;
|
||||||
|
|
||||||
lastTargetScreen = screen;
|
lastTargetScreen = screen;
|
||||||
|
|
||||||
if (skinEditor == null) return;
|
if (skinEditor == null) return;
|
||||||
@ -271,6 +280,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
skinEditor.Save(false);
|
skinEditor.Save(false);
|
||||||
skinEditor.UpdateTargetScreen(target);
|
skinEditor.UpdateTargetScreen(target);
|
||||||
|
disableNestedInputManagers();
|
||||||
}
|
}
|
||||||
else
|
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 readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
|
||||||
private LeasedBindable<bool>? leasedBeatmapSkins;
|
private LeasedBindable<bool>? leasedBeatmapSkins;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user