2017-11-29 15:22:11 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-11-30 15:58:14 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2017-11-30 16:38:55 +08:00
|
|
|
using OpenTK.Graphics;
|
2017-11-29 16:46:12 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-11-30 16:38:55 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-11-30 15:58:14 +08:00
|
|
|
using osu.Framework.Logging;
|
|
|
|
using osu.Framework.Timing;
|
2017-11-30 18:19:34 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2017-11-30 15:58:14 +08:00
|
|
|
using osu.Game.Rulesets.Edit.Tools;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
|
2017-11-29 16:46:12 +08:00
|
|
|
|
2017-11-29 15:22:11 +08:00
|
|
|
namespace osu.Game.Rulesets.Edit
|
|
|
|
{
|
2017-11-29 16:46:12 +08:00
|
|
|
public abstract class HitObjectComposer : CompositeDrawable
|
2017-11-29 15:22:11 +08:00
|
|
|
{
|
2017-11-29 16:46:12 +08:00
|
|
|
private readonly Ruleset ruleset;
|
|
|
|
|
2017-11-30 17:48:00 +08:00
|
|
|
protected HitObjectComposer(Ruleset ruleset)
|
2017-11-29 16:46:12 +08:00
|
|
|
{
|
|
|
|
this.ruleset = ruleset;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
2017-11-29 15:22:11 +08:00
|
|
|
|
2017-11-29 16:46:12 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuGameBase osuGame)
|
|
|
|
{
|
2017-11-30 15:58:14 +08:00
|
|
|
RulesetContainer rulesetContainer;
|
2017-11-29 16:46:12 +08:00
|
|
|
try
|
|
|
|
{
|
2017-11-30 18:19:34 +08:00
|
|
|
rulesetContainer = CreateRulesetContainer(ruleset, osuGame.Beatmap.Value);
|
2017-11-29 16:46:12 +08:00
|
|
|
}
|
2017-11-30 15:58:14 +08:00
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioButtonCollection toolboxCollection;
|
|
|
|
InternalChild = new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Name = "Sidebar",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Right = 10 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ToolboxGroup { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
2017-11-30 16:38:55 +08:00
|
|
|
BorderColour = Color4.White,
|
|
|
|
BorderThickness = 2,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true,
|
|
|
|
},
|
|
|
|
rulesetContainer
|
|
|
|
}
|
2017-11-30 15:58:14 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.Absolute, 200),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
rulesetContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)osuGame.Beatmap.Value.Track ?? new StopwatchClock());
|
|
|
|
|
|
|
|
toolboxCollection.Items =
|
|
|
|
new[] { new RadioButton("Select", () => setCompositionTool(new SelectionTool())) }
|
|
|
|
.Concat(
|
|
|
|
CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t)))
|
|
|
|
)
|
|
|
|
.ToList();
|
2017-11-29 16:46:12 +08:00
|
|
|
}
|
2017-11-30 15:58:14 +08:00
|
|
|
|
|
|
|
private void setCompositionTool(ICompositionTool tool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:19:34 +08:00
|
|
|
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
|
|
|
|
2017-11-30 15:58:14 +08:00
|
|
|
protected abstract IReadOnlyList<ICompositionTool> CompositionTools { get; }
|
2017-11-29 15:22:11 +08:00
|
|
|
}
|
|
|
|
}
|