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

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

@ -46,14 +46,7 @@ namespace osu.Game.Beatmaps
return b;
});
track = new RecyclableLazy<Track>(() =>
{
// we want to ensure that we always have a track, even if it's a fake one.
var t = GetTrack() ?? new VirtualBeatmapTrack(Beatmap);
// applyRateAdjustments(t);
return t;
});
track = new RecyclableLazy<Track>(() => GetTrack() ?? new VirtualBeatmapTrack(Beatmap));
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
waveform = new RecyclableLazy<Waveform>(GetWaveform);
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
@ -183,16 +176,6 @@ namespace osu.Game.Beatmaps
/// </summary>
public void RecycleTrack() => track.Recycle();
// private void applyRateAdjustments(Track t = null)
// {
// if (t == null && track.IsResultAvailable) t = Track;
// if (t == null) return;
//
// t.ResetSpeedAdjustments();
// foreach (var mod in Mods.Value.OfType<IApplicableToClock>())
// mod.ApplyToClock(t);
// }
public class RecyclableLazy<T>
{
private Lazy<T> lazy;

View File

@ -113,7 +113,7 @@ namespace osu.Game
// todo: move this to SongSelect once Screen has the ability to unsuspend.
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
public OsuGame(string[] args = null)
{

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())

View File

@ -61,11 +61,11 @@ namespace osu.Game.Screens
public virtual float BackgroundParallaxAmount => 1;
public Bindable<WorkingBeatmap> Beatmap { get; set; }
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
public Bindable<RulesetInfo> Ruleset { get; set; }
public Bindable<RulesetInfo> Ruleset { get; private set; }
public Bindable<IEnumerable<Mod>> SelectedMods { get; set; }
public Bindable<IEnumerable<Mod>> SelectedMods { get; private set; }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{

View File

@ -83,9 +83,7 @@ namespace osu.Game.Screens.Select
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
protected SongSelect()
{
@ -217,11 +215,8 @@ namespace osu.Game.Screens.Select
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, Bindable<IEnumerable<Mod>> selectedMods)
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins)
{
if (selectedMods != null)
SelectedMods.BindTo(selectedMods);
if (Footer != null)
{
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
@ -269,6 +264,12 @@ namespace osu.Game.Screens.Select
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
SelectedMods.BindTo(base.SelectedMods);
dependencies.CacheAs(SelectedMods);
dependencies.CacheAs<IBindable<IEnumerable<Mod>>>(SelectedMods);
dependencies.CacheAs(this);
dependencies.CacheAs(decoupledRuleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);