1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Add secondary interface for further abstraction

This commit is contained in:
smoogipoo 2019-08-29 16:26:39 +09:00
parent 7927b684d3
commit 5db813b7a4
4 changed files with 30 additions and 10 deletions

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Edit
private readonly DrawableRuleset<TObject> drawableRuleset;
[Resolved]
private EditorBeatmap<TObject> beatmap { get; set; }
private IEditorBeatmap<TObject> beatmap { get; set; }
public DrawableEditRuleset(DrawableRuleset<TObject> drawableRuleset)
{

View File

@ -176,9 +176,6 @@ namespace osu.Game.Rulesets.Edit
where TObject : HitObject
{
private Beatmap<TObject> playableBeatmap;
[Cached]
[Cached(typeof(IEditorBeatmap))]
private EditorBeatmap<TObject> editorBeatmap;
protected HitObjectComposer(Ruleset ruleset)
@ -195,7 +192,11 @@ namespace osu.Game.Rulesets.Edit
editorBeatmap.HitObjectAdded += addHitObject;
editorBeatmap.HitObjectRemoved += removeHitObject;
return base.CreateChildDependencies(parent);
var dependencies = new DependencyContainer(parent);
dependencies.CacheAs<IEditorBeatmap>(editorBeatmap);
dependencies.CacheAs<IEditorBeatmap<TObject>>(editorBeatmap);
return base.CreateChildDependencies(dependencies);
}
private void addHitObject(HitObject hitObject)

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Edit
{
public class EditorBeatmap<T> : IBeatmap<T>, IEditorBeatmap
public class EditorBeatmap<T> : IEditorBeatmap<T>
where T : HitObject
{
public event Action<HitObject> HitObjectAdded;

View File

@ -2,16 +2,35 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Edit
{
public interface IEditorBeatmap
/// <summary>
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
/// </summary>
public interface IEditorBeatmap : IBeatmap
{
/// <summary>
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="IEditorBeatmap"/>.
/// </summary>
event Action<HitObject> HitObjectAdded;
event Action<HitObject> HitObjectRemoved;
void Add(HitObject hitObject);
void Remove(HitObject hitObject);
/// <summary>
/// Invoked when a <see cref="HitObject"/> is removed from this <see cref="IEditorBeatmap"/>.
/// </summary>
event Action<HitObject> HitObjectRemoved;
}
/// <summary>
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
/// </summary>
public interface IEditorBeatmap<out T> : IEditorBeatmap, IBeatmap<T>
where T : HitObject
{
}
}