mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into rework-selection-updates
This commit is contained in:
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user