2019-01-24 16:43:03 +08: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-03 14:36:14 +08:00
|
|
|
|
2018-10-18 15:36:06 +08:00
|
|
|
using System.Linq;
|
2019-08-15 17:25:31 +08:00
|
|
|
using osu.Framework.Allocation;
|
2018-10-03 14:36:14 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2019-08-29 15:06:40 +08:00
|
|
|
using osu.Game.Screens.Edit;
|
2018-10-03 14:36:14 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Edit
|
|
|
|
{
|
2019-03-20 13:49:33 +08:00
|
|
|
public abstract class DrawableEditRuleset : CompositeDrawable
|
2018-10-03 14:36:14 +08:00
|
|
|
{
|
2018-10-17 17:01:38 +08:00
|
|
|
/// <summary>
|
2019-03-20 13:49:33 +08:00
|
|
|
/// The <see cref="Playfield"/> contained by this <see cref="DrawableEditRuleset"/>.
|
2018-10-17 17:01:38 +08:00
|
|
|
/// </summary>
|
|
|
|
public abstract Playfield Playfield { get; }
|
2018-10-03 14:36:14 +08:00
|
|
|
|
2019-03-31 00:29:37 +08:00
|
|
|
public abstract PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer();
|
|
|
|
|
2019-03-20 13:49:33 +08:00
|
|
|
internal DrawableEditRuleset()
|
2018-10-03 14:36:14 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 13:49:33 +08:00
|
|
|
public class DrawableEditRuleset<TObject> : DrawableEditRuleset
|
2018-10-03 14:36:14 +08:00
|
|
|
where TObject : HitObject
|
|
|
|
{
|
2019-03-20 10:22:34 +08:00
|
|
|
public override Playfield Playfield => drawableRuleset.Playfield;
|
2018-10-03 14:36:14 +08:00
|
|
|
|
2019-03-31 00:29:37 +08:00
|
|
|
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer();
|
|
|
|
|
2019-03-20 10:22:34 +08:00
|
|
|
private readonly DrawableRuleset<TObject> drawableRuleset;
|
2018-10-17 17:01:38 +08:00
|
|
|
|
2019-08-29 15:06:40 +08:00
|
|
|
[Resolved]
|
|
|
|
private EditorBeatmap<TObject> beatmap { get; set; }
|
|
|
|
|
2019-03-20 13:49:33 +08:00
|
|
|
public DrawableEditRuleset(DrawableRuleset<TObject> drawableRuleset)
|
2018-10-03 14:36:14 +08:00
|
|
|
{
|
2019-03-20 10:22:34 +08:00
|
|
|
this.drawableRuleset = drawableRuleset;
|
2018-10-17 17:01:38 +08:00
|
|
|
|
2019-03-20 10:22:34 +08:00
|
|
|
InternalChild = drawableRuleset;
|
2019-08-15 17:25:31 +08:00
|
|
|
}
|
2018-10-03 14:36:14 +08:00
|
|
|
|
2019-08-15 17:25:31 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
drawableRuleset.FrameStablePlayback = false;
|
2018-10-17 17:01:38 +08:00
|
|
|
Playfield.DisplayJudgements.Value = false;
|
2018-10-03 14:36:14 +08:00
|
|
|
}
|
|
|
|
|
2019-08-29 15:06:40 +08:00
|
|
|
protected override void LoadComplete()
|
2018-10-03 14:36:14 +08:00
|
|
|
{
|
2019-08-29 15:06:40 +08:00
|
|
|
base.LoadComplete();
|
2018-10-03 14:36:14 +08:00
|
|
|
|
2019-08-29 15:06:40 +08:00
|
|
|
beatmap.HitObjectAdded += addHitObject;
|
|
|
|
beatmap.HitObjectRemoved += removeHitObject;
|
|
|
|
}
|
2018-10-03 14:36:14 +08:00
|
|
|
|
2019-08-29 15:06:40 +08:00
|
|
|
private void addHitObject(HitObject hitObject)
|
|
|
|
{
|
|
|
|
var drawableObject = drawableRuleset.CreateDrawableRepresentation((TObject)hitObject);
|
2018-10-03 15:49:59 +08:00
|
|
|
|
2019-03-20 10:22:34 +08:00
|
|
|
drawableRuleset.Playfield.Add(drawableObject);
|
|
|
|
drawableRuleset.Playfield.PostProcess();
|
2018-10-03 14:36:14 +08:00
|
|
|
}
|
2018-10-18 15:36:06 +08:00
|
|
|
|
2019-08-29 15:06:40 +08:00
|
|
|
private void removeHitObject(HitObject hitObject)
|
2018-10-18 15:36:06 +08:00
|
|
|
{
|
|
|
|
var drawableObject = Playfield.AllHitObjects.Single(d => d.HitObject == hitObject);
|
|
|
|
|
2019-03-20 10:22:34 +08:00
|
|
|
drawableRuleset.Playfield.Remove(drawableObject);
|
|
|
|
drawableRuleset.Playfield.PostProcess();
|
2018-10-18 15:36:06 +08:00
|
|
|
}
|
2018-10-03 14:36:14 +08:00
|
|
|
}
|
|
|
|
}
|