Make work in editor

This commit is contained in:
Dean Herbert
2019-12-05 20:12:25 +09:00
parent e225b0032a
commit d8620a70fb
8 changed files with 53 additions and 23 deletions

View File

@ -47,10 +47,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
HighColour = colours.BlueDarker,
Depth = float.MaxValue
},
new TimelineHitObjectDisplay
{
RelativeSizeAxes = Axes.Both,
},
};
// We don't want the centre marker to scroll

View File

@ -1,6 +1,7 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -11,11 +12,14 @@ using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
public class TimelineArea : CompositeDrawable
public class TimelineArea : Container
{
private readonly Timeline timeline;
private Timeline timeline;
public TimelineArea()
protected override Container<Drawable> Content => timeline;
[BackgroundDependencyLoader]
private void load()
{
Masking = true;
CornerRadius = 5;

View File

@ -16,8 +16,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
internal class TimelineHitObjectDisplay : TimelinePart
{
[Resolved]
private IEditorBeatmap beatmap { get; set; }
private IEditorBeatmap beatmap { get; }
public TimelineHitObjectDisplay(IEditorBeatmap beatmap)
{
this.beatmap = beatmap;
}
[BackgroundDependencyLoader]
private void load()
@ -27,18 +31,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
beatmap.HitObjectAdded += add;
beatmap.HitObjectRemoved += remove;
beatmap.StartTimeChanged += h =>
{
remove(h);
add(h);
};
}
private void remove(HitObject h)
{
foreach (var d in InternalChildren.OfType<TimelineHitObjectRepresentation>().Where(c => c.HitObject == h))
foreach (var d in Children.OfType<TimelineHitObjectRepresentation>().Where(c => c.HitObject == h))
d.Expire();
}
private void add(HitObject h)
{
Add(new TimelineHitObjectRepresentation(h));
}
private void add(HitObject h) => Add(new TimelineHitObjectRepresentation(h));
private class TimelineHitObjectRepresentation : CompositeDrawable
{

View File

@ -3,17 +3,21 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osu.Game.Skinning;
namespace osu.Game.Screens.Edit.Compose
{
public class ComposeScreen : EditorScreenWithTimeline
{
private HitObjectComposer composer;
protected override Drawable CreateMainContent()
{
var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance();
var composer = ruleset?.CreateHitObjectComposer();
composer = ruleset?.CreateHitObjectComposer();
if (composer != null)
{
@ -25,10 +29,15 @@ namespace osu.Game.Screens.Edit.Compose
// load the skinning hierarchy first.
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
return beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(ruleset.CreateHitObjectComposer()));
return beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(composer));
}
return new ScreenWhiteBox.UnderConstructionMessage(ruleset == null ? "This beatmap" : $"{ruleset.Description}'s composer");
}
protected override Drawable CreateTimelineContent() => new TimelineHitObjectDisplay(composer.EditorBeatmap)
{
RelativeSizeAxes = Axes.Both,
};
}
}