mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Reimplement select mod track adjustments
This commit is contained in:
parent
c584967eb1
commit
ad124bfeec
@ -46,14 +46,7 @@ namespace osu.Game.Beatmaps
|
|||||||
return b;
|
return b;
|
||||||
});
|
});
|
||||||
|
|
||||||
track = new RecyclableLazy<Track>(() =>
|
track = new RecyclableLazy<Track>(() => GetTrack() ?? new VirtualBeatmapTrack(Beatmap));
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
});
|
|
||||||
|
|
||||||
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
|
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
|
||||||
waveform = new RecyclableLazy<Waveform>(GetWaveform);
|
waveform = new RecyclableLazy<Waveform>(GetWaveform);
|
||||||
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
|
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
|
||||||
@ -183,16 +176,6 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void RecycleTrack() => track.Recycle();
|
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>
|
public class RecyclableLazy<T>
|
||||||
{
|
{
|
||||||
private Lazy<T> lazy;
|
private Lazy<T> lazy;
|
||||||
|
@ -113,7 +113,7 @@ namespace osu.Game
|
|||||||
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
||||||
[Cached]
|
[Cached]
|
||||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
[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)
|
public OsuGame(string[] args = null)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Music;
|
using osu.Game.Overlays.Music;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -54,7 +55,11 @@ namespace osu.Game.Overlays
|
|||||||
private Container dragContainer;
|
private Container dragContainer;
|
||||||
private Container playerContainer;
|
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>
|
/// <summary>
|
||||||
/// Provide a source for the toolbar height.
|
/// Provide a source for the toolbar height.
|
||||||
@ -73,7 +78,6 @@ namespace osu.Game.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(Bindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps, OsuColour colours)
|
private void load(Bindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps, OsuColour colours)
|
||||||
{
|
{
|
||||||
this.beatmap.BindTo(beatmap);
|
|
||||||
this.beatmaps = beatmaps;
|
this.beatmaps = beatmaps;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -231,6 +235,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
beatmap.BindValueChanged(beatmapChanged, true);
|
beatmap.BindValueChanged(beatmapChanged, true);
|
||||||
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
||||||
|
selectedMods.BindValueChanged(_ => updateAudioAdjustments(), true);
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,10 +359,23 @@ namespace osu.Game.Overlays
|
|||||||
progressBar.CurrentTime = 0;
|
progressBar.CurrentTime = 0;
|
||||||
|
|
||||||
updateDisplay(current, direction);
|
updateDisplay(current, direction);
|
||||||
|
updateAudioAdjustments();
|
||||||
|
|
||||||
queuedDirection = null;
|
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(() =>
|
private void currentTrackCompleted() => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (!current.Track.Looping && !beatmap.Disabled && beatmapSets.Any())
|
if (!current.Track.Looping && !beatmap.Disabled && beatmapSets.Any())
|
||||||
|
@ -61,11 +61,11 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
public virtual float BackgroundParallaxAmount => 1;
|
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)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
|
@ -83,9 +83,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
[Cached]
|
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
|
||||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
|
||||||
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
|
||||||
|
|
||||||
protected SongSelect()
|
protected SongSelect()
|
||||||
{
|
{
|
||||||
@ -217,11 +215,8 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[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)
|
if (Footer != null)
|
||||||
{
|
{
|
||||||
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
|
Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1);
|
||||||
@ -269,6 +264,12 @@ namespace osu.Game.Screens.Select
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(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(this);
|
||||||
dependencies.CacheAs(decoupledRuleset);
|
dependencies.CacheAs(decoupledRuleset);
|
||||||
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
|
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
|
||||||
|
Loading…
Reference in New Issue
Block a user