mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Add basic track reloading support while inside the editor
This commit is contained in:
@ -43,6 +43,7 @@ using osuTK.Input;
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
[Cached(typeof(IBeatSnapProvider))]
|
||||
[Cached]
|
||||
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
||||
{
|
||||
public override float BackgroundParallaxAmount => 0.1f;
|
||||
@ -91,6 +92,9 @@ namespace osu.Game.Screens.Edit
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private MusicController music { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, GameHost host)
|
||||
{
|
||||
@ -98,9 +102,9 @@ namespace osu.Game.Screens.Edit
|
||||
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||
|
||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||
var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
|
||||
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
|
||||
clock.ChangeSource(sourceClock);
|
||||
|
||||
UpdateClockSource();
|
||||
|
||||
dependencies.CacheAs(clock);
|
||||
AddInternal(clock);
|
||||
@ -271,6 +275,15 @@ namespace osu.Game.Screens.Edit
|
||||
bottomBackground.Colour = colours.Gray2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the beatmap's track has changed, this method must be called to keep the editor in a valid state.
|
||||
/// </summary>
|
||||
public void UpdateClockSource()
|
||||
{
|
||||
var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
|
||||
clock.ChangeSource(sourceClock);
|
||||
}
|
||||
|
||||
protected void Save()
|
||||
{
|
||||
// apply any set-level metadata changes.
|
||||
|
Reference in New Issue
Block a user