mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Listen for track reload in timeline
This commit is contained in:
parent
66a02374da
commit
7089bb6c23
@ -15,6 +15,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
@ -35,14 +36,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
public readonly Bindable<bool> TicksVisible = new Bindable<bool>();
|
||||
|
||||
public readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
[Resolved]
|
||||
private EditorClock editorClock { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private EditorBeatmap editorBeatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timeline's scroll position in the last frame.
|
||||
/// </summary>
|
||||
@ -139,11 +141,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity);
|
||||
|
||||
Beatmap.BindTo(beatmap);
|
||||
Beatmap.BindValueChanged(b =>
|
||||
{
|
||||
waveform.Waveform = b.NewValue.Waveform;
|
||||
}, true);
|
||||
musicController.TrackChanged += onTrackReload;
|
||||
waveform.Waveform = beatmap.Value.Waveform;
|
||||
|
||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
}
|
||||
@ -181,6 +180,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private void updateWaveformOpacity() =>
|
||||
waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint);
|
||||
|
||||
private void onTrackReload(WorkingBeatmap beatmap, TrackChangeDirection tcd)
|
||||
{
|
||||
waveform.Waveform = beatmap.Waveform;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -321,5 +325,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
double time = TimeAtPosition(Content.ToLocalSpace(screenSpacePosition).X);
|
||||
return new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(time));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
musicController.TrackChanged -= onTrackReload;
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user