Merge branch 'master' into rework-selection-updates

This commit is contained in:
Dean Herbert
2019-10-06 15:00:56 +08:00
committed by GitHub
87 changed files with 1433 additions and 410 deletions

View File

@ -28,9 +28,9 @@ namespace osu.Game.Tests.Visual
{
[Cached(typeof(Bindable<WorkingBeatmap>))]
[Cached(typeof(IBindable<WorkingBeatmap>))]
private OsuTestBeatmap beatmap;
private NonNullableBindable<WorkingBeatmap> beatmap;
protected BindableBeatmap Beatmap => beatmap;
protected Bindable<WorkingBeatmap> Beatmap => beatmap;
[Cached]
[Cached(typeof(IBindable<RulesetInfo>))]
@ -73,10 +73,13 @@ namespace osu.Game.Tests.Visual
// This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
var working = new DummyWorkingBeatmap(parent.Get<AudioManager>(), parent.Get<TextureStore>());
beatmap = new OsuTestBeatmap(working)
beatmap = new NonNullableBindable<WorkingBeatmap>(working) { Default = working };
beatmap.BindValueChanged(b => ScheduleAfterChildren(() =>
{
Default = working
};
// compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (b.OldValue?.TrackLoaded == true && b.OldValue?.Track != b.NewValue?.Track)
b.OldValue.RecycleTrack();
}));
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
@ -317,13 +320,5 @@ namespace osu.Game.Tests.Visual
public void RunTestBlocking(TestScene test) => runner.RunTestBlocking(test);
}
private class OsuTestBeatmap : BindableBeatmap
{
public OsuTestBeatmap(WorkingBeatmap defaultValue)
: base(defaultValue)
{
}
}
}
}

View File

@ -4,6 +4,8 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
@ -18,16 +20,17 @@ namespace osu.Game.Tests.Visual
protected Container HitObjectContainer;
private PlacementBlueprint currentBlueprint;
private InputManager inputManager;
protected PlacementBlueprintTestScene()
{
Add(HitObjectContainer = CreateHitObjectContainer());
Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
}
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2;
Add(currentBlueprint = CreateBlueprint());
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -38,6 +41,14 @@ namespace osu.Game.Tests.Visual
return dependencies;
}
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
Add(currentBlueprint = CreateBlueprint());
}
public void BeginPlacement(HitObject hitObject)
{
}
@ -54,10 +65,27 @@ namespace osu.Game.Tests.Visual
{
}
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
protected override bool OnMouseMove(MouseMoveEvent e)
{
currentBlueprint.UpdatePosition(e.ScreenSpaceMousePosition);
return true;
}
public override void Add(Drawable drawable)
{
base.Add(drawable);
if (drawable is PlacementBlueprint blueprint)
{
blueprint.Show();
blueprint.UpdatePosition(inputManager.CurrentState.Mouse.Position);
}
}
protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
protected abstract PlacementBlueprint CreateBlueprint();
}