mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 15:47:38 +09:00
Make ModSections overrideable
This commit is contained in:
parent
a800955bb1
commit
f2fa51bf5e
@ -11,26 +11,23 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Humanizer;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModSection : Container
|
public class ModSection : Container
|
||||||
{
|
{
|
||||||
private readonly OsuSpriteText headerLabel;
|
private readonly OsuSpriteText headerLabel;
|
||||||
|
|
||||||
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
|
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
|
||||||
|
|
||||||
public Action<Mod> Action;
|
public Action<Mod> Action;
|
||||||
protected abstract Key[] ToggleKeys { get; }
|
|
||||||
public abstract ModType ModType { get; }
|
|
||||||
|
|
||||||
public string Header
|
public Key[] ToggleKeys;
|
||||||
{
|
|
||||||
get => headerLabel.Text;
|
public readonly ModType ModType;
|
||||||
set => headerLabel.Text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
|
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
|
||||||
|
|
||||||
@ -153,7 +150,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
button.Deselect();
|
button.Deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ModSection()
|
public ModSection(ModType type)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -168,7 +165,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Position = new Vector2(0f, 0f),
|
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>
|
ButtonsContainer = new FillFlowContainer<ModButtonEmpty>
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays.Mods.Sections;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -190,13 +189,31 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Width = content_width,
|
Width = content_width,
|
||||||
LayoutDuration = 200,
|
LayoutDuration = 200,
|
||||||
LayoutEasing = Easing.OutQuint,
|
LayoutEasing = Easing.OutQuint,
|
||||||
Children = new ModSection[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new DifficultyReductionSection { Action = modButtonPressed },
|
CreateModSection(ModType.DifficultyReduction).With(s =>
|
||||||
new DifficultyIncreaseSection { Action = modButtonPressed },
|
{
|
||||||
new AutomationSection { Action = modButtonPressed },
|
s.ToggleKeys = new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P };
|
||||||
new ConversionSection { Action = modButtonPressed },
|
s.Action = modButtonPressed;
|
||||||
new FunSection { 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();
|
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||||
|
|
||||||
|
protected virtual ModSection CreateModSection(ModType type) => new ModSection(type);
|
||||||
|
|
||||||
#region Disposal
|
#region Disposal
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
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…
x
Reference in New Issue
Block a user