mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Show gameplay when loading the skin editor from the main menu
This commit is contained in:
parent
55df8e81b9
commit
95229cb336
@ -1,7 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -9,12 +12,21 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.SkinEditor
|
||||
@ -31,12 +43,21 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
private SkinEditor? skinEditor;
|
||||
|
||||
[Resolved]
|
||||
private IPerformFromScreenRunner? performer { get; set; }
|
||||
|
||||
[Cached]
|
||||
public readonly EditorClipboard Clipboard = new EditorClipboard();
|
||||
|
||||
[Resolved]
|
||||
private OsuGame game { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
private OsuScreen? lastTargetScreen;
|
||||
|
||||
private Vector2 lastDrawSize;
|
||||
@ -72,6 +93,9 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
{
|
||||
globallyDisableBeatmapSkinSetting();
|
||||
|
||||
if (lastTargetScreen is MainMenu)
|
||||
PresentGameplay();
|
||||
|
||||
if (skinEditor != null)
|
||||
{
|
||||
skinEditor.Show();
|
||||
@ -105,6 +129,28 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
globallyReenableBeatmapSkinSetting();
|
||||
}
|
||||
|
||||
public void PresentGameplay()
|
||||
{
|
||||
performer?.PerformFromScreen(screen =>
|
||||
{
|
||||
if (screen is Player)
|
||||
return;
|
||||
|
||||
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
|
||||
IReadOnlyList<Mod> usableMods = mods.Value;
|
||||
|
||||
if (replayGeneratingMod != null)
|
||||
usableMods = usableMods.Append(replayGeneratingMod).ToArray();
|
||||
|
||||
if (!ModUtils.CheckCompatibleSet(usableMods, out var invalid))
|
||||
mods.Value = mods.Value.Except(invalid).ToArray();
|
||||
|
||||
if (replayGeneratingMod != null)
|
||||
screen.Push(new EndlessPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods)));
|
||||
}, new[] { typeof(Player), typeof(PlaySongSelect) });
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -222,5 +268,24 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
leasedBeatmapSkins?.Return();
|
||||
leasedBeatmapSkins = null;
|
||||
}
|
||||
|
||||
private partial class EndlessPlayer : ReplayPlayer
|
||||
{
|
||||
public EndlessPlayer(Func<IBeatmap, IReadOnlyList<Mod>, Score> createScore)
|
||||
: base(createScore, new PlayerConfiguration
|
||||
{
|
||||
ShowResults = false,
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (GameplayState.HasPassed)
|
||||
GameplayClockContainer.Seek(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -14,12 +11,8 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.SkinEditor
|
||||
@ -36,10 +29,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
private IPerformFromScreenRunner? performer { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
private SkinEditorOverlay skinEditorOverlay { get; set; } = null!;
|
||||
|
||||
public SkinEditorSceneLibrary()
|
||||
{
|
||||
@ -96,24 +86,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
Text = SkinEditorStrings.Gameplay,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Action = () => performer?.PerformFromScreen(screen =>
|
||||
{
|
||||
if (screen is Player)
|
||||
return;
|
||||
|
||||
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
|
||||
IReadOnlyList<Mod> usableMods = mods.Value;
|
||||
|
||||
if (replayGeneratingMod != null)
|
||||
usableMods = usableMods.Append(replayGeneratingMod).ToArray();
|
||||
|
||||
if (!ModUtils.CheckCompatibleSet(usableMods, out var invalid))
|
||||
mods.Value = mods.Value.Except(invalid).ToArray();
|
||||
|
||||
if (replayGeneratingMod != null)
|
||||
screen.Push(new PlayerLoader(() => new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods))));
|
||||
}, new[] { typeof(Player), typeof(PlaySongSelect) })
|
||||
Action = () => skinEditorOverlay.PresentGameplay(),
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -137,5 +110,6 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
Content.CornerRadius = 5;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user