mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 12:32:56 +08:00
Add basic track reloading support while inside the editor
This commit is contained in:
parent
65e6dd2ac3
commit
978f6edf38
@ -81,6 +81,11 @@ namespace osu.Game.Overlays
|
|||||||
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
|
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Forcefully reload the current <see cref="WorkingBeatmap"/>'s track from disk.
|
||||||
|
/// </summary>
|
||||||
|
public void ForceReloadCurrentBeatmap() => changeTrack();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the position of a <see cref="BeatmapSetInfo"/> in the current playlist.
|
/// Change the position of a <see cref="BeatmapSetInfo"/> in the current playlist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,6 +43,7 @@ using osuTK.Input;
|
|||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
[Cached(typeof(IBeatSnapProvider))]
|
[Cached(typeof(IBeatSnapProvider))]
|
||||||
|
[Cached]
|
||||||
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
||||||
{
|
{
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
@ -91,6 +92,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, GameHost host)
|
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);
|
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||||
|
|
||||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
// 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 = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
|
||||||
clock.ChangeSource(sourceClock);
|
|
||||||
|
UpdateClockSource();
|
||||||
|
|
||||||
dependencies.CacheAs(clock);
|
dependencies.CacheAs(clock);
|
||||||
AddInternal(clock);
|
AddInternal(clock);
|
||||||
@ -271,6 +275,15 @@ namespace osu.Game.Screens.Edit
|
|||||||
bottomBackground.Colour = colours.Gray2;
|
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()
|
protected void Save()
|
||||||
{
|
{
|
||||||
// apply any set-level metadata changes.
|
// apply any set-level metadata changes.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Transforms;
|
using osu.Framework.Graphics.Transforms;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -17,7 +18,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||||
{
|
{
|
||||||
public readonly double TrackLength;
|
public double TrackLength;
|
||||||
|
|
||||||
public ControlPointInfo ControlPointInfo;
|
public ControlPointInfo ControlPointInfo;
|
||||||
|
|
||||||
@ -190,7 +191,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
|
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
|
||||||
|
|
||||||
public void ChangeSource(IClock source) => underlyingClock.ChangeSource(source);
|
public void ChangeSource(IClock source)
|
||||||
|
{
|
||||||
|
underlyingClock.ChangeSource(source);
|
||||||
|
TrackLength = (source as Track)?.Length ?? 60000;
|
||||||
|
}
|
||||||
|
|
||||||
public IClock Source => underlyingClock.Source;
|
public IClock Source => underlyingClock.Source;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using FileInfo = System.IO.FileInfo;
|
using FileInfo = System.IO.FileInfo;
|
||||||
|
|
||||||
@ -139,6 +140,12 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private FileStore files { get; set; }
|
private FileStore files { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Editor editor { get; set; }
|
||||||
|
|
||||||
private void audioTrackChanged(ValueChangedEvent<string> filePath)
|
private void audioTrackChanged(ValueChangedEvent<string> filePath)
|
||||||
{
|
{
|
||||||
var info = new FileInfo(filePath.NewValue);
|
var info = new FileInfo(filePath.NewValue);
|
||||||
@ -173,6 +180,10 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
});
|
});
|
||||||
|
|
||||||
Beatmap.Value.Metadata.AudioFile = info.Name;
|
Beatmap.Value.Metadata.AudioFile = info.Name;
|
||||||
|
|
||||||
|
music.ForceReloadCurrentBeatmap();
|
||||||
|
|
||||||
|
editor.UpdateClockSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCommit(TextBox sender, bool newText)
|
private void onCommit(TextBox sender, bool newText)
|
||||||
|
Loading…
Reference in New Issue
Block a user