osu/osu.Game/Tests/Visual/PlacementBlueprintTestCase.cs

66 lines
2.1 KiB
C#
Raw Normal View History

2018-10-25 10:11:57 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
2018-11-06 09:28:22 +00:00
using osu.Game.Screens.Edit.Compose;
2018-10-25 10:11:57 +00:00
namespace osu.Game.Tests.Visual
{
[Cached(Type = typeof(IPlacementHandler))]
2018-11-06 09:06:13 +00:00
public abstract class PlacementBlueprintTestCase : OsuTestCase, IPlacementHandler
2018-10-25 10:11:57 +00:00
{
2018-11-12 10:41:06 +00:00
protected readonly Container HitObjectContainer;
2018-11-06 09:04:03 +00:00
private PlacementBlueprint currentBlueprint;
2018-10-25 10:11:57 +00:00
2018-11-06 09:06:13 +00:00
protected PlacementBlueprintTestCase()
2018-10-25 10:11:57 +00:00
{
2018-10-26 06:36:09 +00:00
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2;
2018-11-12 10:41:06 +00:00
Add(HitObjectContainer = CreateHitObjectContainer());
2018-10-25 10:11:57 +00:00
}
[BackgroundDependencyLoader]
private void load()
{
2018-11-07 06:04:48 +00:00
Add(currentBlueprint = CreateBlueprint());
2018-10-25 10:11:57 +00:00
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IAdjustableClock>(new StopwatchClock());
return dependencies;
}
public void BeginPlacement(HitObject hitObject)
{
}
public void EndPlacement(HitObject hitObject)
{
2018-11-12 10:41:06 +00:00
AddHitObject(CreateHitObject(hitObject));
2018-10-25 10:11:57 +00:00
2018-11-06 09:04:03 +00:00
Remove(currentBlueprint);
2018-11-07 06:04:48 +00:00
Add(currentBlueprint = CreateBlueprint());
2018-10-25 10:11:57 +00:00
}
public void Delete(HitObject hitObject)
{
}
2018-11-12 10:41:06 +00:00
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
2018-10-25 10:11:57 +00:00
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
2018-11-07 06:04:48 +00:00
protected abstract PlacementBlueprint CreateBlueprint();
2018-10-25 10:11:57 +00:00
}
}