Fix placement blueprint test scenes not working

This commit is contained in:
smoogipoo 2019-10-03 16:28:56 +09:00
parent 652acac87f
commit f2ba87a1d2
1 changed files with 31 additions and 3 deletions

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 @@ public abstract class PlacementBlueprintTestScene : OsuTestScene, IPlacementHand
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 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
return dependencies;
}
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
Add(currentBlueprint = CreateBlueprint());
}
public void BeginPlacement(HitObject hitObject)
{
}
@ -54,10 +65,27 @@ public void Delete(HitObject hitObject)
{
}
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();
}