mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +08:00
Make ModSections overrideable
This commit is contained in:
parent
a800955bb1
commit
f2fa51bf5e
@ -11,26 +11,23 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Humanizer;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public abstract class ModSection : Container
|
||||
public class ModSection : Container
|
||||
{
|
||||
private readonly OsuSpriteText headerLabel;
|
||||
|
||||
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
|
||||
|
||||
public Action<Mod> Action;
|
||||
protected abstract Key[] ToggleKeys { get; }
|
||||
public abstract ModType ModType { get; }
|
||||
|
||||
public string Header
|
||||
{
|
||||
get => headerLabel.Text;
|
||||
set => headerLabel.Text = value;
|
||||
}
|
||||
public Key[] ToggleKeys;
|
||||
|
||||
public readonly ModType ModType;
|
||||
|
||||
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
|
||||
|
||||
@ -153,7 +150,7 @@ namespace osu.Game.Overlays.Mods
|
||||
button.Deselect();
|
||||
}
|
||||
|
||||
protected ModSection()
|
||||
public ModSection(ModType type)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -168,7 +165,8 @@ namespace osu.Game.Overlays.Mods
|
||||
Origin = Anchor.TopLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Position = new Vector2(0f, 0f),
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
||||
Text = type.Humanize(LetterCasing.Title)
|
||||
},
|
||||
ButtonsContainer = new FillFlowContainer<ModButtonEmpty>
|
||||
{
|
||||
|
@ -19,7 +19,6 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Overlays.Mods.Sections;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
@ -190,13 +189,31 @@ namespace osu.Game.Overlays.Mods
|
||||
Width = content_width,
|
||||
LayoutDuration = 200,
|
||||
LayoutEasing = Easing.OutQuint,
|
||||
Children = new ModSection[]
|
||||
Children = new[]
|
||||
{
|
||||
new DifficultyReductionSection { Action = modButtonPressed },
|
||||
new DifficultyIncreaseSection { Action = modButtonPressed },
|
||||
new AutomationSection { Action = modButtonPressed },
|
||||
new ConversionSection { Action = modButtonPressed },
|
||||
new FunSection { Action = modButtonPressed },
|
||||
CreateModSection(ModType.DifficultyReduction).With(s =>
|
||||
{
|
||||
s.ToggleKeys = new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P };
|
||||
s.Action = modButtonPressed;
|
||||
}),
|
||||
CreateModSection(ModType.DifficultyIncrease).With(s =>
|
||||
{
|
||||
s.ToggleKeys = new[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L };
|
||||
s.Action = modButtonPressed;
|
||||
}),
|
||||
CreateModSection(ModType.Automation).With(s =>
|
||||
{
|
||||
s.ToggleKeys = new[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M };
|
||||
s.Action = modButtonPressed;
|
||||
}),
|
||||
CreateModSection(ModType.Conversion).With(s =>
|
||||
{
|
||||
s.Action = modButtonPressed;
|
||||
}),
|
||||
CreateModSection(ModType.Fun).With(s =>
|
||||
{
|
||||
s.Action = modButtonPressed;
|
||||
}),
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -455,6 +472,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||
|
||||
protected virtual ModSection CreateModSection(ModType type) => new ModSection(type);
|
||||
|
||||
#region Disposal
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -1,19 +0,0 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Sections
|
||||
{
|
||||
public class AutomationSection : ModSection
|
||||
{
|
||||
protected override Key[] ToggleKeys => new[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M };
|
||||
public override ModType ModType => ModType.Automation;
|
||||
|
||||
public AutomationSection()
|
||||
{
|
||||
Header = @"Automation";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Sections
|
||||
{
|
||||
public class ConversionSection : ModSection
|
||||
{
|
||||
protected override Key[] ToggleKeys => null;
|
||||
public override ModType ModType => ModType.Conversion;
|
||||
|
||||
public ConversionSection()
|
||||
{
|
||||
Header = @"Conversion";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Sections
|
||||
{
|
||||
public class DifficultyIncreaseSection : ModSection
|
||||
{
|
||||
protected override Key[] ToggleKeys => new[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L };
|
||||
public override ModType ModType => ModType.DifficultyIncrease;
|
||||
|
||||
public DifficultyIncreaseSection()
|
||||
{
|
||||
Header = @"Difficulty Increase";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Sections
|
||||
{
|
||||
public class DifficultyReductionSection : ModSection
|
||||
{
|
||||
protected override Key[] ToggleKeys => new[] { 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;
|
||||
|
||||
public DifficultyReductionSection()
|
||||
{
|
||||
Header = @"Difficulty Reduction";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Sections
|
||||
{
|
||||
public class FunSection : ModSection
|
||||
{
|
||||
protected override Key[] ToggleKeys => null;
|
||||
public override ModType ModType => ModType.Fun;
|
||||
|
||||
public FunSection()
|
||||
{
|
||||
Header = @"Fun";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user