mirror of
https://github.com/osukey/osukey.git
synced 2025-05-16 11:07:35 +09:00
Fix editor potentially using a track post-disposal
This changes the editor to track the current track as it is *loaded* by `MusicController`, rather than haphazardly following the current global `WorkingBeatmap` (with a potentially unloaded track) or relying on local immediate-load behaviour (as implemented in `ResourcesSection`).
This commit is contained in:
parent
2519706ad6
commit
2f60f91a0e
@ -70,7 +70,11 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Forcefully reload the current <see cref="WorkingBeatmap"/>'s track from disk.
|
/// Forcefully reload the current <see cref="WorkingBeatmap"/>'s track from disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReloadCurrentTrack() => changeTrack();
|
public void ReloadCurrentTrack()
|
||||||
|
{
|
||||||
|
changeTrack();
|
||||||
|
TrackChanged?.Invoke(current, TrackChangeDirection.None);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns whether the beatmap track is playing.
|
/// Returns whether the beatmap track is playing.
|
||||||
|
@ -329,6 +329,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MusicController musicController { get; set; }
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -336,12 +339,18 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
Mode.Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose;
|
Mode.Value = isNewBeatmap ? EditorScreenMode.SongSetup : EditorScreenMode.Compose;
|
||||||
Mode.BindValueChanged(onModeChanged, true);
|
Mode.BindValueChanged(onModeChanged, true);
|
||||||
|
|
||||||
|
musicController.TrackChanged += onTrackChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected override void Dispose(bool isDisposing)
|
||||||
/// If the beatmap's track has changed, this method must be called to keep the editor in a valid state.
|
{
|
||||||
/// </summary>
|
base.Dispose(isDisposing);
|
||||||
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
|
||||||
|
musicController.TrackChanged -= onTrackChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onTrackChanged(WorkingBeatmap working, TrackChangeDirection direction) => clock.ChangeSource(working.Track);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an <see cref="EditorState"/> instance representing the current state of the editor.
|
/// Creates an <see cref="EditorState"/> instance representing the current state of the editor.
|
||||||
|
@ -118,8 +118,6 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
working.Value.Metadata.AudioFile = destination.Name;
|
working.Value.Metadata.AudioFile = destination.Name;
|
||||||
|
|
||||||
music.ReloadCurrentTrack();
|
music.ReloadCurrentTrack();
|
||||||
|
|
||||||
editor?.UpdateClockSource();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user