mirror of
https://github.com/ppy/osu
synced 2025-01-18 03:50:57 +00:00
Set up flow for switching between hotkey styles
This commit is contained in:
parent
5abd8a07d2
commit
658f5341c7
@ -9,9 +9,11 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Overlays.Mods.Input;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Utils;
|
||||
@ -25,6 +27,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager configManager { get; set; } = null!;
|
||||
|
||||
[TestCase(ModType.DifficultyReduction)]
|
||||
[TestCase(ModType.DifficultyIncrease)]
|
||||
[TestCase(ModType.Conversion)]
|
||||
@ -132,8 +137,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestKeyboardSelection()
|
||||
public void TestSequentialKeyboardSelection()
|
||||
{
|
||||
AddStep("set sequential hotkey mode", () => configManager.SetValue(OsuSetting.ModSelectHotkeyStyle, ModSelectHotkeyStyle.Sequential));
|
||||
|
||||
ModColumn column = null!;
|
||||
AddStep("create content", () => Child = new Container
|
||||
{
|
||||
|
16
osu.Game/Overlays/Mods/Input/ClassicModHotkeyHandler.cs
Normal file
16
osu.Game/Overlays/Mods/Input/ClassicModHotkeyHandler.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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 osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Mods.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Uses bindings from stable 1:1.
|
||||
/// </summary>
|
||||
public class ClassicModHotkeyHandler : IModHotkeyHandler
|
||||
{
|
||||
public bool HandleHotkeyPressed(Key hotkey, IEnumerable<ModState> availableMods) => false; // TODO
|
||||
}
|
||||
}
|
@ -13,14 +13,16 @@ namespace osu.Game.Overlays.Mods.Input
|
||||
/// <summary>
|
||||
/// Creates an appropriate <see cref="IModHotkeyHandler"/> for the given <paramref name="modType"/>.
|
||||
/// </summary>
|
||||
public static IModHotkeyHandler Create(ModType modType)
|
||||
public static IModHotkeyHandler Create(ModType modType, ModSelectHotkeyStyle style)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case ModType.DifficultyReduction:
|
||||
case ModType.DifficultyIncrease:
|
||||
case ModType.Automation:
|
||||
return SequentialModHotkeyHandler.Create(modType);
|
||||
return style == ModSelectHotkeyStyle.Sequential
|
||||
? (IModHotkeyHandler)SequentialModHotkeyHandler.Create(modType)
|
||||
: new ClassicModHotkeyHandler();
|
||||
|
||||
default:
|
||||
return new NoopModHotkeyHandler();
|
||||
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -70,7 +71,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected virtual ModPanel CreateModPanel(ModState mod) => new ModPanel(mod);
|
||||
|
||||
private readonly IModHotkeyHandler hotkeyHandler;
|
||||
private Bindable<ModSelectHotkeyStyle> hotkeyStyle = null!;
|
||||
private IModHotkeyHandler hotkeyHandler = null!;
|
||||
|
||||
private readonly TextFlowContainer headerText;
|
||||
private readonly Box headerBackground;
|
||||
@ -89,7 +91,6 @@ namespace osu.Game.Overlays.Mods
|
||||
public ModColumn(ModType modType, bool allowBulkSelection)
|
||||
{
|
||||
ModType = modType;
|
||||
hotkeyHandler = ModHotkeyHandler.Create(modType);
|
||||
|
||||
Width = 320;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
@ -231,7 +232,7 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
||||
private void load(OverlayColourProvider colourProvider, OsuColour colours, OsuConfigManager configManager)
|
||||
{
|
||||
headerBackground.Colour = accentColour = colours.ForModType(ModType);
|
||||
|
||||
@ -243,6 +244,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
contentContainer.BorderColour = ColourInfo.GradientVertical(colourProvider.Background4, colourProvider.Background3);
|
||||
contentBackground.Colour = colourProvider.Background4;
|
||||
|
||||
hotkeyStyle = configManager.GetBindable<ModSelectHotkeyStyle>(OsuSetting.ModSelectHotkeyStyle);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -250,6 +253,7 @@ namespace osu.Game.Overlays.Mods
|
||||
base.LoadComplete();
|
||||
|
||||
toggleAllCheckbox?.Current.BindValueChanged(_ => updateToggleAllText(), true);
|
||||
hotkeyStyle.BindValueChanged(val => hotkeyHandler = ModHotkeyHandler.Create(ModType, val.NewValue), true);
|
||||
asyncLoadPanels();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user