mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:43:10 +08:00
Restore editor clock time after difficulty switch
This commit is contained in:
parent
80e54d51f2
commit
3fc72271f1
@ -476,6 +476,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
});
|
});
|
||||||
|
|
||||||
resetTrack(true);
|
resetTrack(true);
|
||||||
|
if (loader?.State != null)
|
||||||
|
restoreState(loader.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
@ -740,7 +742,16 @@ namespace osu.Game.Screens.Edit
|
|||||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SwitchToDifficulty(BeatmapInfo beatmapInfo) => loader?.ScheduleDifficultySwitch(beatmapInfo);
|
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, new EditorState
|
||||||
|
{
|
||||||
|
Time = clock.CurrentTimeAccurate
|
||||||
|
});
|
||||||
|
|
||||||
|
private void restoreState([NotNull] EditorState state)
|
||||||
|
{
|
||||||
|
if (state.Time != null)
|
||||||
|
clock.Seek(state.Time.Value);
|
||||||
|
}
|
||||||
|
|
||||||
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
|
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
|
||||||
|
|
||||||
|
@ -20,6 +20,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorLoader : ScreenWithBeatmapBackground
|
public class EditorLoader : ScreenWithBeatmapBackground
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The stored state from the last editor opened.
|
||||||
|
/// This will be read by the next editor instance to be opened to restore any relevant previous state.
|
||||||
|
/// </summary>
|
||||||
|
[CanBeNull]
|
||||||
|
public EditorState State;
|
||||||
|
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowBackButton => false;
|
||||||
@ -61,7 +68,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScheduleDifficultySwitch(BeatmapInfo beatmapInfo)
|
public void ScheduleDifficultySwitch(BeatmapInfo nextBeatmap, EditorState editorState)
|
||||||
{
|
{
|
||||||
scheduledDifficultySwitch?.Cancel();
|
scheduledDifficultySwitch?.Cancel();
|
||||||
ValidForResume = true;
|
ValidForResume = true;
|
||||||
@ -70,7 +77,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
scheduledDifficultySwitch = Schedule(() =>
|
scheduledDifficultySwitch = Schedule(() =>
|
||||||
{
|
{
|
||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(beatmapInfo);
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(nextBeatmap);
|
||||||
|
State = editorState;
|
||||||
|
|
||||||
// This screen is a weird exception to the rule that nothing after song select changes the global beatmap.
|
// This screen is a weird exception to the rule that nothing after song select changes the global beatmap.
|
||||||
// Because of this, we need to update the background stack's beatmap to match.
|
// Because of this, we need to update the background stack's beatmap to match.
|
||||||
|
19
osu.Game/Screens/Edit/EditorState.cs
Normal file
19
osu.Game/Screens/Edit/EditorState.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Structure used to transport data between <see cref="Editor"/> instances on difficulty change.
|
||||||
|
/// It's intended to be received by <see cref="EditorLoader"/> from one editor instance and passed down to the next one.
|
||||||
|
/// </summary>
|
||||||
|
public class EditorState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current clock time when a difficulty switch was requested.
|
||||||
|
/// </summary>
|
||||||
|
public double? Time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user