1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Allow screen to specify whether to apply audio rate adjustments from mods

This commit is contained in:
Dean Herbert 2019-11-15 13:47:14 +09:00
parent b8bb97607b
commit 6d06b444ba
6 changed files with 37 additions and 3 deletions

View File

@ -925,6 +925,8 @@ namespace osu.Game
{
OverlayActivationMode.Value = newOsuScreen.InitialOverlayActivationMode;
musicController.AllowRateAdjustments = newOsuScreen.AllowRateAdjustments;
if (newOsuScreen.HideOverlaysOnEnter)
CloseAllOverlays();
else

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays
private OnScreenDisplay onScreenDisplay { get; set; }
[BackgroundDependencyLoader]
private void load()
private void load(OsuGame game)
{
beatmapSets.AddRange(beatmaps.GetAllUsableBeatmapSets().OrderBy(_ => RNG.Next()));
beatmaps.ItemAdded += handleBeatmapAdded;
@ -233,6 +233,24 @@ namespace osu.Game.Overlays
queuedDirection = null;
}
private bool allowRateAdjustments;
/// <summary>
/// Whether mod rate adjustments are allowed to be applied.
/// </summary>
public bool AllowRateAdjustments
{
get => allowRateAdjustments;
set
{
if (allowRateAdjustments == value)
return;
allowRateAdjustments = value;
ResetTrackAdjustments();
}
}
public void ResetTrackAdjustments()
{
var track = current?.Track;
@ -241,8 +259,11 @@ namespace osu.Game.Overlays
track.ResetSpeedAdjustments();
foreach (var mod in mods.Value.OfType<IApplicableToClock>())
mod.ApplyToClock(track);
if (allowRateAdjustments)
{
foreach (var mod in mods.Value.OfType<IApplicableToClock>())
mod.ApplyToClock(track);
}
}
protected override void Dispose(bool isDisposing)

View File

@ -51,5 +51,10 @@ namespace osu.Game.Screens
Bindable<WorkingBeatmap> Beatmap { get; }
Bindable<RulesetInfo> Ruleset { get; }
/// <summary>
/// Whether mod rate adjustments are allowed to be applied.
/// </summary>
bool AllowRateAdjustments { get; }
}
}

View File

@ -37,6 +37,8 @@ namespace osu.Game.Screens.Menu
public override bool AllowExternalScreenChange => true;
public override bool AllowRateAdjustments => false;
private Screen songSelect;
private MenuSideFlashes sideFlashes;

View File

@ -91,6 +91,8 @@ namespace osu.Game.Screens
public Bindable<RulesetInfo> Ruleset { get; private set; }
public virtual bool AllowRateAdjustments => true;
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)

View File

@ -16,6 +16,8 @@ namespace osu.Game.Screens
public override bool CursorVisible => false;
public override bool AllowRateAdjustments => false;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
}
}