mirror of
https://github.com/ppy/osu
synced 2025-02-16 18:17:01 +00:00
Add extension point for ruleset-specific beatmap setup sections
This commit is contained in:
parent
cdd0262ca1
commit
ce1912781e
@ -28,6 +28,7 @@ using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Rulesets.Filter;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
@ -315,5 +316,11 @@ namespace osu.Game.Rulesets
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public virtual IRulesetFilterCriteria CreateRulesetFilterCriteria() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Can be overridden to add a ruleset-specific section to the editor beatmap setup screen.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public virtual RulesetSetupSection CreateEditorSetupSectionForRuleset() => null;
|
||||
}
|
||||
}
|
||||
|
20
osu.Game/Screens/Edit/Setup/RulesetSetupSection.cs
Normal file
20
osu.Game/Screens/Edit/Setup/RulesetSetupSection.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.Localisation;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
public abstract class RulesetSetupSection : SetupSection
|
||||
{
|
||||
public sealed override LocalisableString Title => $"{rulesetInfo.Name}-specific";
|
||||
|
||||
private readonly RulesetInfo rulesetInfo;
|
||||
|
||||
protected RulesetSetupSection(RulesetInfo rulesetInfo)
|
||||
{
|
||||
this.rulesetInfo = rulesetInfo;
|
||||
}
|
||||
}
|
||||
}
|
@ -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 System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -21,22 +22,28 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(EditorBeatmap beatmap)
|
||||
{
|
||||
var sectionsEnumerable = new List<SetupSection>
|
||||
{
|
||||
new ResourcesSection(),
|
||||
new MetadataSection(),
|
||||
new DifficultySection(),
|
||||
new ColoursSection(),
|
||||
new DesignSection(),
|
||||
};
|
||||
|
||||
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateEditorSetupSectionForRuleset();
|
||||
if (rulesetSpecificSection != null)
|
||||
sectionsEnumerable.Add(rulesetSpecificSection);
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
sections = new SetupScreenSectionsContainer
|
||||
{
|
||||
FixedHeader = header,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new SetupSection[]
|
||||
{
|
||||
new ResourcesSection(),
|
||||
new MetadataSection(),
|
||||
new DifficultySection(),
|
||||
new ColoursSection(),
|
||||
new DesignSection(),
|
||||
}
|
||||
ChildrenEnumerable = sectionsEnumerable,
|
||||
FixedHeader = header
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
internal abstract class SetupSection : Container
|
||||
public abstract class SetupSection : Container
|
||||
{
|
||||
private readonly FillFlowContainer flow;
|
||||
private FillFlowContainer flow;
|
||||
|
||||
/// <summary>
|
||||
/// Used to align some of the child <see cref="LabelledDrawable{T}"/>s together to achieve a grid-like look.
|
||||
@ -31,7 +31,8 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
|
||||
public abstract LocalisableString Title { get; }
|
||||
|
||||
protected SetupSection()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
Loading…
Reference in New Issue
Block a user