2019-01-24 17:43:03 +09:00
|
|
|
// 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.
|
2018-10-25 19:11:57 +09:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-10-03 16:28:56 +09:00
|
|
|
using osu.Framework.Input;
|
|
|
|
using osu.Framework.Input.Events;
|
2018-10-25 19:11:57 +09:00
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-06 18:28:22 +09:00
|
|
|
using osu.Game.Screens.Edit.Compose;
|
2018-10-25 19:11:57 +09:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
|
|
|
[Cached(Type = typeof(IPlacementHandler))]
|
2019-05-14 22:37:25 +03:00
|
|
|
public abstract class PlacementBlueprintTestScene : OsuTestScene, IPlacementHandler
|
2018-10-25 19:11:57 +09:00
|
|
|
{
|
2019-06-04 12:08:23 +09:00
|
|
|
protected Container HitObjectContainer;
|
2018-11-06 18:04:03 +09:00
|
|
|
private PlacementBlueprint currentBlueprint;
|
2018-10-25 19:11:57 +09:00
|
|
|
|
2019-10-03 16:28:56 +09:00
|
|
|
private InputManager inputManager;
|
|
|
|
|
2019-05-14 22:37:25 +03:00
|
|
|
protected PlacementBlueprintTestScene()
|
2018-10-25 19:11:57 +09:00
|
|
|
{
|
2019-10-03 16:28:56 +09:00
|
|
|
Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
|
2018-10-25 19:11:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2019-06-04 12:08:23 +09:00
|
|
|
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2;
|
2018-10-25 19:11:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
{
|
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
dependencies.CacheAs<IAdjustableClock>(new StopwatchClock());
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
}
|
|
|
|
|
2019-10-03 16:28:56 +09:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
inputManager = GetContainingInputManager();
|
|
|
|
Add(currentBlueprint = CreateBlueprint());
|
|
|
|
}
|
|
|
|
|
2018-10-25 19:11:57 +09:00
|
|
|
public void BeginPlacement(HitObject hitObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void EndPlacement(HitObject hitObject)
|
|
|
|
{
|
2018-11-12 19:41:06 +09:00
|
|
|
AddHitObject(CreateHitObject(hitObject));
|
2018-10-25 19:11:57 +09:00
|
|
|
|
2018-11-06 18:04:03 +09:00
|
|
|
Remove(currentBlueprint);
|
2018-11-07 15:04:48 +09:00
|
|
|
Add(currentBlueprint = CreateBlueprint());
|
2018-10-25 19:11:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Delete(HitObject hitObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-10-03 16:28:56 +09:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2018-11-12 19:41:06 +09:00
|
|
|
|
|
|
|
protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
|
|
|
|
|
2019-10-03 16:28:56 +09:00
|
|
|
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
|
|
|
|
|
2018-10-25 19:11:57 +09:00
|
|
|
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
|
2018-11-07 15:04:48 +09:00
|
|
|
protected abstract PlacementBlueprint CreateBlueprint();
|
2018-10-25 19:11:57 +09:00
|
|
|
}
|
|
|
|
}
|