mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge branch 'master' into sample-point-multiple
This commit is contained in:
@ -14,6 +14,7 @@ using osu.Game.Screens.Backgrounds;
|
|||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||||
using osu.Game.Screens.Edit.GameplayTest;
|
using osu.Game.Screens.Edit.GameplayTest;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -150,6 +151,35 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning);
|
AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSharedClockState()
|
||||||
|
{
|
||||||
|
AddStep("seek to 00:01:00", () => EditorClock.Seek(60_000));
|
||||||
|
AddStep("click test gameplay button", () =>
|
||||||
|
{
|
||||||
|
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(button);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
EditorPlayer editorPlayer = null;
|
||||||
|
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||||
|
|
||||||
|
GameplayClockContainer gameplayClockContainer = null;
|
||||||
|
AddStep("fetch gameplay clock", () => gameplayClockContainer = editorPlayer.ChildrenOfType<GameplayClockContainer>().First());
|
||||||
|
AddUntilStep("gameplay clock running", () => gameplayClockContainer.IsRunning);
|
||||||
|
AddAssert("gameplay time past 00:01:00", () => gameplayClockContainer.CurrentTime >= 60_000);
|
||||||
|
|
||||||
|
double timeAtPlayerExit = 0;
|
||||||
|
AddWaitStep("wait some", 5);
|
||||||
|
AddStep("store time before exit", () => timeAtPlayerExit = gameplayClockContainer.CurrentTime);
|
||||||
|
|
||||||
|
AddStep("exit player", () => editorPlayer.Exit());
|
||||||
|
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||||
|
AddAssert("time is past player exit", () => EditorClock.CurrentTime >= timeAtPlayerExit);
|
||||||
|
}
|
||||||
|
|
||||||
public override void TearDownSteps()
|
public override void TearDownSteps()
|
||||||
{
|
{
|
||||||
base.TearDownSteps();
|
base.TearDownSteps();
|
||||||
|
@ -31,12 +31,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||||
AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State.Value == Visibility.Visible);
|
AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
// The pause screen and fail animation both ramp frequency.
|
||||||
|
// This tests to ensure that it doesn't reset during that handoff.
|
||||||
|
AddAssert("frequency only ever decreased", () => !((FailPlayer)Player).FrequencyIncreased);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FailPlayer : TestPlayer
|
private class FailPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
public new FailOverlay FailOverlay => base.FailOverlay;
|
public new FailOverlay FailOverlay => base.FailOverlay;
|
||||||
|
|
||||||
|
public bool FrequencyIncreased { get; private set; }
|
||||||
|
|
||||||
public FailPlayer()
|
public FailPlayer()
|
||||||
: base(false, false)
|
: base(false, false)
|
||||||
{
|
{
|
||||||
@ -47,6 +53,19 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
HealthProcessor.FailConditions += (_, __) => true;
|
HealthProcessor.FailConditions += (_, __) => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double lastFrequency = double.MaxValue;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
double freq = Beatmap.Value.Track.AggregateFrequency.Value;
|
||||||
|
|
||||||
|
FrequencyIncreased |= freq > lastFrequency;
|
||||||
|
|
||||||
|
lastFrequency = freq;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,6 +325,19 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an <see cref="EditorState"/> instance representing the current state of the editor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nextBeatmap">
|
||||||
|
/// The next beatmap to be shown, in the case of difficulty switch.
|
||||||
|
/// <see langword="null"/> indicates that the beatmap will not be changing.
|
||||||
|
/// </param>
|
||||||
|
public EditorState GetState([CanBeNull] BeatmapInfo nextBeatmap = null) => new EditorState
|
||||||
|
{
|
||||||
|
Time = clock.CurrentTimeAccurate,
|
||||||
|
ClipboardContent = nextBeatmap == null || editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore the editor to a provided state.
|
/// Restore the editor to a provided state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -780,11 +793,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, new EditorState
|
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, GetState(nextBeatmap));
|
||||||
{
|
|
||||||
Time = clock.CurrentTimeAccurate,
|
|
||||||
ClipboardContent = editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty
|
|
||||||
});
|
|
||||||
|
|
||||||
private void cancelExit()
|
private void cancelExit()
|
||||||
{
|
{
|
||||||
@ -807,7 +816,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
pushEditorPlayer();
|
pushEditorPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushEditorPlayer() => this.Push(new EditorPlayerLoader());
|
void pushEditorPlayer() => this.Push(new EditorPlayerLoader(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
@ -10,14 +11,22 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
{
|
{
|
||||||
public class EditorPlayer : Player
|
public class EditorPlayer : Player
|
||||||
{
|
{
|
||||||
public EditorPlayer()
|
private readonly Editor editor;
|
||||||
: base(new PlayerConfiguration { ShowResults = false })
|
private readonly EditorState editorState;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController musicController { get; set; }
|
private MusicController musicController { get; set; }
|
||||||
|
|
||||||
|
public EditorPlayer(Editor editor)
|
||||||
|
: base(new PlayerConfiguration { ShowResults = false })
|
||||||
|
{
|
||||||
|
this.editor = editor;
|
||||||
|
editorState = editor.GetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||||
|
=> new MasterGameplayClockContainer(beatmap, editorState.Time, true);
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -35,9 +44,22 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
|
|
||||||
protected override bool CheckModsAllowFailure() => false; // never fail.
|
protected override bool CheckModsAllowFailure() => false; // never fail.
|
||||||
|
|
||||||
|
public override void OnEntering(IScreen last)
|
||||||
|
{
|
||||||
|
base.OnEntering(last);
|
||||||
|
|
||||||
|
// finish alpha transforms on entering to avoid gameplay starting in a half-hidden state.
|
||||||
|
// the finish calls are purposefully not propagated to children to avoid messing up their state.
|
||||||
|
FinishTransforms();
|
||||||
|
GameplayClockContainer.FinishTransforms(false, nameof(Alpha));
|
||||||
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
musicController.Stop();
|
musicController.Stop();
|
||||||
|
|
||||||
|
editorState.Time = GameplayClockContainer.CurrentTime;
|
||||||
|
editor.RestoreState(editorState);
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuLogo osuLogo { get; set; }
|
private OsuLogo osuLogo { get; set; }
|
||||||
|
|
||||||
public EditorPlayerLoader()
|
public EditorPlayerLoader(Editor editor)
|
||||||
: base(() => new EditorPlayer())
|
: base(() => new EditorPlayer(editor))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
this.TransformBindableTo(trackFreq, 0, duration).OnComplete(_ =>
|
this.TransformBindableTo(trackFreq, 0, duration).OnComplete(_ =>
|
||||||
{
|
{
|
||||||
RemoveFilters();
|
// Don't reset frequency as the pause screen may appear post transform, causing a second frequency sweep.
|
||||||
|
RemoveFilters(false);
|
||||||
OnComplete?.Invoke();
|
OnComplete?.Invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -137,15 +138,16 @@ namespace osu.Game.Screens.Play
|
|||||||
Content.FadeColour(Color4.Gray, duration);
|
Content.FadeColour(Color4.Gray, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveFilters()
|
public void RemoveFilters(bool resetTrackFrequency = true)
|
||||||
{
|
{
|
||||||
|
if (resetTrackFrequency)
|
||||||
|
track?.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq);
|
||||||
|
|
||||||
if (filters.Parent == null)
|
if (filters.Parent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RemoveInternal(filters);
|
RemoveInternal(filters);
|
||||||
filters.Dispose();
|
filters.Dispose();
|
||||||
|
|
||||||
track?.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Reference in New Issue
Block a user