1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

Merge branch 'master' into progress-bar-show-seek

This commit is contained in:
Dean Herbert 2019-05-10 17:27:49 +09:00 committed by GitHub
commit a44296a6db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 41 deletions

View File

@ -73,6 +73,26 @@ namespace osu.Game.Tests.Visual.Gameplay
checkFrameCount(2);
}
[Test]
public void TestInitialSeekWithGameplayStart()
{
seekManualTo(1000);
createStabilityContainer(30000);
confirmSeek(1000);
checkFrameCount(0);
seekManualTo(10000);
confirmSeek(10000);
checkFrameCount(1);
seekManualTo(130000);
confirmSeek(130000);
checkFrameCount(6002);
}
[Test]
public void TestInitialSeek()
{
@ -83,7 +103,11 @@ namespace osu.Game.Tests.Visual.Gameplay
checkFrameCount(0);
}
private void createStabilityContainer() => AddStep("create container", () => mainContainer.Child = new FrameStabilityContainer().WithChild(consumer = new ClockConsumingChild()));
private const int max_frames_catchup = 50;
private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () =>
mainContainer.Child = new FrameStabilityContainer(gameplayStartTime) { MaxCatchUpFrames = max_frames_catchup }
.WithChild(consumer = new ClockConsumingChild()));
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);

View File

@ -360,6 +360,9 @@ namespace osu.Game.Rulesets.Scoring
JudgedHits--;
if (result.Type != HitResult.None)
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1;
if (result.Judgement.IsBonus)
{
if (result.IsHit)

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
@ -142,11 +143,11 @@ namespace osu.Game.Rulesets.UI
public virtual PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new PlayfieldAdjustmentContainer();
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
private void load(OsuConfigManager config, CancellationToken cancellationToken)
{
InternalChildren = new Drawable[]
{
frameStabilityContainer = new FrameStabilityContainer
frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime)
{
Child = KeyBindingInputManager
.WithChild(CreatePlayfieldAdjustmentContainer()
@ -165,16 +166,24 @@ namespace osu.Game.Rulesets.UI
applyRulesetMods(mods, config);
loadObjects();
loadObjects(cancellationToken);
}
/// <summary>
/// Creates and adds drawable representations of hit objects to the play field.
/// </summary>
private void loadObjects()
private void loadObjects(CancellationToken cancellationToken)
{
foreach (TObject h in Beatmap.HitObjects)
{
if (cancellationToken.IsCancellationRequested)
break;
addHitObject(h);
}
if (cancellationToken.IsCancellationRequested)
return;
Playfield.PostProcess();

View File

@ -17,20 +17,29 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public class FrameStabilityContainer : Container, IHasReplayHandler
{
public FrameStabilityContainer()
private readonly double gameplayStartTime;
/// <summary>
/// The number of frames (per parent frame) which can be run in an attempt to catch-up to real-time.
/// </summary>
public int MaxCatchUpFrames { get; set; } = 5;
[Cached]
public GameplayClock GameplayClock { get; }
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
{
RelativeSizeAxes = Axes.Both;
GameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
this.gameplayStartTime = gameplayStartTime;
}
private readonly ManualClock manualClock;
private readonly FramedClock framedClock;
[Cached]
public GameplayClock GameplayClock { get; }
private IFrameBasedClock parentGameplayClock;
[BackgroundDependencyLoader(true)]
@ -65,8 +74,6 @@ namespace osu.Game.Rulesets.UI
private bool isAttached => ReplayInputHandler != null;
private const int max_catch_up_updates_per_frame = 50;
private const double sixty_frame_time = 1000.0 / 60;
private bool firstConsumption = true;
@ -78,7 +85,7 @@ namespace osu.Game.Rulesets.UI
int loops = 0;
while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame)
while (validState && requireMoreUpdateLoops && loops++ < MaxCatchUpFrames)
{
updateClock();
@ -117,6 +124,8 @@ namespace osu.Game.Rulesets.UI
firstConsumption = false;
}
else if (manualClock.CurrentTime < gameplayStartTime)
manualClock.CurrentTime = newProposedTime = Math.Min(gameplayStartTime, newProposedTime);
else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
{
newProposedTime = newProposedTime > manualClock.CurrentTime

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Threading;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -57,7 +58,7 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader(true)]
private void load(FileStore fileStore, GameplayClock clock)
private void load(FileStore fileStore, GameplayClock clock, CancellationToken cancellationToken)
{
if (clock != null)
Clock = clock;
@ -65,7 +66,12 @@ namespace osu.Game.Storyboards.Drawables
dependencies.Cache(new TextureStore(new TextureLoaderStore(fileStore.Store), false, scaleAdjust: 1));
foreach (var layer in Storyboard.Layers)
{
if (cancellationToken.IsCancellationRequested)
break;
Add(layer.CreateDrawable());
}
}
private void updateLayerVisibility()

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -24,10 +25,13 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
private void load()
private void load(CancellationToken cancellationToken)
{
foreach (var element in Layer.Elements)
{
if (cancellationToken.IsCancellationRequested)
break;
if (element.IsDrawable)
AddInternal(element.CreateDrawable());
}

View File

@ -5,11 +5,10 @@ using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables;
using System.Collections.Generic;
using System.Linq;
using System;
namespace osu.Game.Storyboards
{
public class Storyboard : IDisposable
public class Storyboard
{
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
public IEnumerable<StoryboardLayer> Layers => layers.Values;
@ -56,30 +55,5 @@ namespace osu.Game.Storyboards
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
return drawable;
}
#region Disposal
~Storyboard()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private bool isDisposed;
protected virtual void Dispose(bool isDisposing)
{
if (isDisposed)
return;
isDisposed = true;
}
#endregion
}
}