1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 02:02:55 +08:00

Merge pull request #26560 from peppy/fix-skin-loss

Fix skin potentially being lost when opening and closing skin editor rapidly
This commit is contained in:
Bartłomiej Dach 2024-01-16 10:16:30 +01:00 committed by GitHub
commit a3b7943e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 4 deletions

View File

@ -35,6 +35,7 @@ using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Playlists; using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Carousel; using osu.Game.Screens.Select.Carousel;
@ -834,6 +835,24 @@ namespace osu.Game.Tests.Visual.Navigation
AddAssert("exit dialog is shown", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog is ConfirmExitDialog); AddAssert("exit dialog is shown", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog is ConfirmExitDialog);
} }
[Test]
public void TestQuickSkinEditorDoesntNukeSkin()
{
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddStep("open", () => InputManager.Key(Key.Space));
AddStep("skin", () => InputManager.Key(Key.E));
AddStep("editor", () => InputManager.Key(Key.S));
AddStep("and close immediately", () => InputManager.Key(Key.Escape));
AddStep("open again", () => InputManager.Key(Key.S));
Player player = null;
AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
AddUntilStep("wait for gameplay still has health bar", () => player.ChildrenOfType<ArgonHealthDisplay>().Any());
}
[Test] [Test]
public void TestTouchScreenDetectionAtSongSelect() public void TestTouchScreenDetectionAtSongSelect()
{ {

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays.SkinEditor
protected override bool StartHidden => true; protected override bool StartHidden => true;
private Drawable targetScreen = null!; private Drawable? targetScreen;
private OsuTextFlowContainer headerText = null!; private OsuTextFlowContainer headerText = null!;
@ -541,8 +541,14 @@ namespace osu.Game.Overlays.SkinEditor
if (!hasBegunMutating) if (!hasBegunMutating)
return; return;
if (targetScreen?.IsLoaded != true)
return;
SkinComponentsContainer[] targetContainers = availableTargets.ToArray(); SkinComponentsContainer[] targetContainers = availableTargets.ToArray();
if (!targetContainers.All(c => c.ComponentsLoaded))
return;
foreach (var t in targetContainers) foreach (var t in targetContainers)
currentSkin.Value.UpdateDrawableTarget(t); currentSkin.Value.UpdateDrawableTarget(t);

View File

@ -136,10 +136,15 @@ namespace osu.Game.Overlays.SkinEditor
globallyReenableBeatmapSkinSetting(); globallyReenableBeatmapSkinSetting();
} }
public void PresentGameplay() public void PresentGameplay() => presentGameplay(false);
private void presentGameplay(bool attemptedBeatmapSwitch)
{ {
performer?.PerformFromScreen(screen => performer?.PerformFromScreen(screen =>
{ {
if (State.Value != Visibility.Visible)
return;
if (beatmap.Value is DummyWorkingBeatmap) if (beatmap.Value is DummyWorkingBeatmap)
{ {
// presume we don't have anything good to play and just bail. // presume we don't have anything good to play and just bail.
@ -149,8 +154,12 @@ namespace osu.Game.Overlays.SkinEditor
// If we're playing the intro, switch away to another beatmap. // If we're playing the intro, switch away to another beatmap.
if (beatmap.Value.BeatmapSetInfo.Protected) if (beatmap.Value.BeatmapSetInfo.Protected)
{ {
music.NextTrack(); if (!attemptedBeatmapSwitch)
Schedule(PresentGameplay); {
music.NextTrack();
Schedule(() => presentGameplay(true));
}
return; return;
} }