1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 20:53:04 +08:00

Add abstract ModType for ModSection.

This commit is contained in:
Huo Yaoyuan 2017-03-07 00:19:38 +08:00
parent 318ab68af1
commit 836484ba51
5 changed files with 33 additions and 28 deletions

View File

@ -4,12 +4,14 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
public class AssistedSection : ModSection public class AssistedSection : ModSection
{ {
protected override Key[] ToggleKeys => new Key[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M }; protected override Key[] ToggleKeys => new Key[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M };
public override ModType ModType => ModType.Special;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)

View File

@ -4,12 +4,14 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
public class DifficultyIncreaseSection : ModSection public class DifficultyIncreaseSection : ModSection
{ {
protected override Key[] ToggleKeys => new Key[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L }; protected override Key[] ToggleKeys => new Key[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L };
public override ModType ModType => ModType.DifficultyIncrease;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)

View File

@ -4,12 +4,14 @@
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
public class DifficultyReductionSection : ModSection public class DifficultyReductionSection : ModSection
{ {
protected override Key[] ToggleKeys => new Key[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P }; protected override Key[] ToggleKeys => new Key[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P };
public override ModType ModType => ModType.DifficultyReduction;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)

View File

@ -22,6 +22,7 @@ namespace osu.Game.Overlays.Mods
public Action<Mod> Action; public Action<Mod> Action;
protected abstract Key[] ToggleKeys { get; } protected abstract Key[] ToggleKeys { get; }
public abstract ModType ModType { get; }
public string Header public string Header
{ {

View File

@ -41,34 +41,8 @@ namespace osu.Game.Overlays.Mods
private void modeChanged(object sender, EventArgs eventArgs) private void modeChanged(object sender, EventArgs eventArgs)
{ {
var ruleset = Ruleset.GetRuleset(PlayMode); var ruleset = Ruleset.GetRuleset(PlayMode);
foreach (ModSection section in modSectionsContainer.Children)
modSectionsContainer.Children = new ModSection[] section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
{
new DifficultyReductionSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.DifficultyReduction).Select(m => new ModButton(m)).ToArray(),
},
new DifficultyIncreaseSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.DifficultyIncrease).Select(m => new ModButton(m)).ToArray(),
},
new AssistedSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
Buttons = ruleset.GetModsFor(ModType.Special).Select(m => new ModButton(m)).ToArray(),
},
};
} }
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
@ -298,6 +272,30 @@ namespace osu.Game.Overlays.Mods
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(0f, 10f), Spacing = new Vector2(0f, 10f),
Width = content_width, Width = content_width,
Children = new ModSection[]
{
new DifficultyReductionSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new DifficultyIncreaseSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new AssistedSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
}
}, },
// Footer // Footer
new Container new Container