2019-01-24 08:43:03 +00: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-04-13 09:19:50 +00:00
|
|
|
|
2020-09-29 08:26:49 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-29 08:26:49 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets;
|
2019-12-05 11:12:25 +00:00
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
2019-10-08 03:52:34 +00:00
|
|
|
using osu.Game.Skinning;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-11-06 09:28:22 +00:00
|
|
|
namespace osu.Game.Screens.Edit.Compose
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-10-09 07:05:55 +00:00
|
|
|
public class ComposeScreen : EditorScreenWithTimeline
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-12-05 11:12:25 +00:00
|
|
|
private HitObjectComposer composer;
|
|
|
|
|
2020-09-24 08:03:54 +00:00
|
|
|
public ComposeScreen()
|
|
|
|
: base(EditorScreenMode.Compose)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-29 08:26:49 +00:00
|
|
|
private Ruleset ruleset;
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-09-29 08:26:49 +00:00
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
|
|
|
|
ruleset = parent.Get<IBindable<WorkingBeatmap>>().Value.BeatmapInfo.Ruleset?.CreateInstance();
|
2019-12-05 11:12:25 +00:00
|
|
|
composer = ruleset?.CreateHitObjectComposer();
|
2019-04-01 03:16:05 +00:00
|
|
|
|
2020-09-29 08:26:49 +00:00
|
|
|
// make the composer available to the timeline and other components in this screen.
|
|
|
|
dependencies.CacheAs(composer);
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateMainContent()
|
|
|
|
{
|
2019-12-06 03:51:43 +00:00
|
|
|
if (ruleset == null || composer == null)
|
|
|
|
return new ScreenWhiteBox.UnderConstructionMessage(ruleset == null ? "This beatmap" : $"{ruleset.Description}'s composer");
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-06 03:51:43 +00:00
|
|
|
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
2019-10-08 03:52:34 +00:00
|
|
|
|
2019-12-06 03:51:43 +00:00
|
|
|
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
|
|
|
// full access to all skin sources.
|
2020-04-02 09:39:49 +00:00
|
|
|
var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, EditorBeatmap.PlayableBeatmap));
|
2019-10-08 03:52:34 +00:00
|
|
|
|
2019-12-06 03:51:43 +00:00
|
|
|
// 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(composer));
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
2019-12-05 11:12:25 +00:00
|
|
|
|
2020-11-12 10:52:02 +00:00
|
|
|
protected override Drawable CreateTimelineContent() => composer == null ? base.CreateTimelineContent() : new TimelineBlueprintContainer(composer);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|