1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 03:42:57 +08:00

Move mod speed hotkey handler to user mod select overlay

The very base class is the wrong place for it because
`FreeModSelectOverlay` inherits from it, and that one has different
assumptions and rules than "user" selection. In particular, in non-user
selection, more than one rate adjust mod may be active, which breaks the
mod speed hotkey's basic assumptions.
This commit is contained in:
Bartłomiej Dach 2024-05-24 13:14:06 +02:00
parent b1b207960a
commit cab8cf7410
No known key found for this signature in database
2 changed files with 26 additions and 12 deletions

View File

@ -27,7 +27,6 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Select;
using osu.Game.Utils;
using osuTK;
using osuTK.Input;
@ -135,7 +134,6 @@ namespace osu.Game.Overlays.Mods
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
private FillFlowContainer footerContentFlow = null!;
private DeselectAllModsButton deselectAllModsButton = null!;
private ModSpeedHotkeyHandler modSpeedHotkeyHandler = null!;
private Container aboveColumnsContent = null!;
private RankingInformationDisplay? rankingInformationDisplay;
@ -189,7 +187,6 @@ namespace osu.Game.Overlays.Mods
Origin = Anchor.BottomCentre,
Height = 0
},
modSpeedHotkeyHandler = new ModSpeedHotkeyHandler(),
});
MainAreaContent.AddRange(new Drawable[]
@ -704,15 +701,6 @@ namespace osu.Game.Overlays.Mods
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.IncreaseModSpeed:
return modSpeedHotkeyHandler.ChangeSpeed(0.05, AllAvailableMods.Where(state => state.ValidForSelection.Value).Select(state => state.Mod));
case GlobalAction.DecreaseModSpeed:
return modSpeedHotkeyHandler.ChangeSpeed(-0.05, AllAvailableMods.Where(state => state.ValidForSelection.Value).Select(state => state.Mod));
}
if (e.Repeat)
return false;

View File

@ -3,18 +3,30 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Input.Events;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Select;
using osu.Game.Utils;
namespace osu.Game.Overlays.Mods
{
public partial class UserModSelectOverlay : ModSelectOverlay
{
private ModSpeedHotkeyHandler modSpeedHotkeyHandler = null!;
public UserModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Green)
: base(colourScheme)
{
}
[BackgroundDependencyLoader]
private void load()
{
Add(modSpeedHotkeyHandler = new ModSpeedHotkeyHandler());
}
protected override ModColumn CreateModColumn(ModType modType) => new UserModColumn(modType, false);
protected override IReadOnlyList<Mod> ComputeNewModsFromSelection(IReadOnlyList<Mod> oldSelection, IReadOnlyList<Mod> newSelection)
@ -38,6 +50,20 @@ namespace osu.Game.Overlays.Mods
return modsAfterRemoval.ToList();
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.IncreaseModSpeed:
return modSpeedHotkeyHandler.ChangeSpeed(0.05, AllAvailableMods.Where(state => state.ValidForSelection.Value).Select(state => state.Mod));
case GlobalAction.DecreaseModSpeed:
return modSpeedHotkeyHandler.ChangeSpeed(-0.05, AllAvailableMods.Where(state => state.ValidForSelection.Value).Select(state => state.Mod));
}
return base.OnPressed(e);
}
private partial class UserModColumn : ModColumn
{
public UserModColumn(ModType modType, bool allowIncompatibleSelection)