Reimplement select mod track adjustments

This commit is contained in:
smoogipoo
2019-04-08 19:16:34 +09:00
parent c584967eb1
commit ad124bfeec
5 changed files with 33 additions and 31 deletions

View File

@ -22,6 +22,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Music;
using osu.Game.Rulesets.Mods;
using osuTK;
using osuTK.Graphics;
@ -54,7 +55,11 @@ namespace osu.Game.Overlays
private Container dragContainer;
private Container playerContainer;
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
[Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private IBindable<IEnumerable<Mod>> selectedMods { get; set; }
/// <summary>
/// Provide a source for the toolbar height.
@ -73,7 +78,6 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader]
private void load(Bindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps, OsuColour colours)
{
this.beatmap.BindTo(beatmap);
this.beatmaps = beatmaps;
Children = new Drawable[]
@ -231,6 +235,7 @@ namespace osu.Game.Overlays
{
beatmap.BindValueChanged(beatmapChanged, true);
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
selectedMods.BindValueChanged(_ => updateAudioAdjustments(), true);
base.LoadComplete();
}
@ -354,10 +359,23 @@ namespace osu.Game.Overlays
progressBar.CurrentTime = 0;
updateDisplay(current, direction);
updateAudioAdjustments();
queuedDirection = null;
}
private void updateAudioAdjustments()
{
var track = current?.Track;
if (track == null)
return;
track.ResetSpeedAdjustments();
foreach (var mod in selectedMods.Value.OfType<IApplicableToClock>())
mod.ApplyToClock(track);
}
private void currentTrackCompleted() => Schedule(() =>
{
if (!current.Track.Looping && !beatmap.Disabled && beatmapSets.Any())