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

Change Speedchange behaviour to keep changing while holding key, Add Toast to nofity user what just happend

This commit is contained in:
Fabian van Oeffelt 2024-05-21 14:47:34 +02:00
parent 3fdbd735ce
commit 148afd1201
3 changed files with 40 additions and 8 deletions

View File

@ -49,6 +49,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString UrlCopied => new TranslatableString(getKey(@"url_copied"), @"URL copied");
/// <summary>
/// "Speed Changed"
/// </summary>
public static LocalisableString SpeedChanged => new TranslatableString(getKey(@"speed_changed"), @"Speed Changed");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -0,0 +1,17 @@
// 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.Configuration;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
namespace osu.Game.Overlays.OSD
{
public partial class SpeedChangeToast : Toast
{
public SpeedChangeToast(OsuConfigManager config, double delta)
: base(CommonStrings.Beatmaps, ToastStrings.SpeedChanged, config.LookupKeyBindings(GlobalAction.IncreaseSpeed) + " / " + config.LookupKeyBindings(GlobalAction.DecreaseSpeed))
{
}
}
}

View File

@ -30,6 +30,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Overlays.OSD;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds;
@ -151,6 +152,12 @@ namespace osu.Game.Screens.Select
private bool usedPitchMods;
[Resolved]
private OnScreenDisplay? onScreenDisplay { get; set; }
[Resolved]
private OsuConfigManager? config { get; set; }
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender, OsuConfigManager config)
{
@ -819,7 +826,7 @@ namespace osu.Game.Screens.Select
public void ChangeSpeed(double delta)
{
// Mod Change from 0.95 DC to 1.0 none to 1.05 DT/NC ?
onScreenDisplay?.Display(new SpeedChangeToast(config!, delta));
if (game == null) return;
ModNightcore modNc = (ModNightcore)((MultiMod)game.AvailableMods.Value[ModType.DifficultyIncrease].First(mod => mod is MultiMod multiMod && multiMod.Mods.Count(modType => modType is ModNightcore) > 0)).Mods.First(mod => mod is ModNightcore);
@ -1135,17 +1142,10 @@ namespace osu.Game.Screens.Select
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
if (!this.IsCurrentScreen()) return false;
switch (e.Action)
{
case GlobalAction.Select:
FinaliseSelection();
return true;
case GlobalAction.IncreaseSpeed:
ChangeSpeed(0.05);
return true;
@ -1155,6 +1155,16 @@ namespace osu.Game.Screens.Select
return true;
}
if (e.Repeat)
return false;
switch (e.Action)
{
case GlobalAction.Select:
FinaliseSelection();
return true;
}
return false;
}