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-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Logging;
|
2018-10-17 16:41:17 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-10-17 14:46:30 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-11-06 17:28:22 +08:00
|
|
|
using osu.Game.Screens.Edit.Compose.Components;
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-11-06 17:28:22 +08:00
|
|
|
namespace osu.Game.Screens.Edit.Compose
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-10-17 14:46:30 +08:00
|
|
|
[Cached(Type = typeof(IPlacementHandler))]
|
2018-11-07 12:04:17 +08:00
|
|
|
public class ComposeScreen : EditorScreen, IPlacementHandler
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
private const float vertical_margins = 10;
|
|
|
|
private const float horizontal_margins = 20;
|
|
|
|
|
|
|
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
|
|
|
|
2018-10-17 16:41:17 +08:00
|
|
|
private HitObjectComposer composer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load([CanBeNull] BindableBeatDivisor beatDivisor)
|
|
|
|
{
|
|
|
|
if (beatDivisor != null)
|
|
|
|
this.beatDivisor.BindTo(beatDivisor);
|
|
|
|
|
2018-10-17 16:41:17 +08:00
|
|
|
Container composerContainer;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Name = "Timeline",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black.Opacity(0.5f)
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Name = "Timeline content",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Horizontal = horizontal_margins, Vertical = vertical_margins },
|
|
|
|
Child = new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2018-06-11 19:08:17 +08:00
|
|
|
Child = new TimelineArea { RelativeSizeAxes = Axes.Both }
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
|
|
|
new BeatDivisorControl(beatDivisor) { RelativeSizeAxes = Axes.Both }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Absolute, 90),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
composerContainer = new Container
|
|
|
|
{
|
|
|
|
Name = "Composer content",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Horizontal = horizontal_margins, Vertical = vertical_margins },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 110) }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance();
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
if (ruleset == null)
|
|
|
|
{
|
|
|
|
Logger.Log("Beatmap doesn't have a ruleset assigned.");
|
|
|
|
// ExitRequested?.Invoke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-17 16:41:17 +08:00
|
|
|
composer = ruleset.CreateHitObjectComposer();
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
if (composer == null)
|
|
|
|
{
|
|
|
|
Logger.Log($"Ruleset {ruleset.Description} doesn't support hitobject composition.");
|
|
|
|
// ExitRequested?.Invoke();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
composerContainer.Child = composer;
|
|
|
|
}
|
2018-10-17 14:46:30 +08:00
|
|
|
|
2018-10-17 16:41:17 +08:00
|
|
|
public void BeginPlacement(HitObject hitObject)
|
|
|
|
{
|
|
|
|
}
|
2018-10-17 14:46:30 +08:00
|
|
|
|
2018-10-17 16:41:17 +08:00
|
|
|
public void EndPlacement(HitObject hitObject) => composer.Add(hitObject);
|
2018-10-18 15:36:06 +08:00
|
|
|
|
|
|
|
public void Delete(HitObject hitObject) => composer.Remove(hitObject);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|