mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 13:25:35 +08:00
Merge branch 'master' into slider-merger
This commit is contained in:
commit
615c5cf6ae
@ -43,6 +43,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Setup
|
|||||||
private void updateBeatmap()
|
private void updateBeatmap()
|
||||||
{
|
{
|
||||||
Beatmap.BeatmapInfo.SpecialStyle = specialStyle.Current.Value;
|
Beatmap.BeatmapInfo.SpecialStyle = specialStyle.Current.Value;
|
||||||
|
Beatmap.SaveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
|
|
||||||
public override string Acronym => "CS";
|
public override string Acronym => "CS";
|
||||||
|
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 0.9;
|
||||||
|
|
||||||
public override string Description => "No more tricky speed changes!";
|
public override string Description => "No more tricky speed changes!";
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
{
|
{
|
||||||
Mod = mod,
|
Mod = mod,
|
||||||
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 &&
|
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 &&
|
||||||
Precision.AlmostEquals(Player.GameplayClockContainer.GameplayClock.Rate, mod.SpeedChange.Value)
|
Precision.AlmostEquals(Player.GameplayClockContainer.Rate, mod.SpeedChange.Value)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,7 +10,6 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -36,16 +33,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
private const double spinner_duration = 6000;
|
private const double spinner_duration = 6000;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audioManager { get; set; }
|
private AudioManager audioManager { get; set; } = null!;
|
||||||
|
|
||||||
protected override bool Autoplay => true;
|
protected override bool Autoplay => true;
|
||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new ScoreExposedPlayer();
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new ScoreExposedPlayer();
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
|
||||||
=> new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
=> new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
||||||
|
|
||||||
private DrawableSpinner drawableSpinner;
|
private DrawableSpinner drawableSpinner = null!;
|
||||||
private SpriteIcon spinnerSymbol => drawableSpinner.ChildrenOfType<SpriteIcon>().Single();
|
private SpriteIcon spinnerSymbol => drawableSpinner.ChildrenOfType<SpriteIcon>().Single();
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
@ -67,12 +64,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
||||||
});
|
});
|
||||||
AddAssert("is disc rotation not almost 0", () => !Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, 100));
|
AddAssert("is disc rotation not almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.Not.EqualTo(0).Within(100));
|
||||||
AddAssert("is disc rotation absolute not almost 0", () => !Precision.AlmostEquals(drawableSpinner.Result.RateAdjustedRotation, 0, 100));
|
AddAssert("is disc rotation absolute not almost 0", () => drawableSpinner.Result.RateAdjustedRotation, () => Is.Not.EqualTo(0).Within(100));
|
||||||
|
|
||||||
addSeekStep(0);
|
addSeekStep(0);
|
||||||
AddAssert("is disc rotation almost 0", () => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, trackerRotationTolerance));
|
AddAssert("is disc rotation almost 0", () => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(0).Within(trackerRotationTolerance));
|
||||||
AddAssert("is disc rotation absolute almost 0", () => Precision.AlmostEquals(drawableSpinner.Result.RateAdjustedRotation, 0, 100));
|
AddAssert("is disc rotation absolute almost 0", () => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(0).Within(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -100,20 +97,20 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
// we want to make sure that the rotation at time 2500 is in the same direction as at time 5000, but about half-way in.
|
// we want to make sure that the rotation at time 2500 is in the same direction as at time 5000, but about half-way in.
|
||||||
// due to the exponential damping applied we're allowing a larger margin of error of about 10%
|
// due to the exponential damping applied we're allowing a larger margin of error of about 10%
|
||||||
// (5% relative to the final rotation value, but we're half-way through the spin).
|
// (5% relative to the final rotation value, but we're half-way through the spin).
|
||||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation / 2, trackerRotationTolerance));
|
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation / 2).Within(trackerRotationTolerance));
|
||||||
AddAssert("symbol rotation rewound",
|
AddAssert("symbol rotation rewound",
|
||||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation / 2, spinnerSymbolRotationTolerance));
|
() => spinnerSymbol.Rotation, () => Is.EqualTo(finalSpinnerSymbolRotation / 2).Within(spinnerSymbolRotationTolerance));
|
||||||
AddAssert("is cumulative rotation rewound",
|
AddAssert("is cumulative rotation rewound",
|
||||||
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
||||||
() => Precision.AlmostEquals(drawableSpinner.Result.RateAdjustedRotation, finalCumulativeTrackerRotation / 2, 100));
|
() => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(finalCumulativeTrackerRotation / 2).Within(100));
|
||||||
|
|
||||||
addSeekStep(spinner_start_time + 5000);
|
addSeekStep(spinner_start_time + 5000);
|
||||||
AddAssert("is disc rotation almost same",
|
AddAssert("is disc rotation almost same",
|
||||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation, trackerRotationTolerance));
|
() => drawableSpinner.RotationTracker.Rotation, () => Is.EqualTo(finalTrackerRotation).Within(trackerRotationTolerance));
|
||||||
AddAssert("is symbol rotation almost same",
|
AddAssert("is symbol rotation almost same",
|
||||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation, spinnerSymbolRotationTolerance));
|
() => spinnerSymbol.Rotation, () => Is.EqualTo(finalSpinnerSymbolRotation).Within(spinnerSymbolRotationTolerance));
|
||||||
AddAssert("is cumulative rotation almost same",
|
AddAssert("is cumulative rotation almost same",
|
||||||
() => Precision.AlmostEquals(drawableSpinner.Result.RateAdjustedRotation, finalCumulativeTrackerRotation, 100));
|
() => drawableSpinner.Result.RateAdjustedRotation, () => Is.EqualTo(finalCumulativeTrackerRotation).Within(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -177,10 +174,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddStep("retrieve spm", () => estimatedSpm = drawableSpinner.SpinsPerMinute.Value);
|
AddStep("retrieve spm", () => estimatedSpm = drawableSpinner.SpinsPerMinute.Value);
|
||||||
|
|
||||||
addSeekStep(2000);
|
addSeekStep(2000);
|
||||||
AddAssert("spm still valid", () => Precision.AlmostEquals(drawableSpinner.SpinsPerMinute.Value, estimatedSpm, 1.0));
|
AddAssert("spm still valid", () => drawableSpinner.SpinsPerMinute.Value, () => Is.EqualTo(estimatedSpm).Within(1.0));
|
||||||
|
|
||||||
addSeekStep(1000);
|
addSeekStep(1000);
|
||||||
AddAssert("spm still valid", () => Precision.AlmostEquals(drawableSpinner.SpinsPerMinute.Value, estimatedSpm, 1.0));
|
AddAssert("spm still valid", () => drawableSpinner.SpinsPerMinute.Value, () => Is.EqualTo(estimatedSpm).Within(1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(0.5)]
|
[TestCase(0.5)]
|
||||||
@ -202,14 +199,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddStep("adjust track rate", () => ((MasterGameplayClockContainer)Player.GameplayClockContainer).UserPlaybackRate.Value = rate);
|
AddStep("adjust track rate", () => ((MasterGameplayClockContainer)Player.GameplayClockContainer).UserPlaybackRate.Value = rate);
|
||||||
|
|
||||||
addSeekStep(1000);
|
addSeekStep(1000);
|
||||||
AddAssert("progress almost same", () => Precision.AlmostEquals(expectedProgress, drawableSpinner.Progress, 0.05));
|
AddAssert("progress almost same", () => expectedProgress, () => Is.EqualTo(drawableSpinner.Progress).Within(0.05));
|
||||||
AddAssert("spm almost same", () => Precision.AlmostEquals(expectedSpm, drawableSpinner.SpinsPerMinute.Value, 2.0));
|
AddAssert("spm almost same", () => expectedSpm, () => Is.EqualTo(drawableSpinner.SpinsPerMinute.Value).Within(2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSeekStep(double time)
|
private void addSeekStep(double time)
|
||||||
{
|
{
|
||||||
AddStep($"seek to {time}", () => Player.GameplayClockContainer.Seek(time));
|
AddStep($"seek to {time}", () => Player.GameplayClockContainer.Seek(time));
|
||||||
AddUntilStep("wait for seek to finish", () => Precision.AlmostEquals(time, Player.DrawableRuleset.FrameStableClock.CurrentTime, 100));
|
AddUntilStep("wait for seek to finish", () => time, () => Is.EqualTo(Player.DrawableRuleset.FrameStableClock.CurrentTime).Within(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformReplay(Func<Replay, Replay> replayTransformation) => AddStep("set replay", () =>
|
private void transformReplay(Func<Replay, Replay> replayTransformation) => AddStep("set replay", () =>
|
||||||
|
@ -49,6 +49,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Setup
|
|||||||
private void updateBeatmap()
|
private void updateBeatmap()
|
||||||
{
|
{
|
||||||
Beatmap.BeatmapInfo.StackLeniency = stackLeniency.Current.Value;
|
Beatmap.BeatmapInfo.StackLeniency = stackLeniency.Current.Value;
|
||||||
|
Beatmap.SaveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public override IconUsage? Icon => OsuIcon.ModAutopilot;
|
public override IconUsage? Icon => OsuIcon.ModAutopilot;
|
||||||
public override ModType Type => ModType.Automation;
|
public override ModType Type => ModType.Automation;
|
||||||
public override string Description => @"Automatic cursor movement - just follow the rhythm.";
|
public override string Description => @"Automatic cursor movement - just follow the rhythm.";
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 0.1;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModFailCondition), typeof(ModNoFail), typeof(ModAutoplay), typeof(OsuModMagnetised), typeof(OsuModRepel) };
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModFailCondition), typeof(ModNoFail), typeof(ModAutoplay), typeof(OsuModMagnetised), typeof(OsuModRepel) };
|
||||||
|
|
||||||
public bool PerformFail() => false;
|
public bool PerformFail() => false;
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public override IconUsage? Icon => FontAwesome.Solid.Magnet;
|
public override IconUsage? Icon => FontAwesome.Solid.Magnet;
|
||||||
public override ModType Type => ModType.Fun;
|
public override ModType Type => ModType.Fun;
|
||||||
public override string Description => "No need to chase the circles – your cursor is a magnet!";
|
public override string Description => "No need to chase the circles – your cursor is a magnet!";
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 0.5;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay), typeof(OsuModRelax), typeof(OsuModRepel) };
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModAutopilot), typeof(OsuModWiggle), typeof(OsuModTransform), typeof(ModAutoplay), typeof(OsuModRelax), typeof(OsuModRepel) };
|
||||||
|
|
||||||
private IFrameStableClock gameplayClock = null!;
|
private IFrameStableClock gameplayClock = null!;
|
||||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
private bool rotationTransferred;
|
private bool rotationTransferred;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("start clock", () => gameplayClockContainer.Start());
|
AddStep("start clock", () => gameplayClockContainer.Start());
|
||||||
AddUntilStep("elapsed greater than zero", () => gameplayClockContainer.GameplayClock.ElapsedFrameTime > 0);
|
AddUntilStep("elapsed greater than zero", () => gameplayClockContainer.ElapsedFrameTime > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -60,16 +60,16 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("start clock", () => gameplayClockContainer.Start());
|
AddStep("start clock", () => gameplayClockContainer.Start());
|
||||||
AddUntilStep("current time greater 2000", () => gameplayClockContainer.GameplayClock.CurrentTime > 2000);
|
AddUntilStep("current time greater 2000", () => gameplayClockContainer.CurrentTime > 2000);
|
||||||
|
|
||||||
double timeAtReset = 0;
|
double timeAtReset = 0;
|
||||||
AddStep("reset clock", () =>
|
AddStep("reset clock", () =>
|
||||||
{
|
{
|
||||||
timeAtReset = gameplayClockContainer.GameplayClock.CurrentTime;
|
timeAtReset = gameplayClockContainer.CurrentTime;
|
||||||
gameplayClockContainer.Reset();
|
gameplayClockContainer.Reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("current time < time at reset", () => gameplayClockContainer.GameplayClock.CurrentTime < timeAtReset);
|
AddAssert("current time < time at reset", () => gameplayClockContainer.CurrentTime < timeAtReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -77,7 +77,6 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
||||||
{
|
{
|
||||||
IsPaused = { Value = true },
|
|
||||||
Child = new FrameStabilityContainer
|
Child = new FrameStabilityContainer
|
||||||
{
|
{
|
||||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
@ -106,7 +105,6 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
||||||
{
|
{
|
||||||
StartTime = start_time,
|
StartTime = start_time,
|
||||||
IsPaused = { Value = true },
|
|
||||||
Child = new FrameStabilityContainer
|
Child = new FrameStabilityContainer
|
||||||
{
|
{
|
||||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
@ -141,7 +139,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
|
beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
|
||||||
{
|
{
|
||||||
Clock = gameplayContainer.GameplayClock
|
Clock = gameplayContainer
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -30,7 +31,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
public List<Bindable<double>> MutableNonGameplayAdjustments { get; } = new List<Bindable<double>>();
|
public List<Bindable<double>> MutableNonGameplayAdjustments { get; } = new List<Bindable<double>>();
|
||||||
|
|
||||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => MutableNonGameplayAdjustments;
|
public override IEnumerable<double> NonGameplayAdjustments => MutableNonGameplayAdjustments.Select(b => b.Value);
|
||||||
|
|
||||||
public TestGameplayClock(IFrameBasedClock underlyingClock)
|
public TestGameplayClock(IFrameBasedClock underlyingClock)
|
||||||
: base(underlyingClock)
|
: base(underlyingClock)
|
||||||
|
@ -128,6 +128,8 @@ namespace osu.Game.Tests.Resources
|
|||||||
|
|
||||||
var rulesetInfo = getRuleset();
|
var rulesetInfo = getRuleset();
|
||||||
|
|
||||||
|
string hash = Guid.NewGuid().ToString().ComputeMD5Hash();
|
||||||
|
|
||||||
yield return new BeatmapInfo
|
yield return new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineID = beatmapId,
|
OnlineID = beatmapId,
|
||||||
@ -136,7 +138,8 @@ namespace osu.Game.Tests.Resources
|
|||||||
Length = length,
|
Length = length,
|
||||||
BeatmapSet = beatmapSet,
|
BeatmapSet = beatmapSet,
|
||||||
BPM = bpm,
|
BPM = bpm,
|
||||||
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
|
Hash = hash,
|
||||||
|
MD5Hash = hash,
|
||||||
Ruleset = rulesetInfo,
|
Ruleset = rulesetInfo,
|
||||||
Metadata = metadata.DeepClone(),
|
Metadata = metadata.DeepClone(),
|
||||||
Difficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -65,7 +63,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("seek near end", () => Clock.Seek(Clock.TrackLength - 250));
|
AddStep("seek near end", () => Clock.Seek(Clock.TrackLength - 250));
|
||||||
AddUntilStep("clock stops", () => !Clock.IsRunning);
|
AddUntilStep("clock stops", () => !Clock.IsRunning);
|
||||||
|
|
||||||
AddAssert("clock stopped at end", () => Clock.CurrentTime == Clock.TrackLength);
|
AddUntilStep("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||||
|
|
||||||
AddStep("start clock again", () => Clock.Start());
|
AddStep("start clock again", () => Clock.Start());
|
||||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||||
@ -80,7 +78,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("clock stopped", () => !Clock.IsRunning);
|
AddAssert("clock stopped", () => !Clock.IsRunning);
|
||||||
|
|
||||||
AddStep("seek exactly to end", () => Clock.Seek(Clock.TrackLength));
|
AddStep("seek exactly to end", () => Clock.Seek(Clock.TrackLength));
|
||||||
AddAssert("clock stopped at end", () => Clock.CurrentTime == Clock.TrackLength);
|
AddAssert("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||||
|
|
||||||
AddStep("start clock again", () => Clock.Start());
|
AddStep("start clock again", () => Clock.Start());
|
||||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||||
@ -92,16 +90,16 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("stop clock", () => Clock.Stop());
|
AddStep("stop clock", () => Clock.Stop());
|
||||||
|
|
||||||
AddStep("seek before start time", () => Clock.Seek(-1000));
|
AddStep("seek before start time", () => Clock.Seek(-1000));
|
||||||
AddAssert("time is clamped to 0", () => Clock.CurrentTime == 0);
|
AddAssert("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
||||||
|
|
||||||
AddStep("seek beyond track length", () => Clock.Seek(Clock.TrackLength + 1000));
|
AddStep("seek beyond track length", () => Clock.Seek(Clock.TrackLength + 1000));
|
||||||
AddAssert("time is clamped to track length", () => Clock.CurrentTime == Clock.TrackLength);
|
AddAssert("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||||
|
|
||||||
AddStep("seek smoothly before start time", () => Clock.SeekSmoothlyTo(-1000));
|
AddStep("seek smoothly before start time", () => Clock.SeekSmoothlyTo(-1000));
|
||||||
AddAssert("time is clamped to 0", () => Clock.CurrentTime == 0);
|
AddUntilStep("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
||||||
|
|
||||||
AddStep("seek smoothly beyond track length", () => Clock.SeekSmoothlyTo(Clock.TrackLength + 1000));
|
AddStep("seek smoothly beyond track length", () => Clock.SeekSmoothlyTo(Clock.TrackLength + 1000));
|
||||||
AddAssert("time is clamped to track length", () => Clock.CurrentTime == Clock.TrackLength);
|
AddUntilStep("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
(typeof(ScoreProcessor), actualComponentsContainer.Dependencies.Get<ScoreProcessor>()),
|
(typeof(ScoreProcessor), actualComponentsContainer.Dependencies.Get<ScoreProcessor>()),
|
||||||
(typeof(HealthProcessor), actualComponentsContainer.Dependencies.Get<HealthProcessor>()),
|
(typeof(HealthProcessor), actualComponentsContainer.Dependencies.Get<HealthProcessor>()),
|
||||||
(typeof(GameplayState), actualComponentsContainer.Dependencies.Get<GameplayState>()),
|
(typeof(GameplayState), actualComponentsContainer.Dependencies.Get<GameplayState>()),
|
||||||
(typeof(GameplayClock), actualComponentsContainer.Dependencies.Get<GameplayClock>())
|
(typeof(IGameplayClock), actualComponentsContainer.Dependencies.Get<IGameplayClock>())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,13 +137,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);
|
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);
|
||||||
|
|
||||||
private void confirmSeek(double time) => AddUntilStep($"wait for seek to {time}", () => consumer.Clock.CurrentTime == time);
|
private void confirmSeek(double time) => AddUntilStep($"wait for seek to {time}", () => consumer.Clock.CurrentTime, () => Is.EqualTo(time));
|
||||||
|
|
||||||
private void checkFrameCount(int frames) =>
|
private void checkFrameCount(int frames) =>
|
||||||
AddAssert($"elapsed frames is {frames}", () => consumer.ElapsedFrames == frames);
|
AddAssert($"elapsed frames is {frames}", () => consumer.ElapsedFrames, () => Is.EqualTo(frames));
|
||||||
|
|
||||||
private void checkRate(double rate) =>
|
private void checkRate(double rate) =>
|
||||||
AddAssert($"clock rate is {rate}", () => consumer.Clock.Rate == rate);
|
AddAssert($"clock rate is {rate}", () => consumer.Clock.Rate, () => Is.EqualTo(rate));
|
||||||
|
|
||||||
public class ClockConsumingChild : CompositeDrawable
|
public class ClockConsumingChild : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -21,22 +19,22 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAllSamplesStopDuringSeek()
|
public void TestAllSamplesStopDuringSeek()
|
||||||
{
|
{
|
||||||
DrawableSlider slider = null;
|
DrawableSlider? slider = null;
|
||||||
PoolableSkinnableSample[] samples = null;
|
PoolableSkinnableSample[] samples = null!;
|
||||||
ISamplePlaybackDisabler sampleDisabler = null;
|
ISamplePlaybackDisabler sampleDisabler = null!;
|
||||||
|
|
||||||
AddUntilStep("get variables", () =>
|
AddUntilStep("get variables", () =>
|
||||||
{
|
{
|
||||||
sampleDisabler = Player;
|
sampleDisabler = Player;
|
||||||
slider = Player.ChildrenOfType<DrawableSlider>().MinBy(s => s.HitObject.StartTime);
|
slider = Player.ChildrenOfType<DrawableSlider>().MinBy(s => s.HitObject.StartTime);
|
||||||
samples = slider?.ChildrenOfType<PoolableSkinnableSample>().ToArray();
|
samples = slider.ChildrenOfType<PoolableSkinnableSample>().ToArray();
|
||||||
|
|
||||||
return slider != null;
|
return slider != null;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for slider sliding then seek", () =>
|
AddUntilStep("wait for slider sliding then seek", () =>
|
||||||
{
|
{
|
||||||
if (!slider.Tracking.Value)
|
if (slider?.Tracking.Value != true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!samples.Any(s => s.Playing))
|
if (!samples.Any(s => s.Playing))
|
||||||
|
@ -38,8 +38,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
// best way to check without exposing.
|
// best way to check without exposing.
|
||||||
private Drawable hideTarget => hudOverlay.KeyCounter;
|
private Drawable hideTarget => hudOverlay.KeyCounter;
|
||||||
|
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime;
|
public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime;
|
||||||
|
|
||||||
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
public double GameplayClockTime => GameplayClockContainer.CurrentTime;
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
if (!FirstFrameClockTime.HasValue)
|
if (!FirstFrameClockTime.HasValue)
|
||||||
{
|
{
|
||||||
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
FirstFrameClockTime = GameplayClockContainer.CurrentTime;
|
||||||
AddInternal(new OsuSpriteText
|
AddInternal(new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
AddUntilStep("gameplay has started",
|
AddUntilStep("gameplay has started",
|
||||||
() => Player.GameplayClockContainer.GameplayClock.CurrentTime > Player.DrawableRuleset.GameplayStartTime);
|
() => Player.GameplayClockContainer.CurrentTime > Player.DrawableRuleset.GameplayStartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -313,7 +313,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("pause again", () =>
|
AddUntilStep("pause again", () =>
|
||||||
{
|
{
|
||||||
Player.Pause();
|
Player.Pause();
|
||||||
return !Player.GameplayClockContainer.GameplayClock.IsRunning;
|
return !Player.GameplayClockContainer.IsRunning;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
||||||
@ -378,7 +378,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
|
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
|
||||||
|
|
||||||
private void confirmClockRunning(bool isRunning) =>
|
private void confirmClockRunning(bool isRunning) =>
|
||||||
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.GameplayClock.IsRunning == isRunning);
|
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.IsRunning == isRunning);
|
||||||
|
|
||||||
protected override bool AllowFail => true;
|
protected override bool AllowFail => true;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ using osu.Game.Screens.Play;
|
|||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
using SkipOverlay = osu.Game.Screens.Play.SkipOverlay;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
@ -56,6 +57,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly ChangelogOverlay changelogOverlay;
|
private readonly ChangelogOverlay changelogOverlay;
|
||||||
|
|
||||||
|
private double savedTrackVolume;
|
||||||
|
private double savedMasterVolume;
|
||||||
|
private bool savedMutedState;
|
||||||
|
|
||||||
public TestScenePlayerLoader()
|
public TestScenePlayerLoader()
|
||||||
{
|
{
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
@ -75,11 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() => player = null);
|
||||||
{
|
|
||||||
player = null;
|
|
||||||
audioManager.Volume.SetDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the input manager child to a new test player loader container instance.
|
/// Sets the input manager child to a new test player loader container instance.
|
||||||
@ -98,7 +99,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private void prepareBeatmap()
|
private void prepareBeatmap()
|
||||||
{
|
{
|
||||||
var workingBeatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
var workingBeatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
|
||||||
|
// Add intro time to test quick retry skipping (TestQuickRetry).
|
||||||
|
workingBeatmap.BeatmapInfo.AudioLeadIn = 60000;
|
||||||
|
|
||||||
|
// Turn on epilepsy warning to test warning display (TestEpilepsyWarning).
|
||||||
workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning;
|
workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning;
|
||||||
|
|
||||||
Beatmap.Value = workingBeatmap;
|
Beatmap.Value = workingBeatmap;
|
||||||
|
|
||||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
|
||||||
@ -147,6 +154,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
moveMouse();
|
moveMouse();
|
||||||
return player?.LoadState == LoadState.Ready;
|
return player?.LoadState == LoadState.Ready;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddRepeatStep("move mouse", moveMouse, 20);
|
AddRepeatStep("move mouse", moveMouse, 20);
|
||||||
|
|
||||||
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
||||||
@ -154,6 +162,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
void moveMouse()
|
void moveMouse()
|
||||||
{
|
{
|
||||||
|
notificationOverlay.State.Value = Visibility.Hidden;
|
||||||
|
|
||||||
InputManager.MoveMouseTo(
|
InputManager.MoveMouseTo(
|
||||||
loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft
|
loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft
|
||||||
+ (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft)
|
+ (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft)
|
||||||
@ -274,6 +284,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("load player", () => resetPlayer(false, beforeLoad));
|
AddStep("load player", () => resetPlayer(false, beforeLoad));
|
||||||
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
||||||
|
|
||||||
|
saveVolumes();
|
||||||
|
|
||||||
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
||||||
AddStep("click notification", () =>
|
AddStep("click notification", () =>
|
||||||
{
|
{
|
||||||
@ -287,6 +299,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddAssert("check " + volumeName, assert);
|
AddAssert("check " + volumeName, assert);
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
|
|
||||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,6 +308,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
public void TestEpilepsyWarning(bool warning)
|
public void TestEpilepsyWarning(bool warning)
|
||||||
{
|
{
|
||||||
|
saveVolumes();
|
||||||
|
setFullVolume();
|
||||||
|
|
||||||
AddStep("change epilepsy warning", () => epilepsyWarning = warning);
|
AddStep("change epilepsy warning", () => epilepsyWarning = warning);
|
||||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||||
|
|
||||||
@ -306,6 +323,30 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
|
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
|
||||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestEpilepsyWarningEarlyExit()
|
||||||
|
{
|
||||||
|
saveVolumes();
|
||||||
|
setFullVolume();
|
||||||
|
|
||||||
|
AddStep("set epilepsy warning", () => epilepsyWarning = true);
|
||||||
|
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||||
|
|
||||||
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
|
|
||||||
|
AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0);
|
||||||
|
AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddStep("exit early", () => loader.Exit());
|
||||||
|
|
||||||
|
AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden);
|
||||||
|
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||||
|
|
||||||
|
restoreVolumes();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(true, 1.0, false)] // on battery, above cutoff --> no warning
|
[TestCase(true, 1.0, false)] // on battery, above cutoff --> no warning
|
||||||
@ -336,21 +377,65 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
private void restoreVolumes()
|
||||||
public void TestEpilepsyWarningEarlyExit()
|
|
||||||
{
|
{
|
||||||
AddStep("set epilepsy warning", () => epilepsyWarning = true);
|
AddStep("restore previous volumes", () =>
|
||||||
|
{
|
||||||
|
audioManager.VolumeTrack.Value = savedTrackVolume;
|
||||||
|
audioManager.Volume.Value = savedMasterVolume;
|
||||||
|
volumeOverlay.IsMuted.Value = savedMutedState;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFullVolume()
|
||||||
|
{
|
||||||
|
AddStep("set volumes to 100%", () =>
|
||||||
|
{
|
||||||
|
audioManager.VolumeTrack.Value = 1;
|
||||||
|
audioManager.Volume.Value = 1;
|
||||||
|
volumeOverlay.IsMuted.Value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveVolumes()
|
||||||
|
{
|
||||||
|
AddStep("save previous volumes", () =>
|
||||||
|
{
|
||||||
|
savedTrackVolume = audioManager.VolumeTrack.Value;
|
||||||
|
savedMasterVolume = audioManager.Volume.Value;
|
||||||
|
savedMutedState = volumeOverlay.IsMuted.Value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestQuickRetry()
|
||||||
|
{
|
||||||
|
TestPlayer getCurrentPlayer() => loader.CurrentPlayer as TestPlayer;
|
||||||
|
bool checkSkipButtonVisible() => player.ChildrenOfType<SkipOverlay>().FirstOrDefault()?.IsButtonVisible == true;
|
||||||
|
|
||||||
|
TestPlayer previousPlayer = null;
|
||||||
|
|
||||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||||
|
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => getCurrentPlayer()?.IsCurrentScreen() == true);
|
||||||
|
AddStep("store previous player", () => previousPlayer = getCurrentPlayer());
|
||||||
|
|
||||||
AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0);
|
AddStep("Restart map normally", () => getCurrentPlayer().Restart());
|
||||||
AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible);
|
AddUntilStep("wait for load", () => getCurrentPlayer()?.LoadedBeatmapSuccessfully == true);
|
||||||
|
|
||||||
AddStep("exit early", () => loader.Exit());
|
AddUntilStep("restart completed", () => getCurrentPlayer() != null && getCurrentPlayer() != previousPlayer);
|
||||||
|
AddStep("store previous player", () => previousPlayer = getCurrentPlayer());
|
||||||
|
|
||||||
AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden);
|
AddUntilStep("skip button visible", checkSkipButtonVisible);
|
||||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
|
||||||
|
AddStep("press quick retry key", () => InputManager.PressKey(Key.Tilde));
|
||||||
|
AddUntilStep("restart completed", () => getCurrentPlayer() != null && getCurrentPlayer() != previousPlayer);
|
||||||
|
AddStep("release quick retry key", () => InputManager.ReleaseKey(Key.Tilde));
|
||||||
|
|
||||||
|
AddUntilStep("wait for load", () => getCurrentPlayer()?.LoadedBeatmapSuccessfully == true);
|
||||||
|
|
||||||
|
AddUntilStep("time reached zero", () => getCurrentPlayer()?.GameplayClockContainer.CurrentTime > 0);
|
||||||
|
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
||||||
|
@ -29,8 +29,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
|
@ -36,8 +36,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -22,7 +23,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private double increment;
|
private double increment;
|
||||||
|
|
||||||
private GameplayClockContainer gameplayClockContainer;
|
private GameplayClockContainer gameplayClockContainer;
|
||||||
private GameplayClock gameplayClock;
|
private IFrameBasedClock gameplayClock;
|
||||||
|
|
||||||
private const double skip_time = 6000;
|
private const double skip_time = 6000;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
};
|
};
|
||||||
|
|
||||||
gameplayClockContainer.Start();
|
gameplayClockContainer.Start();
|
||||||
gameplayClock = gameplayClockContainer.GameplayClock;
|
gameplayClock = gameplayClockContainer;
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
||||||
|
|
||||||
Dependencies.CacheAs(gameplayClockContainer.GameplayClock);
|
Dependencies.CacheAs<IGameplayClock>(gameplayClockContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -363,7 +363,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private Player player => Stack.CurrentScreen as Player;
|
private Player player => Stack.CurrentScreen as Player;
|
||||||
|
|
||||||
private double currentFrameStableTime
|
private double currentFrameStableTime
|
||||||
=> player.ChildrenOfType<FrameStabilityContainer>().First().FrameStableClock.CurrentTime;
|
=> player.ChildrenOfType<FrameStabilityContainer>().First().CurrentTime;
|
||||||
|
|
||||||
private void waitForPlayer() => AddUntilStep("wait for player", () => (Stack.CurrentScreen as Player)?.IsLoaded == true);
|
private void waitForPlayer() => AddUntilStep("wait for player", () => (Stack.CurrentScreen as Player)?.IsLoaded == true);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestStoryboardNoSkipOutro()
|
public void TestStoryboardNoSkipOutro()
|
||||||
{
|
{
|
||||||
CreateTest();
|
CreateTest();
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
|
||||||
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
|
||||||
AddUntilStep("wait for fail overlay", () => Player.FailOverlay.State.Value == Visibility.Visible);
|
AddUntilStep("wait for fail overlay", () => Player.FailOverlay.State.Value == Visibility.Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
AddStep("set ShowResults = false", () => showResults = false);
|
AddStep("set ShowResults = false", () => showResults = false);
|
||||||
});
|
});
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
|
||||||
AddWaitStep("wait", 10);
|
AddWaitStep("wait", 10);
|
||||||
AddAssert("no score shown", () => !Player.IsScoreShown);
|
AddAssert("no score shown", () => !Player.IsScoreShown);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestStoryboardEndsBeforeCompletion()
|
public void TestStoryboardEndsBeforeCompletion()
|
||||||
{
|
{
|
||||||
CreateTest(() => AddStep("set storyboard duration to .1s", () => currentStoryboardDuration = 100));
|
CreateTest(() => AddStep("set storyboard duration to .1s", () => currentStoryboardDuration = 100));
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
|
||||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||||
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("skip overlay content not visible", () => fadeContainer().State == Visibility.Hidden);
|
AddUntilStep("skip overlay content not visible", () => fadeContainer().State == Visibility.Hidden);
|
||||||
|
|
||||||
AddUntilStep("skip overlay content becomes visible", () => fadeContainer().State == Visibility.Visible);
|
AddUntilStep("skip overlay content becomes visible", () => fadeContainer().State == Visibility.Visible);
|
||||||
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= currentStoryboardDuration);
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Mods
|
|||||||
protected override TestPlayer CreateModPlayer(Ruleset ruleset)
|
protected override TestPlayer CreateModPlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
var player = base.CreateModPlayer(ruleset);
|
var player = base.CreateModPlayer(ruleset);
|
||||||
player.RestartRequested = () => restartRequested = true;
|
player.RestartRequested = _ => restartRequested = true;
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkPaused(int userId, bool state)
|
private void checkPaused(int userId, bool state)
|
||||||
=> AddUntilStep($"{userId} is {(state ? "paused" : "playing")}", () => getPlayer(userId).ChildrenOfType<GameplayClockContainer>().First().GameplayClock.IsRunning != state);
|
=> AddUntilStep($"{userId} is {(state ? "paused" : "playing")}", () => getPlayer(userId).ChildrenOfType<GameplayClockContainer>().First().IsRunning != state);
|
||||||
|
|
||||||
private void checkPausedInstant(int userId, bool state)
|
private void checkPausedInstant(int userId, bool state)
|
||||||
{
|
{
|
||||||
|
@ -671,7 +671,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
for (double i = 1000; i < TestResources.QUICK_BEATMAP_LENGTH; i += 1000)
|
for (double i = 1000; i < TestResources.QUICK_BEATMAP_LENGTH; i += 1000)
|
||||||
{
|
{
|
||||||
double time = i;
|
double time = i;
|
||||||
AddUntilStep($"wait for time > {i}", () => this.ChildrenOfType<GameplayClockContainer>().SingleOrDefault()?.GameplayClock.CurrentTime > time);
|
AddUntilStep($"wait for time > {i}", () => this.ChildrenOfType<GameplayClockContainer>().SingleOrDefault()?.CurrentTime > time);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddUntilStep("wait for results", () => multiplayerComponents.CurrentScreen is ResultsScreen);
|
AddUntilStep("wait for results", () => multiplayerComponents.CurrentScreen is ResultsScreen);
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Collections;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Overlays.Music;
|
using osu.Game.Overlays.Music;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -21,13 +23,25 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
public class TestScenePlaylistOverlay : OsuManualInputManagerTestScene
|
public class TestScenePlaylistOverlay : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private readonly BindableList<Live<BeatmapSetInfo>> beatmapSets = new BindableList<Live<BeatmapSetInfo>>();
|
protected override bool UseFreshStoragePerRun => true;
|
||||||
|
|
||||||
private PlaylistOverlay playlistOverlay;
|
private PlaylistOverlay playlistOverlay = null!;
|
||||||
|
|
||||||
private Live<BeatmapSetInfo> first;
|
private BeatmapManager beatmapManager = null!;
|
||||||
|
|
||||||
private const int item_count = 100;
|
private const int item_count = 20;
|
||||||
|
|
||||||
|
private List<BeatmapSetInfo> beatmapSets => beatmapManager.GetAllUsableBeatmapSets();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host)
|
||||||
|
{
|
||||||
|
Dependencies.Cache(new RealmRulesetStore(Realm));
|
||||||
|
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, Audio, Resources, host, Beatmap.Default));
|
||||||
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
|
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||||
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
@ -46,16 +60,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
beatmapSets.Clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < item_count; i++)
|
for (int i = 0; i < item_count; i++)
|
||||||
{
|
{
|
||||||
beatmapSets.Add(TestResources.CreateTestBeatmapSetInfo().ToLiveUnmanaged());
|
beatmapManager.Import(TestResources.CreateTestBeatmapSetInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
first = beatmapSets.First();
|
beatmapSets.First().ToLive(Realm);
|
||||||
|
|
||||||
playlistOverlay.BeatmapSets.BindTo(beatmapSets);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -70,9 +80,13 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddUntilStep("wait for animations to complete", () => !playlistOverlay.Transforms.Any());
|
AddUntilStep("wait for animations to complete", () => !playlistOverlay.Transforms.Any());
|
||||||
|
|
||||||
|
PlaylistItem firstItem = null!;
|
||||||
|
|
||||||
AddStep("hold 1st item handle", () =>
|
AddStep("hold 1st item handle", () =>
|
||||||
{
|
{
|
||||||
var handle = this.ChildrenOfType<OsuRearrangeableListItem<Live<BeatmapSetInfo>>.PlaylistItemHandle>().First();
|
firstItem = this.ChildrenOfType<PlaylistItem>().First();
|
||||||
|
var handle = firstItem.ChildrenOfType<PlaylistItem.PlaylistItemHandle>().First();
|
||||||
|
|
||||||
InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre);
|
InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre);
|
||||||
InputManager.PressButton(MouseButton.Left);
|
InputManager.PressButton(MouseButton.Left);
|
||||||
});
|
});
|
||||||
@ -83,7 +97,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.BottomLeft);
|
InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.BottomLeft);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("song 1 is 5th", () => beatmapSets[4].Equals(first));
|
AddAssert("first is moved", () => playlistOverlay.ChildrenOfType<Playlist>().Single().Items.ElementAt(4).Value.Equals(firstItem.Model.Value));
|
||||||
|
|
||||||
AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
|
AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
}
|
}
|
||||||
@ -101,6 +115,68 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
() => playlistOverlay.ChildrenOfType<PlaylistItem>()
|
() => playlistOverlay.ChildrenOfType<PlaylistItem>()
|
||||||
.Where(item => item.MatchingFilter)
|
.Where(item => item.MatchingFilter)
|
||||||
.All(item => item.FilterTerms.Any(term => term.ToString().Contains("10"))));
|
.All(item => item.FilterTerms.Any(term => term.ToString().Contains("10"))));
|
||||||
|
|
||||||
|
AddStep("Import new non-matching beatmap", () =>
|
||||||
|
{
|
||||||
|
var testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo(1);
|
||||||
|
testBeatmapSetInfo.Beatmaps.Single().Metadata.Title = "no guid";
|
||||||
|
beatmapManager.Import(testBeatmapSetInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("Force realm refresh", () => Realm.Run(r => r.Refresh()));
|
||||||
|
|
||||||
|
AddAssert("results filtered correctly",
|
||||||
|
() => playlistOverlay.ChildrenOfType<PlaylistItem>()
|
||||||
|
.Where(item => item.MatchingFilter)
|
||||||
|
.All(item => item.FilterTerms.Any(term => term.ToString().Contains("10"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCollectionFiltering()
|
||||||
|
{
|
||||||
|
NowPlayingCollectionDropdown collectionDropdown() => playlistOverlay.ChildrenOfType<NowPlayingCollectionDropdown>().Single();
|
||||||
|
|
||||||
|
AddStep("Add collection", () =>
|
||||||
|
{
|
||||||
|
Dependencies.Get<RealmAccess>().Write(r =>
|
||||||
|
{
|
||||||
|
r.RemoveAll<BeatmapCollection>();
|
||||||
|
r.Add(new BeatmapCollection("wang"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for dropdown to have new collection", () => collectionDropdown().Items.Count() == 2);
|
||||||
|
|
||||||
|
AddStep("Filter to collection", () =>
|
||||||
|
{
|
||||||
|
collectionDropdown().Current.Value = collectionDropdown().Items.Last();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("No items present", () => !playlistOverlay.ChildrenOfType<PlaylistItem>().Any(i => i.MatchingFilter));
|
||||||
|
|
||||||
|
AddStep("Import new non-matching beatmap", () =>
|
||||||
|
{
|
||||||
|
beatmapManager.Import(TestResources.CreateTestBeatmapSetInfo(1));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("Force realm refresh", () => Realm.Run(r => r.Refresh()));
|
||||||
|
|
||||||
|
AddUntilStep("No items matching", () => !playlistOverlay.ChildrenOfType<PlaylistItem>().Any(i => i.MatchingFilter));
|
||||||
|
|
||||||
|
BeatmapSetInfo collectionAddedBeatmapSet = null!;
|
||||||
|
|
||||||
|
AddStep("Import new matching beatmap", () =>
|
||||||
|
{
|
||||||
|
collectionAddedBeatmapSet = TestResources.CreateTestBeatmapSetInfo(1);
|
||||||
|
|
||||||
|
beatmapManager.Import(collectionAddedBeatmapSet);
|
||||||
|
Realm.Write(r => r.All<BeatmapCollection>().First().BeatmapMD5Hashes.Add(collectionAddedBeatmapSet.Beatmaps.First().MD5Hash));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("Force realm refresh", () => Realm.Run(r => r.Refresh()));
|
||||||
|
|
||||||
|
AddUntilStep("Only matching item",
|
||||||
|
() => playlistOverlay.ChildrenOfType<PlaylistItem>().Where(i => i.MatchingFilter).Select(i => i.Model.ID), () => Is.EquivalentTo(new[] { collectionAddedBeatmapSet.ID }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,14 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public string OnlineMD5Hash { get; set; } = string.Empty;
|
public string OnlineMD5Hash { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last time of a local modification (via the editor).
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? LastLocalUpdate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last time online metadata was applied to this beatmap.
|
||||||
|
/// </summary>
|
||||||
public DateTimeOffset? LastOnlineUpdate { get; set; }
|
public DateTimeOffset? LastOnlineUpdate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,6 +94,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
var beatmapSet = new BeatmapSetInfo
|
var beatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
|
DateAdded = DateTimeOffset.UtcNow,
|
||||||
Beatmaps =
|
Beatmaps =
|
||||||
{
|
{
|
||||||
new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
|
new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
|
||||||
@ -313,6 +314,7 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
|
beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
|
||||||
beatmapInfo.Hash = stream.ComputeSHA2Hash();
|
beatmapInfo.Hash = stream.ComputeSHA2Hash();
|
||||||
|
|
||||||
|
beatmapInfo.LastLocalUpdate = DateTimeOffset.Now;
|
||||||
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
||||||
|
|
||||||
AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo));
|
AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo));
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
foreach (string newBeatmap in existing.BeatmapMD5Hashes)
|
foreach (string newBeatmap in collection.BeatmapMD5Hashes)
|
||||||
{
|
{
|
||||||
if (!existing.BeatmapMD5Hashes.Contains(newBeatmap))
|
if (!existing.BeatmapMD5Hashes.Contains(newBeatmap))
|
||||||
existing.BeatmapMD5Hashes.Add(newBeatmap);
|
existing.BeatmapMD5Hashes.Add(newBeatmap);
|
||||||
|
@ -68,8 +68,9 @@ namespace osu.Game.Database
|
|||||||
/// 20 2022-07-21 Added LastAppliedDifficultyVersion to RulesetInfo, changed default value of BeatmapInfo.StarRating to -1.
|
/// 20 2022-07-21 Added LastAppliedDifficultyVersion to RulesetInfo, changed default value of BeatmapInfo.StarRating to -1.
|
||||||
/// 21 2022-07-27 Migrate collections to realm (BeatmapCollection).
|
/// 21 2022-07-27 Migrate collections to realm (BeatmapCollection).
|
||||||
/// 22 2022-07-31 Added ModPreset.
|
/// 22 2022-07-31 Added ModPreset.
|
||||||
|
/// 23 2022-08-01 Added LastLocalUpdate to BeatmapInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int schema_version = 22;
|
private const int schema_version = 23;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
using Markdig.Syntax.Inlines;
|
|
||||||
using osu.Framework.Graphics.Containers.Markdown;
|
using osu.Framework.Graphics.Containers.Markdown;
|
||||||
using osu.Game.Graphics.Containers.Markdown;
|
using osu.Game.Graphics.Containers.Markdown;
|
||||||
|
|
||||||
@ -12,16 +11,8 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
public class CommentMarkdownContainer : OsuMarkdownContainer
|
public class CommentMarkdownContainer : OsuMarkdownContainer
|
||||||
{
|
{
|
||||||
public override MarkdownTextFlowContainer CreateTextFlow() => new CommentMarkdownTextFlowContainer();
|
|
||||||
|
|
||||||
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
|
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
|
||||||
|
|
||||||
private class CommentMarkdownTextFlowContainer : OsuMarkdownTextFlowContainer
|
|
||||||
{
|
|
||||||
// Don't render image in comment for now
|
|
||||||
protected override void AddImage(LinkInline linkInline) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CommentMarkdownHeading : OsuMarkdownHeading
|
private class CommentMarkdownHeading : OsuMarkdownHeading
|
||||||
{
|
{
|
||||||
public CommentMarkdownHeading(HeadingBlock headingBlock)
|
public CommentMarkdownHeading(HeadingBlock headingBlock)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -17,10 +15,12 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
public class Playlist : OsuRearrangeableListContainer<Live<BeatmapSetInfo>>
|
public class Playlist : OsuRearrangeableListContainer<Live<BeatmapSetInfo>>
|
||||||
{
|
{
|
||||||
public Action<Live<BeatmapSetInfo>> RequestSelection;
|
public Action<Live<BeatmapSetInfo>>? RequestSelection;
|
||||||
|
|
||||||
public readonly Bindable<Live<BeatmapSetInfo>> SelectedSet = new Bindable<Live<BeatmapSetInfo>>();
|
public readonly Bindable<Live<BeatmapSetInfo>> SelectedSet = new Bindable<Live<BeatmapSetInfo>>();
|
||||||
|
|
||||||
|
private FilterCriteria currentCriteria = new FilterCriteria();
|
||||||
|
|
||||||
public new MarginPadding Padding
|
public new MarginPadding Padding
|
||||||
{
|
{
|
||||||
get => base.Padding;
|
get => base.Padding;
|
||||||
@ -31,26 +31,22 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
var items = (SearchContainer<RearrangeableListItem<Live<BeatmapSetInfo>>>)ListContainer;
|
var items = (SearchContainer<RearrangeableListItem<Live<BeatmapSetInfo>>>)ListContainer;
|
||||||
|
|
||||||
string[] currentCollectionHashes = criteria.Collection?.PerformRead(c => c.BeatmapMD5Hashes.ToArray());
|
string[]? currentCollectionHashes = criteria.Collection?.PerformRead(c => c.BeatmapMD5Hashes.ToArray());
|
||||||
|
|
||||||
foreach (var item in items.OfType<PlaylistItem>())
|
foreach (var item in items.OfType<PlaylistItem>())
|
||||||
{
|
{
|
||||||
if (currentCollectionHashes == null)
|
item.InSelectedCollection = currentCollectionHashes == null || item.Model.Value.Beatmaps.Select(b => b.MD5Hash).Any(currentCollectionHashes.Contains);
|
||||||
item.InSelectedCollection = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item.InSelectedCollection = item.Model.Value.Beatmaps.Select(b => b.MD5Hash)
|
|
||||||
.Any(currentCollectionHashes.Contains);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items.SearchTerm = criteria.SearchText;
|
items.SearchTerm = criteria.SearchText;
|
||||||
|
currentCriteria = criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Live<BeatmapSetInfo> FirstVisibleSet => Items.FirstOrDefault(i => ((PlaylistItem)ItemMap[i]).MatchingFilter);
|
public Live<BeatmapSetInfo>? FirstVisibleSet => Items.FirstOrDefault(i => ((PlaylistItem)ItemMap[i]).MatchingFilter);
|
||||||
|
|
||||||
protected override OsuRearrangeableListItem<Live<BeatmapSetInfo>> CreateOsuDrawable(Live<BeatmapSetInfo> item) => new PlaylistItem(item)
|
protected override OsuRearrangeableListItem<Live<BeatmapSetInfo>> CreateOsuDrawable(Live<BeatmapSetInfo> item) => new PlaylistItem(item)
|
||||||
{
|
{
|
||||||
|
InSelectedCollection = currentCriteria.Collection?.PerformRead(c => item.Value.Beatmaps.Select(b => b.MD5Hash).Any(c.BeatmapMD5Hashes.Contains)) != false,
|
||||||
SelectedSet = { BindTarget = SelectedSet },
|
SelectedSet = { BindTarget = SelectedSet },
|
||||||
RequestSelection = set => RequestSelection?.Invoke(set)
|
RequestSelection = set => RequestSelection?.Invoke(set)
|
||||||
};
|
};
|
||||||
|
@ -26,8 +26,6 @@ namespace osu.Game.Overlays.Music
|
|||||||
private const float transition_duration = 600;
|
private const float transition_duration = 600;
|
||||||
private const float playlist_height = 510;
|
private const float playlist_height = 510;
|
||||||
|
|
||||||
public IBindableList<Live<BeatmapSetInfo>> BeatmapSets => beatmapSets;
|
|
||||||
|
|
||||||
private readonly BindableList<Live<BeatmapSetInfo>> beatmapSets = new BindableList<Live<BeatmapSetInfo>>();
|
private readonly BindableList<Live<BeatmapSetInfo>> beatmapSets = new BindableList<Live<BeatmapSetInfo>>();
|
||||||
|
|
||||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||||
@ -104,9 +102,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
// tests might bind externally, in which case we don't want to involve realm.
|
beatmapSubscription = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>().Where(s => !s.DeletePending), beatmapsChanged);
|
||||||
if (beatmapSets.Count == 0)
|
|
||||||
beatmapSubscription = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>().Where(s => !s.DeletePending), beatmapsChanged);
|
|
||||||
|
|
||||||
list.Items.BindTo(beatmapSets);
|
list.Items.BindTo(beatmapSets);
|
||||||
beatmap.BindValueChanged(working => list.SelectedSet.Value = working.NewValue.BeatmapSetInfo.ToLive(realm), true);
|
beatmap.BindValueChanged(working => list.SelectedSet.Value = working.NewValue.BeatmapSetInfo.ToLive(realm), true);
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public override ModType Type => ModType.Fun;
|
public override ModType Type => ModType.Fun;
|
||||||
|
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 0.5;
|
||||||
|
|
||||||
public override bool ValidForMultiplayer => false;
|
public override bool ValidForMultiplayer => false;
|
||||||
public override bool ValidForMultiplayerAsFreeMod => false;
|
public override bool ValidForMultiplayerAsFreeMod => false;
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public override IconUsage? Icon => FontAwesome.Solid.Hammer;
|
public override IconUsage? Icon => FontAwesome.Solid.Hammer;
|
||||||
|
|
||||||
public override double ScoreMultiplier => 1.0;
|
public override double ScoreMultiplier => 0.5;
|
||||||
|
|
||||||
public override bool RequiresConfiguration => true;
|
public override bool RequiresConfiguration => true;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override string Acronym => "RX";
|
public override string Acronym => "RX";
|
||||||
public override IconUsage? Icon => OsuIcon.ModRelax;
|
public override IconUsage? Icon => OsuIcon.ModRelax;
|
||||||
public override ModType Type => ModType.Automation;
|
public override ModType Type => ModType.Automation;
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 0.1;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModFailCondition) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModFailCondition) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public override Container FrameStableComponents { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
public override Container FrameStableComponents { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public override IFrameStableClock FrameStableClock => frameStabilityContainer.FrameStableClock;
|
public override IFrameStableClock FrameStableClock => frameStabilityContainer;
|
||||||
|
|
||||||
private bool frameStablePlayback = true;
|
private bool frameStablePlayback = true;
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
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.Timing;
|
using osu.Framework.Timing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
@ -20,9 +20,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// A container which consumes a parent gameplay clock and standardises frame counts for children.
|
/// A container which consumes a parent gameplay clock and standardises frame counts for children.
|
||||||
/// Will ensure a minimum of 50 frames per clock second is maintained, regardless of any system lag or seeks.
|
/// Will ensure a minimum of 50 frames per clock second is maintained, regardless of any system lag or seeks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FrameStabilityContainer : Container, IHasReplayHandler
|
[Cached(typeof(IGameplayClock))]
|
||||||
|
[Cached(typeof(IFrameStableClock))]
|
||||||
|
public sealed class FrameStabilityContainer : Container, IHasReplayHandler, IFrameStableClock, IGameplayClock
|
||||||
{
|
{
|
||||||
private readonly double gameplayStartTime;
|
public ReplayInputHandler? ReplayInputHandler { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of frames (per parent frame) which can be run in an attempt to catch-up to real-time.
|
/// The number of frames (per parent frame) which can be run in an attempt to catch-up to real-time.
|
||||||
@ -32,28 +34,35 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to enable frame-stable playback.
|
/// Whether to enable frame-stable playback.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool FrameStablePlayback = true;
|
internal bool FrameStablePlayback { get; set; } = true;
|
||||||
|
|
||||||
public IFrameStableClock FrameStableClock => frameStableClock;
|
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && state != PlaybackState.NotValid;
|
||||||
|
|
||||||
[Cached(typeof(GameplayClock))]
|
private readonly Bindable<bool> isCatchingUp = new Bindable<bool>();
|
||||||
private readonly FrameStabilityClock frameStableClock;
|
|
||||||
|
|
||||||
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
private readonly Bindable<bool> waitingOnFrames = new Bindable<bool>();
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
frameStableClock = new FrameStabilityClock(framedClock = new FramedClock(manualClock = new ManualClock()));
|
private readonly double gameplayStartTime;
|
||||||
|
|
||||||
this.gameplayStartTime = gameplayStartTime;
|
private IGameplayClock? parentGameplayClock;
|
||||||
}
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A clock which is used as reference for time, rate and running state.
|
||||||
|
/// </summary>
|
||||||
|
private IClock referenceClock = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A local manual clock which tracks the reference clock.
|
||||||
|
/// Values are transferred from <see cref="referenceClock"/> each update call.
|
||||||
|
/// </summary>
|
||||||
private readonly ManualClock manualClock;
|
private readonly ManualClock manualClock;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The main framed clock which has stability applied to it.
|
||||||
|
/// This gets exposed to children as an <see cref="IGameplayClock"/>.
|
||||||
|
/// </summary>
|
||||||
private readonly FramedClock framedClock;
|
private readonly FramedClock framedClock;
|
||||||
|
|
||||||
private IFrameBasedClock parentGameplayClock;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current direction of playback to be exposed to frame stable children.
|
/// The current direction of playback to be exposed to frame stable children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -62,32 +71,34 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
private int direction = 1;
|
private int direction = 1;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
|
||||||
private void load(GameplayClock clock)
|
|
||||||
{
|
|
||||||
if (clock != null)
|
|
||||||
{
|
|
||||||
parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
|
|
||||||
frameStableClock.IsPaused.BindTo(clock.IsPaused);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
setClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlaybackState state;
|
private PlaybackState state;
|
||||||
|
|
||||||
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && state != PlaybackState.NotValid;
|
|
||||||
|
|
||||||
private bool hasReplayAttached => ReplayInputHandler != null;
|
private bool hasReplayAttached => ReplayInputHandler != null;
|
||||||
|
|
||||||
private const double sixty_frame_time = 1000.0 / 60;
|
|
||||||
|
|
||||||
private bool firstConsumption = true;
|
private bool firstConsumption = true;
|
||||||
|
|
||||||
|
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
framedClock = new FramedClock(manualClock = new ManualClock());
|
||||||
|
|
||||||
|
this.gameplayStartTime = gameplayStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(IGameplayClock? gameplayClock)
|
||||||
|
{
|
||||||
|
if (gameplayClock != null)
|
||||||
|
{
|
||||||
|
parentGameplayClock = gameplayClock;
|
||||||
|
IsPaused.BindTo(parentGameplayClock.IsPaused);
|
||||||
|
}
|
||||||
|
|
||||||
|
referenceClock = gameplayClock ?? Clock;
|
||||||
|
Clock = this;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool UpdateSubTree()
|
public override bool UpdateSubTree()
|
||||||
{
|
{
|
||||||
int loops = MaxCatchUpFrames;
|
int loops = MaxCatchUpFrames;
|
||||||
@ -110,12 +121,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private void updateClock()
|
private void updateClock()
|
||||||
{
|
{
|
||||||
if (frameStableClock.WaitingOnFrames.Value)
|
if (waitingOnFrames.Value)
|
||||||
{
|
{
|
||||||
// if waiting on frames, run one update loop to determine if frames have arrived.
|
// if waiting on frames, run one update loop to determine if frames have arrived.
|
||||||
state = PlaybackState.Valid;
|
state = PlaybackState.Valid;
|
||||||
}
|
}
|
||||||
else if (frameStableClock.IsPaused.Value)
|
else if (IsPaused.Value)
|
||||||
{
|
{
|
||||||
// time should not advance while paused, nor should anything run.
|
// time should not advance while paused, nor should anything run.
|
||||||
state = PlaybackState.NotValid;
|
state = PlaybackState.NotValid;
|
||||||
@ -126,10 +137,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
state = PlaybackState.Valid;
|
state = PlaybackState.Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentGameplayClock == null)
|
double proposedTime = referenceClock.CurrentTime;
|
||||||
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
|
||||||
|
|
||||||
double proposedTime = parentGameplayClock.CurrentTime;
|
|
||||||
|
|
||||||
if (FrameStablePlayback)
|
if (FrameStablePlayback)
|
||||||
// if we require frame stability, the proposed time will be adjusted to move at most one known
|
// if we require frame stability, the proposed time will be adjusted to move at most one known
|
||||||
@ -149,14 +157,14 @@ namespace osu.Game.Rulesets.UI
|
|||||||
if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime)
|
if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime)
|
||||||
direction = proposedTime >= manualClock.CurrentTime ? 1 : -1;
|
direction = proposedTime >= manualClock.CurrentTime ? 1 : -1;
|
||||||
|
|
||||||
double timeBehind = Math.Abs(proposedTime - parentGameplayClock.CurrentTime);
|
double timeBehind = Math.Abs(proposedTime - referenceClock.CurrentTime);
|
||||||
|
|
||||||
frameStableClock.IsCatchingUp.Value = timeBehind > 200;
|
isCatchingUp.Value = timeBehind > 200;
|
||||||
frameStableClock.WaitingOnFrames.Value = state == PlaybackState.NotValid;
|
waitingOnFrames.Value = state == PlaybackState.NotValid;
|
||||||
|
|
||||||
manualClock.CurrentTime = proposedTime;
|
manualClock.CurrentTime = proposedTime;
|
||||||
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
|
manualClock.Rate = Math.Abs(referenceClock.Rate) * direction;
|
||||||
manualClock.IsRunning = parentGameplayClock.IsRunning;
|
manualClock.IsRunning = referenceClock.IsRunning;
|
||||||
|
|
||||||
// determine whether catch-up is required.
|
// determine whether catch-up is required.
|
||||||
if (state == PlaybackState.Valid && timeBehind > 0)
|
if (state == PlaybackState.Valid && timeBehind > 0)
|
||||||
@ -174,6 +182,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <returns>Whether playback is still valid.</returns>
|
/// <returns>Whether playback is still valid.</returns>
|
||||||
private bool updateReplay(ref double proposedTime)
|
private bool updateReplay(ref double proposedTime)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(ReplayInputHandler != null);
|
||||||
|
|
||||||
double? newTime;
|
double? newTime;
|
||||||
|
|
||||||
if (FrameStablePlayback)
|
if (FrameStablePlayback)
|
||||||
@ -210,6 +220,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="proposedTime">The time which is to be displayed.</param>
|
/// <param name="proposedTime">The time which is to be displayed.</param>
|
||||||
private void applyFrameStability(ref double proposedTime)
|
private void applyFrameStability(ref double proposedTime)
|
||||||
{
|
{
|
||||||
|
const double sixty_frame_time = 1000.0 / 60;
|
||||||
|
|
||||||
if (firstConsumption)
|
if (firstConsumption)
|
||||||
{
|
{
|
||||||
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
||||||
@ -233,20 +245,54 @@ namespace osu.Game.Rulesets.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClock()
|
#region Delegation of IGameplayClock
|
||||||
|
|
||||||
|
public IBindable<bool> IsPaused { get; } = new BindableBool();
|
||||||
|
|
||||||
|
public double CurrentTime => framedClock.CurrentTime;
|
||||||
|
|
||||||
|
public double Rate => framedClock.Rate;
|
||||||
|
|
||||||
|
public bool IsRunning => framedClock.IsRunning;
|
||||||
|
|
||||||
|
public void ProcessFrame() { }
|
||||||
|
|
||||||
|
public double ElapsedFrameTime => framedClock.ElapsedFrameTime;
|
||||||
|
|
||||||
|
public double FramesPerSecond => framedClock.FramesPerSecond;
|
||||||
|
|
||||||
|
public FrameTimeInfo TimeInfo => framedClock.TimeInfo;
|
||||||
|
|
||||||
|
public double TrueGameplayRate
|
||||||
{
|
{
|
||||||
if (parentGameplayClock == null)
|
get
|
||||||
{
|
{
|
||||||
// in case a parent gameplay clock isn't available, just use the parent clock.
|
double baseRate = Rate;
|
||||||
parentGameplayClock ??= Clock;
|
|
||||||
}
|
foreach (double adjustment in NonGameplayAdjustments)
|
||||||
else
|
{
|
||||||
{
|
if (Precision.AlmostEquals(adjustment, 0))
|
||||||
Clock = frameStableClock;
|
return 0;
|
||||||
|
|
||||||
|
baseRate /= adjustment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayInputHandler ReplayInputHandler { get; set; }
|
public double? StartTime => parentGameplayClock?.StartTime;
|
||||||
|
|
||||||
|
public IEnumerable<double> NonGameplayAdjustments => parentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<double>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Delegation of IFrameStableClock
|
||||||
|
|
||||||
|
IBindable<bool> IFrameStableClock.IsCatchingUp => isCatchingUp;
|
||||||
|
IBindable<bool> IFrameStableClock.WaitingOnFrames => waitingOnFrames;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private enum PlaybackState
|
private enum PlaybackState
|
||||||
{
|
{
|
||||||
@ -266,25 +312,5 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Valid
|
Valid
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FrameStabilityClock : GameplayClock, IFrameStableClock
|
|
||||||
{
|
|
||||||
public GameplayClock ParentGameplayClock;
|
|
||||||
|
|
||||||
public readonly Bindable<bool> IsCatchingUp = new Bindable<bool>();
|
|
||||||
|
|
||||||
public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>();
|
|
||||||
|
|
||||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<Bindable<double>>();
|
|
||||||
|
|
||||||
public FrameStabilityClock(FramedClock underlyingClock)
|
|
||||||
: base(underlyingClock)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IBindable<bool> IFrameStableClock.IsCatchingUp => IsCatchingUp;
|
|
||||||
|
|
||||||
IBindable<bool> IFrameStableClock.WaitingOnFrames => WaitingOnFrames;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
|
|
||||||
|
@ -78,7 +78,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
this.beatmapInfo = beatmapInfo ?? playableBeatmap.BeatmapInfo;
|
this.beatmapInfo = beatmapInfo ?? playableBeatmap.BeatmapInfo;
|
||||||
|
|
||||||
if (beatmapSkin is Skin skin)
|
if (beatmapSkin is Skin skin)
|
||||||
|
{
|
||||||
BeatmapSkin = new EditorBeatmapSkin(skin);
|
BeatmapSkin = new EditorBeatmapSkin(skin);
|
||||||
|
BeatmapSkin.BeatmapSkinChanged += SaveState;
|
||||||
|
}
|
||||||
|
|
||||||
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
|
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value;
|
Beatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning.Current.Value;
|
||||||
Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value;
|
Beatmap.BeatmapInfo.LetterboxInBreaks = letterboxDuringBreaks.Current.Value;
|
||||||
Beatmap.BeatmapInfo.SamplesMatchPlaybackRate = samplesMatchPlaybackRate.Current.Value;
|
Beatmap.BeatmapInfo.SamplesMatchPlaybackRate = samplesMatchPlaybackRate.Current.Value;
|
||||||
|
|
||||||
|
Beatmap.SaveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
Beatmap.Difficulty.OverallDifficulty = overallDifficultySlider.Current.Value;
|
Beatmap.Difficulty.OverallDifficulty = overallDifficultySlider.Current.Value;
|
||||||
|
|
||||||
Beatmap.UpdateAllHitObjects();
|
Beatmap.UpdateAllHitObjects();
|
||||||
|
Beatmap.SaveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
target.Current.Value = value;
|
target.Current.Value = value;
|
||||||
|
|
||||||
updateReadOnlyState();
|
updateReadOnlyState();
|
||||||
updateMetadata();
|
Scheduler.AddOnce(updateMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateReadOnlyState()
|
private void updateReadOnlyState()
|
||||||
@ -102,7 +102,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
|
|
||||||
// for now, update on commit rather than making BeatmapMetadata bindables.
|
// for now, update on commit rather than making BeatmapMetadata bindables.
|
||||||
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
||||||
updateMetadata();
|
Scheduler.AddOnce(updateMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMetadata()
|
private void updateMetadata()
|
||||||
@ -117,6 +117,8 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
Beatmap.BeatmapInfo.DifficultyName = difficultyTextBox.Current.Value;
|
Beatmap.BeatmapInfo.DifficultyName = difficultyTextBox.Current.Value;
|
||||||
Beatmap.Metadata.Source = sourceTextBox.Current.Value;
|
Beatmap.Metadata.Source = sourceTextBox.Current.Value;
|
||||||
Beatmap.Metadata.Tags = tagsTextBox.Current.Value;
|
Beatmap.Metadata.Tags = tagsTextBox.Current.Value;
|
||||||
|
|
||||||
|
Beatmap.SaveState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
protected override string BeatmapFile => "circles.osz";
|
protected override string BeatmapFile => "circles.osz";
|
||||||
|
|
||||||
|
public const double TRACK_START_DELAY_NON_THEMED = 1000;
|
||||||
|
private const double track_start_delay_themed = 600;
|
||||||
|
|
||||||
|
private const double delay_for_menu = 2900;
|
||||||
private const double delay_step_one = 2300;
|
private const double delay_step_one = 2300;
|
||||||
private const double delay_step_two = 600;
|
|
||||||
|
|
||||||
private Sample welcome;
|
private Sample welcome;
|
||||||
|
|
||||||
@ -44,14 +47,16 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
welcome?.Play();
|
welcome?.Play();
|
||||||
|
|
||||||
|
double trackStartDelay = UsingThemedIntro ? track_start_delay_themed : TRACK_START_DELAY_NON_THEMED;
|
||||||
|
|
||||||
Scheduler.AddDelayed(delegate
|
Scheduler.AddDelayed(delegate
|
||||||
{
|
{
|
||||||
StartTrack();
|
StartTrack();
|
||||||
|
|
||||||
PrepareMenuLoad();
|
PrepareMenuLoad();
|
||||||
|
|
||||||
Scheduler.AddDelayed(LoadMenu, delay_step_one);
|
Scheduler.AddDelayed(LoadMenu, delay_for_menu - trackStartDelay);
|
||||||
}, delay_step_two);
|
}, trackStartDelay);
|
||||||
|
|
||||||
logo.ScaleTo(1);
|
logo.ScaleTo(1);
|
||||||
logo.FadeIn();
|
logo.FadeIn();
|
||||||
|
@ -272,11 +272,17 @@ namespace osu.Game.Screens.Menu
|
|||||||
FadeInBackground(200);
|
FadeInBackground(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void StartTrack()
|
protected void StartTrack()
|
||||||
{
|
{
|
||||||
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu.
|
var drawableTrack = musicController.CurrentTrack;
|
||||||
if (UsingThemedIntro)
|
|
||||||
Track.Start();
|
drawableTrack.Start();
|
||||||
|
|
||||||
|
if (!UsingThemedIntro)
|
||||||
|
{
|
||||||
|
drawableTrack.VolumeTo(0).Then()
|
||||||
|
.VolumeTo(1, 2000, Easing.OutQuint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||||
|
@ -84,9 +84,17 @@ namespace osu.Game.Screens.Menu
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!UsingThemedIntro)
|
if (!UsingThemedIntro)
|
||||||
|
{
|
||||||
|
// If the user has requested no theme, fallback to the same intro voice and delay as IntroCircles.
|
||||||
|
// The triangles intro voice and theme are combined which makes it impossible to use.
|
||||||
welcome?.Play();
|
welcome?.Play();
|
||||||
|
Scheduler.AddDelayed(StartTrack, IntroCircles.TRACK_START_DELAY_NON_THEMED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
StartTrack();
|
||||||
|
|
||||||
StartTrack();
|
// no-op for the case of themed intro, no harm in calling for both scenarios as a safety measure.
|
||||||
|
decoupledClock.Start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,11 +107,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
intro.Expire();
|
intro.Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void StartTrack()
|
|
||||||
{
|
|
||||||
decoupledClock.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TrianglesIntroSequence : CompositeDrawable
|
private class TrianglesIntroSequence : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly OsuLogo logo;
|
private readonly OsuLogo logo;
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Timing;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -26,7 +22,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The score containing the player's replay.</param>
|
/// <param name="score">The score containing the player's replay.</param>
|
||||||
/// <param name="spectatorPlayerClock">The clock controlling the gameplay running state.</param>
|
/// <param name="spectatorPlayerClock">The clock controlling the gameplay running state.</param>
|
||||||
public MultiSpectatorPlayer([NotNull] Score score, [NotNull] ISpectatorPlayerClock spectatorPlayerClock)
|
public MultiSpectatorPlayer(Score score, ISpectatorPlayerClock spectatorPlayerClock)
|
||||||
: base(score, new PlayerConfiguration { AllowUserInteraction = false })
|
: base(score, new PlayerConfiguration { AllowUserInteraction = false })
|
||||||
{
|
{
|
||||||
this.spectatorPlayerClock = spectatorPlayerClock;
|
this.spectatorPlayerClock = spectatorPlayerClock;
|
||||||
@ -41,6 +37,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
HUDOverlay.HoldToQuit.Expire();
|
HUDOverlay.HoldToQuit.Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
// The player clock's running state is controlled externally, but the local pausing state needs to be updated to start/stop gameplay.
|
||||||
|
CatchUpSpectatorPlayerClock catchUpClock = (CatchUpSpectatorPlayerClock)GameplayClockContainer.SourceClock;
|
||||||
|
|
||||||
|
if (catchUpClock.IsRunning)
|
||||||
|
GameplayClockContainer.Start();
|
||||||
|
else
|
||||||
|
GameplayClockContainer.Stop();
|
||||||
|
|
||||||
|
base.Update();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -50,28 +59,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||||
=> new SpectatorGameplayClockContainer(spectatorPlayerClock);
|
=> new GameplayClockContainer(spectatorPlayerClock);
|
||||||
|
|
||||||
private class SpectatorGameplayClockContainer : GameplayClockContainer
|
|
||||||
{
|
|
||||||
public SpectatorGameplayClockContainer([NotNull] IClock sourceClock)
|
|
||||||
: base(sourceClock)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
// The SourceClock here is always a CatchUpSpectatorPlayerClock.
|
|
||||||
// The player clock's running state is controlled externally, but the local pausing state needs to be updated to stop gameplay.
|
|
||||||
if (SourceClock.IsRunning)
|
|
||||||
Start();
|
|
||||||
else
|
|
||||||
Stop();
|
|
||||||
|
|
||||||
base.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override GameplayClock CreateGameplayClock(IFrameBasedClock source) => new GameplayClock(source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
|
|
||||||
for (int i = 0; i < Users.Count; i++)
|
for (int i = 0; i < Users.Count; i++)
|
||||||
{
|
{
|
||||||
grid.Add(instances[i] = new PlayerArea(Users[i], masterClockContainer.GameplayClock));
|
grid.Add(instances[i] = new PlayerArea(Users[i], masterClockContainer));
|
||||||
syncManager.AddPlayerClock(instances[i].GameplayClock);
|
syncManager.AddPlayerClock(instances[i].GameplayClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
|
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
private void onComboChange(ValueChangedEvent<int> combo)
|
private void onComboChange(ValueChangedEvent<int> combo)
|
||||||
{
|
{
|
||||||
|
@ -19,51 +19,39 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
|
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameplayClock : IFrameBasedClock
|
public class GameplayClock : IGameplayClock
|
||||||
{
|
{
|
||||||
internal readonly IFrameBasedClock UnderlyingClock;
|
internal readonly IFrameBasedClock UnderlyingClock;
|
||||||
|
|
||||||
public readonly BindableBool IsPaused = new BindableBool();
|
public readonly BindableBool IsPaused = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
IBindable<bool> IGameplayClock.IsPaused => IsPaused;
|
||||||
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
|
||||||
/// </summary>
|
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
|
||||||
public virtual IEnumerable<Bindable<double>> NonGameplayAdjustments => Enumerable.Empty<Bindable<double>>();
|
|
||||||
|
|
||||||
public GameplayClock(IFrameBasedClock underlyingClock)
|
public GameplayClock(IFrameBasedClock underlyingClock)
|
||||||
{
|
{
|
||||||
UnderlyingClock = underlyingClock;
|
UnderlyingClock = underlyingClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// If not set, a value of zero will be used.
|
|
||||||
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
|
||||||
/// </remarks>
|
|
||||||
public double? StartTime { get; internal set; }
|
public double? StartTime { get; internal set; }
|
||||||
|
|
||||||
public double CurrentTime => UnderlyingClock.CurrentTime;
|
public double CurrentTime => UnderlyingClock.CurrentTime;
|
||||||
|
|
||||||
public double Rate => UnderlyingClock.Rate;
|
public double Rate => UnderlyingClock.Rate;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The rate of gameplay when playback is at 100%.
|
|
||||||
/// This excludes any seeking / user adjustments.
|
|
||||||
/// </summary>
|
|
||||||
public double TrueGameplayRate
|
public double TrueGameplayRate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
double baseRate = Rate;
|
double baseRate = Rate;
|
||||||
|
|
||||||
foreach (var adjustment in NonGameplayAdjustments)
|
foreach (double adjustment in NonGameplayAdjustments)
|
||||||
{
|
{
|
||||||
if (Precision.AlmostEquals(adjustment.Value, 0))
|
if (Precision.AlmostEquals(adjustment, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
baseRate /= adjustment.Value;
|
baseRate /= adjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseRate;
|
return baseRate;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -16,17 +16,14 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GameplayClockContainer : Container, IAdjustableClock
|
public class GameplayClockContainer : Container, IAdjustableClock, IGameplayClock
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The final clock which is exposed to gameplay components.
|
|
||||||
/// </summary>
|
|
||||||
public GameplayClock GameplayClock { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether gameplay is paused.
|
/// Whether gameplay is paused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableBool IsPaused = new BindableBool(true);
|
public IBindable<bool> IsPaused => isPaused;
|
||||||
|
|
||||||
|
private readonly BindableBool isPaused = new BindableBool(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The adjustable source clock used for gameplay. Should be used for seeks and clock control.
|
/// The adjustable source clock used for gameplay. Should be used for seeks and clock control.
|
||||||
@ -36,12 +33,12 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The source clock.
|
/// The source clock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IClock SourceClock { get; private set; }
|
public IClock SourceClock { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a seek has been performed via <see cref="Seek"/>
|
/// Invoked when a seek has been performed via <see cref="Seek"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action OnSeek;
|
public event Action? OnSeek;
|
||||||
|
|
||||||
private double? startTime;
|
private double? startTime;
|
||||||
|
|
||||||
@ -59,16 +56,23 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
startTime = value;
|
startTime = value;
|
||||||
|
|
||||||
if (GameplayClock != null)
|
if (GameplayClock.IsNotNull())
|
||||||
GameplayClock.StartTime = value;
|
GameplayClock.StartTime = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<double> NonGameplayAdjustments => GameplayClock.NonGameplayAdjustments;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The final clock which is exposed to gameplay components.
|
||||||
|
/// </summary>
|
||||||
|
protected GameplayClock GameplayClock { get; private set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="GameplayClockContainer"/>.
|
/// Creates a new <see cref="GameplayClockContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
|
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
|
||||||
protected GameplayClockContainer(IClock sourceClock)
|
public GameplayClockContainer(IClock sourceClock)
|
||||||
{
|
{
|
||||||
SourceClock = sourceClock;
|
SourceClock = sourceClock;
|
||||||
|
|
||||||
@ -82,10 +86,12 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
dependencies.CacheAs(GameplayClock = CreateGameplayClock(AdjustableSource));
|
GameplayClock = CreateGameplayClock(AdjustableSource);
|
||||||
|
|
||||||
|
dependencies.CacheAs<IGameplayClock>(this);
|
||||||
|
|
||||||
GameplayClock.StartTime = StartTime;
|
GameplayClock.StartTime = StartTime;
|
||||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
GameplayClock.IsPaused.BindTo(isPaused);
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
@ -106,7 +112,7 @@ namespace osu.Game.Screens.Play
|
|||||||
AdjustableSource.Start();
|
AdjustableSource.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
IsPaused.Value = false;
|
isPaused.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -128,7 +134,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops gameplay.
|
/// Stops gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop() => IsPaused.Value = true;
|
public void Stop() => isPaused.Value = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||||
@ -193,7 +199,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="source">The <see cref="IFrameBasedClock"/> providing the source time.</param>
|
/// <param name="source">The <see cref="IFrameBasedClock"/> providing the source time.</param>
|
||||||
/// <returns>The final <see cref="GameplayClock"/>.</returns>
|
/// <returns>The final <see cref="GameplayClock"/>.</returns>
|
||||||
protected abstract GameplayClock CreateGameplayClock(IFrameBasedClock source);
|
protected virtual GameplayClock CreateGameplayClock(IFrameBasedClock source) => new GameplayClock(source);
|
||||||
|
|
||||||
#region IAdjustableClock
|
#region IAdjustableClock
|
||||||
|
|
||||||
@ -205,9 +211,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
void IAdjustableClock.Reset() => Reset();
|
void IAdjustableClock.Reset() => Reset();
|
||||||
|
|
||||||
public void ResetSpeedAdjustments()
|
public void ResetSpeedAdjustments() => throw new NotImplementedException();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
double IAdjustableClock.Rate
|
double IAdjustableClock.Rate
|
||||||
{
|
{
|
||||||
@ -215,12 +219,25 @@ namespace osu.Game.Screens.Play
|
|||||||
set => throw new NotSupportedException();
|
set => throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
double IClock.Rate => GameplayClock.Rate;
|
public double Rate => GameplayClock.Rate;
|
||||||
|
|
||||||
public double CurrentTime => GameplayClock.CurrentTime;
|
public double CurrentTime => GameplayClock.CurrentTime;
|
||||||
|
|
||||||
public bool IsRunning => GameplayClock.IsRunning;
|
public bool IsRunning => GameplayClock.IsRunning;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void ProcessFrame()
|
||||||
|
{
|
||||||
|
// Handled via update. Don't process here to safeguard from external usages potentially processing frames additional times.
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ElapsedFrameTime => GameplayClock.ElapsedFrameTime;
|
||||||
|
|
||||||
|
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
||||||
|
|
||||||
|
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
|
||||||
|
|
||||||
|
public double TrueGameplayRate => GameplayClock.TrueGameplayRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public bool UsesFixedAnchor { get; set; }
|
public bool UsesFixedAnchor { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected GameplayClock GameplayClock { get; private set; } = null!;
|
protected IGameplayClock GameplayClock { get; private set; } = null!;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DrawableRuleset? drawableRuleset { get; set; }
|
private DrawableRuleset? drawableRuleset { get; set; }
|
||||||
@ -94,7 +94,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
double objectOffsetCurrent = currentTime - FirstHitTime;
|
double objectOffsetCurrent = currentTime - FirstHitTime;
|
||||||
|
|
||||||
double objectDuration = LastHitTime - FirstHitTime;
|
double objectDuration = LastHitTime - FirstHitTime;
|
||||||
UpdateProgress(objectOffsetCurrent / objectDuration, false);
|
if (objectDuration == 0)
|
||||||
|
UpdateProgress(0, false);
|
||||||
|
else
|
||||||
|
UpdateProgress(objectOffsetCurrent / objectDuration, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
set => endTime = value;
|
set => endTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameplayClock gameplayClock;
|
private IGameplayClock gameplayClock;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours, GameplayClock clock)
|
private void load(OsuColour colours, IGameplayClock clock)
|
||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
gameplayClock = clock;
|
gameplayClock = clock;
|
||||||
|
34
osu.Game/Screens/Play/IGameplayClock.cs
Normal file
34
osu.Game/Screens/Play/IGameplayClock.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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 osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public interface IGameplayClock : IFrameBasedClock
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The rate of gameplay when playback is at 100%.
|
||||||
|
/// This excludes any seeking / user adjustments.
|
||||||
|
/// </summary>
|
||||||
|
double TrueGameplayRate { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If not set, a value of zero will be used.
|
||||||
|
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
||||||
|
/// </remarks>
|
||||||
|
double? StartTime { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
||||||
|
/// </summary>
|
||||||
|
IEnumerable<double> NonGameplayAdjustments { get; }
|
||||||
|
|
||||||
|
IBindable<bool> IsPaused { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -303,7 +303,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private class MasterGameplayClock : GameplayClock
|
private class MasterGameplayClock : GameplayClock
|
||||||
{
|
{
|
||||||
public readonly List<Bindable<double>> MutableNonGameplayAdjustments = new List<Bindable<double>>();
|
public readonly List<Bindable<double>> MutableNonGameplayAdjustments = new List<Bindable<double>>();
|
||||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => MutableNonGameplayAdjustments;
|
public override IEnumerable<double> NonGameplayAdjustments => MutableNonGameplayAdjustments.Select(b => b.Value);
|
||||||
|
|
||||||
public MasterGameplayClock(FramedOffsetClock underlyingClock)
|
public MasterGameplayClock(FramedOffsetClock underlyingClock)
|
||||||
: base(underlyingClock)
|
: base(underlyingClock)
|
||||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool PauseOnFocusLost => true;
|
protected virtual bool PauseOnFocusLost => true;
|
||||||
|
|
||||||
public Action RestartRequested;
|
public Action<bool> RestartRequested;
|
||||||
|
|
||||||
private bool isRestarting;
|
private bool isRestarting;
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ namespace osu.Game.Screens.Play
|
|||||||
FailOverlay = new FailOverlay
|
FailOverlay = new FailOverlay
|
||||||
{
|
{
|
||||||
SaveReplay = prepareAndImportScore,
|
SaveReplay = prepareAndImportScore,
|
||||||
OnRetry = Restart,
|
OnRetry = () => Restart(),
|
||||||
OnQuit = () => PerformExit(true),
|
OnQuit = () => PerformExit(true),
|
||||||
},
|
},
|
||||||
new HotkeyExitOverlay
|
new HotkeyExitOverlay
|
||||||
@ -294,7 +294,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
fadeOut(true);
|
fadeOut(true);
|
||||||
Restart();
|
Restart(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ namespace osu.Game.Screens.Play
|
|||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
||||||
|
|
||||||
// bind clock into components that require it
|
// bind clock into components that require it
|
||||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
((IBindable<bool>)DrawableRuleset.IsPaused).BindTo(GameplayClockContainer.IsPaused);
|
||||||
|
|
||||||
DrawableRuleset.NewResult += r =>
|
DrawableRuleset.NewResult += r =>
|
||||||
{
|
{
|
||||||
@ -371,6 +371,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
IsBreakTime.BindTo(breakTracker.IsBreakTime);
|
IsBreakTime.BindTo(breakTracker.IsBreakTime);
|
||||||
IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
|
IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
|
||||||
|
|
||||||
|
if (Configuration.AutomaticallySkipIntro)
|
||||||
|
skipIntroOverlay.SkipWhenReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
|
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
|
||||||
@ -441,7 +444,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
OnResume = Resume,
|
OnResume = Resume,
|
||||||
Retries = RestartCount,
|
Retries = RestartCount,
|
||||||
OnRetry = Restart,
|
OnRetry = () => Restart(),
|
||||||
OnQuit = () => PerformExit(true),
|
OnQuit = () => PerformExit(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -475,7 +478,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private void updateSampleDisabledState()
|
private void updateSampleDisabledState()
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = DrawableRuleset.FrameStableClock.IsCatchingUp.Value || GameplayClockContainer.GameplayClock.IsPaused.Value;
|
samplePlaybackDisabled.Value = DrawableRuleset.FrameStableClock.IsCatchingUp.Value || GameplayClockContainer.IsPaused.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePauseOnFocusLostState()
|
private void updatePauseOnFocusLostState()
|
||||||
@ -648,7 +651,8 @@ namespace osu.Game.Screens.Play
|
|||||||
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
|
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
|
||||||
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Restart()
|
/// <param name="quickRestart">Whether a quick restart was requested (skipping intro etc.).</param>
|
||||||
|
public void Restart(bool quickRestart = false)
|
||||||
{
|
{
|
||||||
if (!Configuration.AllowRestart)
|
if (!Configuration.AllowRestart)
|
||||||
return;
|
return;
|
||||||
@ -660,7 +664,7 @@ namespace osu.Game.Screens.Play
|
|||||||
musicController.Stop();
|
musicController.Stop();
|
||||||
|
|
||||||
sampleRestart?.Play();
|
sampleRestart?.Play();
|
||||||
RestartRequested?.Invoke();
|
RestartRequested?.Invoke(quickRestart);
|
||||||
|
|
||||||
PerformExit(false);
|
PerformExit(false);
|
||||||
}
|
}
|
||||||
@ -840,7 +844,7 @@ namespace osu.Game.Screens.Play
|
|||||||
failAnimationLayer.Start();
|
failAnimationLayer.Start();
|
||||||
|
|
||||||
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
||||||
Restart();
|
Restart(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -877,7 +881,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private double? lastPauseActionTime;
|
private double? lastPauseActionTime;
|
||||||
|
|
||||||
protected bool PauseCooldownActive =>
|
protected bool PauseCooldownActive =>
|
||||||
lastPauseActionTime.HasValue && GameplayClockContainer.GameplayClock.CurrentTime < lastPauseActionTime + pause_cooldown;
|
lastPauseActionTime.HasValue && GameplayClockContainer.CurrentTime < lastPauseActionTime + pause_cooldown;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A set of conditionals which defines whether the current game state and configuration allows for
|
/// A set of conditionals which defines whether the current game state and configuration allows for
|
||||||
@ -915,7 +919,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
GameplayClockContainer.Stop();
|
GameplayClockContainer.Stop();
|
||||||
PauseOverlay.Show();
|
PauseOverlay.Show();
|
||||||
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
lastPauseActionTime = GameplayClockContainer.CurrentTime;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,7 +1009,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void StartGameplay()
|
protected virtual void StartGameplay()
|
||||||
{
|
{
|
||||||
if (GameplayClockContainer.GameplayClock.IsRunning)
|
if (GameplayClockContainer.IsRunning)
|
||||||
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
||||||
|
|
||||||
GameplayClockContainer.Reset(true);
|
GameplayClockContainer.Reset(true);
|
||||||
|
@ -31,5 +31,10 @@ namespace osu.Game.Screens.Play
|
|||||||
/// Whether the player should be allowed to skip intros/outros, advancing to the start of gameplay or the end of a storyboard.
|
/// Whether the player should be allowed to skip intros/outros, advancing to the start of gameplay or the end of a storyboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowSkipping { get; set; } = true;
|
public bool AllowSkipping { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the intro should be skipped by default.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutomaticallySkipIntro { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private EpilepsyWarning? epilepsyWarning;
|
private EpilepsyWarning? epilepsyWarning;
|
||||||
|
|
||||||
|
private bool quickRestart;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private INotificationOverlay? notificationOverlay { get; set; }
|
private INotificationOverlay? notificationOverlay { get; set; }
|
||||||
|
|
||||||
@ -361,6 +363,7 @@ namespace osu.Game.Screens.Play
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CurrentPlayer = createPlayer();
|
CurrentPlayer = createPlayer();
|
||||||
|
CurrentPlayer.Configuration.AutomaticallySkipIntro = quickRestart;
|
||||||
CurrentPlayer.RestartCount = restartCount++;
|
CurrentPlayer.RestartCount = restartCount++;
|
||||||
CurrentPlayer.RestartRequested = restartRequested;
|
CurrentPlayer.RestartRequested = restartRequested;
|
||||||
|
|
||||||
@ -375,8 +378,9 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartRequested()
|
private void restartRequested(bool quickRestartRequested)
|
||||||
{
|
{
|
||||||
|
quickRestart = quickRestartRequested;
|
||||||
hideOverlays = true;
|
hideOverlays = true;
|
||||||
ValidForResume = true;
|
ValidForResume = true;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public class ScreenSuspensionHandler : Component
|
public class ScreenSuspensionHandler : Component
|
||||||
{
|
{
|
||||||
private readonly GameplayClockContainer gameplayClockContainer;
|
private readonly GameplayClockContainer gameplayClockContainer;
|
||||||
private Bindable<bool> isPaused;
|
private IBindable<bool> isPaused;
|
||||||
|
|
||||||
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
|
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
|
||||||
|
|
||||||
|
@ -39,9 +39,12 @@ namespace osu.Game.Screens.Play
|
|||||||
private double displayTime;
|
private double displayTime;
|
||||||
|
|
||||||
private bool isClickable;
|
private bool isClickable;
|
||||||
|
private bool skipQueued;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
|
internal bool IsButtonVisible => fadeContainer.State == Visibility.Visible && buttonContainer.State.Value == Visibility.Visible;
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
@ -123,6 +126,20 @@ namespace osu.Game.Screens.Play
|
|||||||
displayTime = gameplayClock.CurrentTime;
|
displayTime = gameplayClock.CurrentTime;
|
||||||
|
|
||||||
fadeContainer.TriggerShow();
|
fadeContainer.TriggerShow();
|
||||||
|
|
||||||
|
if (skipQueued)
|
||||||
|
{
|
||||||
|
Scheduler.AddDelayed(() => button.TriggerClick(), 200);
|
||||||
|
skipQueued = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SkipWhenReady()
|
||||||
|
{
|
||||||
|
if (IsLoaded)
|
||||||
|
button.TriggerClick();
|
||||||
|
else
|
||||||
|
skipQueued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -177,7 +177,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
player?.Restart();
|
player?.Restart(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(GameplayClock clock, CancellationToken? cancellationToken, GameHost host, RealmAccess realm)
|
private void load(IGameplayClock clock, CancellationToken? cancellationToken, GameHost host, RealmAccess realm)
|
||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
Clock = clock;
|
Clock = clock;
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true, }))
|
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu-development", new HostOptions { BindIPC = true, }))
|
||||||
{
|
{
|
||||||
host.Run(new OsuTestBrowser());
|
host.Run(new OsuTestBrowser());
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user