Merge branch 'master' into remove-dispose-updates

This commit is contained in:
Dean Herbert
2022-09-01 23:03:19 +09:00
111 changed files with 1638 additions and 878 deletions

View File

@ -6,6 +6,8 @@
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
@ -24,30 +26,39 @@ namespace osu.Game.Tests.Visual
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
[Cached]
protected new readonly EditorClock Clock;
protected EditorClock EditorClock;
private readonly Bindable<double> frequencyAdjustment = new BindableDouble(1);
private IBeatmap editorClockBeatmap;
protected virtual bool ScrollUsingMouseWheel => true;
protected EditorClockTestScene()
{
Clock = new EditorClock(new Beatmap(), BeatDivisor) { IsCoupled = false };
}
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content = new Container { RelativeSizeAxes = Axes.Both };
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
editorClockBeatmap = CreateEditorClockBeatmap();
base.Content.AddRange(new Drawable[]
{
EditorClock = new EditorClock(editorClockBeatmap, BeatDivisor),
content
});
dependencies.Cache(BeatDivisor);
dependencies.CacheAs(Clock);
dependencies.CacheAs(EditorClock);
return dependencies;
}
protected override void LoadComplete()
{
Beatmap.Value = CreateWorkingBeatmap(editorClockBeatmap);
base.LoadComplete();
Beatmap.BindValueChanged(beatmapChanged, true);
@ -55,22 +66,13 @@ namespace osu.Game.Tests.Visual
AddSliderStep("editor clock rate", 0.0, 2.0, 1.0, v => frequencyAdjustment.Value = v);
}
protected virtual IBeatmap CreateEditorClockBeatmap() => new Beatmap();
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
{
e.OldValue?.Track.RemoveAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
Clock.Beatmap = e.NewValue.Beatmap;
Clock.ChangeSource(e.NewValue.Track);
Clock.ProcessFrame();
e.NewValue.Track.AddAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
}
protected override void Update()
{
base.Update();
Clock.ProcessFrame();
EditorClock.ChangeSource(e.NewValue.Track);
}
protected override bool OnScroll(ScrollEvent e)
@ -79,9 +81,9 @@ namespace osu.Game.Tests.Visual
return false;
if (e.ScrollDelta.Y > 0)
Clock.SeekBackward(true);
EditorClock.SeekBackward(true);
else
Clock.SeekForward(true);
EditorClock.SeekForward(true);
return true;
}

View File

@ -30,10 +30,15 @@ namespace osu.Game.Tests.Visual
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(new EditorClock());
var playable = GetPlayableBeatmap();
dependencies.CacheAs(new EditorBeatmap(playable));
var editorClock = new EditorClock();
base.Content.Add(editorClock);
dependencies.CacheAs(editorClock);
var editorBeatmap = new EditorBeatmap(playable);
// Not adding to hierarchy as we don't satisfy its dependencies. Probably not good.
dependencies.CacheAs(editorBeatmap);
return dependencies;
}

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -19,19 +16,23 @@ namespace osu.Game.Tests.Visual
[Cached]
private readonly EditorClock editorClock = new EditorClock();
protected override Container<Drawable> Content => content ?? base.Content;
protected override Container<Drawable> Content => content;
private readonly Container content;
protected SelectionBlueprintTestScene()
{
base.Content.Add(content = new Container
base.Content.AddRange(new Drawable[]
{
Clock = new FramedClock(new StopwatchClock()),
RelativeSizeAxes = Axes.Both
editorClock,
content = new Container
{
Clock = new FramedClock(new StopwatchClock()),
RelativeSizeAxes = Axes.Both
}
});
}
protected void AddBlueprint(HitObjectSelectionBlueprint blueprint, [CanBeNull] DrawableHitObject drawableObject = null)
protected void AddBlueprint(HitObjectSelectionBlueprint blueprint, DrawableHitObject? drawableObject = null)
{
Add(blueprint.With(d =>
{