Skip to content

Commit

Permalink
Change Speedchange behaviour to keep changing while holding key, Add …
Browse files Browse the repository at this point in the history
…Toast to nofity user what just happend
  • Loading branch information
Fabian van Oeffelt committed May 21, 2024
1 parent 3fdbd73 commit 148afd1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
5 changes: 5 additions & 0 deletions osu.Game/Localisation/ToastStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public static class ToastStrings
/// </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}";
}
}
17 changes: 17 additions & 0 deletions osu.Game/Overlays/OSD/SpeedChangeToast.cs
Original file line number Diff line number Diff line change
@@ -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))
{
}
}
}
26 changes: 18 additions & 8 deletions osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;
Expand Down Expand Up @@ -151,6 +152,12 @@ public abstract partial class SongSelect : ScreenWithBeatmapBackground, IKeyBind

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)
{
Expand Down Expand Up @@ -819,7 +826,7 @@ public override bool OnBackButton()
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);
Expand Down Expand Up @@ -1135,17 +1142,10 @@ public void ClearScores(BeatmapInfo? beatmapInfo)

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;
Expand All @@ -1155,6 +1155,16 @@ public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
return true;
}

if (e.Repeat)
return false;

switch (e.Action)
{
case GlobalAction.Select:
FinaliseSelection();
return true;
}

return false;
}

Expand Down

0 comments on commit 148afd1

Please sign in to comment.