mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Restore remaining editor components to use Beatmap.Track
This commit is contained in:
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
@ -64,10 +65,10 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private readonly Drawable marker;
|
private readonly Drawable marker;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorClock editorClock { get; set; }
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController musicController { get; set; }
|
private EditorClock editorClock { get; set; }
|
||||||
|
|
||||||
public AudioVisualiser()
|
public AudioVisualiser()
|
||||||
{
|
{
|
||||||
@ -93,8 +94,8 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (musicController.TrackLoaded)
|
if (beatmap.Value.Track.IsLoaded)
|
||||||
marker.X = (float)(editorClock.CurrentTime / musicController.CurrentTrack.Length);
|
marker.X = (float)(editorClock.CurrentTime / beatmap.Value.Track.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -17,6 +18,7 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
private const float contents_padding = 15;
|
private const float contents_padding = 15;
|
||||||
|
|
||||||
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
protected Track Track => Beatmap.Value.Track;
|
||||||
|
|
||||||
private readonly Drawable background;
|
private readonly Drawable background;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
@ -16,7 +16,6 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components
|
namespace osu.Game.Screens.Edit.Components
|
||||||
@ -28,9 +27,6 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorClock editorClock { get; set; }
|
private EditorClock editorClock { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private MusicController musicController { get; set; }
|
|
||||||
|
|
||||||
private readonly BindableNumber<double> tempo = new BindableDouble(1);
|
private readonly BindableNumber<double> tempo = new BindableDouble(1);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -66,12 +62,12 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
musicController.CurrentTrack.AddAdjustment(AdjustableProperty.Tempo, tempo);
|
Track?.AddAdjustment(AdjustableProperty.Tempo, tempo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
musicController?.CurrentTrack.RemoveAdjustment(AdjustableProperty.Tempo, tempo);
|
Track?.RemoveAdjustment(AdjustableProperty.Tempo, tempo);
|
||||||
|
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using osuTK;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Overlays;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||||
{
|
{
|
||||||
@ -27,9 +26,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|||||||
|
|
||||||
protected override Container<T> Content => content;
|
protected override Container<T> Content => content;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private MusicController musicController { get; set; }
|
|
||||||
|
|
||||||
public TimelinePart(Container<T> content = null)
|
public TimelinePart(Container<T> content = null)
|
||||||
{
|
{
|
||||||
AddInternal(this.content = content ?? new Container<T> { RelativeSizeAxes = Axes.Both });
|
AddInternal(this.content = content ?? new Container<T> { RelativeSizeAxes = Axes.Both });
|
||||||
@ -50,14 +46,14 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|||||||
private void updateRelativeChildSize()
|
private void updateRelativeChildSize()
|
||||||
{
|
{
|
||||||
// the track may not be loaded completely (only has a length once it is).
|
// the track may not be loaded completely (only has a length once it is).
|
||||||
if (!musicController.TrackLoaded)
|
if (!Beatmap.Value.Track.IsLoaded)
|
||||||
{
|
{
|
||||||
content.RelativeChildSize = Vector2.One;
|
content.RelativeChildSize = Vector2.One;
|
||||||
Schedule(updateRelativeChildSize);
|
Schedule(updateRelativeChildSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
content.RelativeChildSize = new Vector2((float)Math.Max(1, musicController.CurrentTrack.Length), 1);
|
content.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
|
protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
|
||||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool trackWasPlaying;
|
private bool trackWasPlaying;
|
||||||
|
|
||||||
private ITrack track;
|
private Track track;
|
||||||
|
|
||||||
public Timeline()
|
public Timeline()
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
private void seekTrackToCurrent()
|
private void seekTrackToCurrent()
|
||||||
{
|
{
|
||||||
if (!musicController.TrackLoaded)
|
if (!track.IsLoaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
editorClock.Seek(Current / Content.DrawWidth * track.Length);
|
editorClock.Seek(Current / Content.DrawWidth * track.Length);
|
||||||
@ -142,7 +142,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
private void scrollToTrackTime()
|
private void scrollToTrackTime()
|
||||||
{
|
{
|
||||||
if (!musicController.TrackLoaded || track.Length == 0)
|
if (!track.IsLoaded || track.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScrollTo((float)(editorClock.CurrentTime / track.Length) * Content.DrawWidth, false);
|
ScrollTo((float)(editorClock.CurrentTime / track.Length) * Content.DrawWidth, false);
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
private EditorBeatmap beatmap { get; set; }
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController musicController { get; set; }
|
private Bindable<WorkingBeatmap> working { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BindableBeatDivisor beatDivisor { get; set; }
|
private BindableBeatDivisor beatDivisor { get; set; }
|
||||||
@ -43,7 +44,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
||||||
{
|
{
|
||||||
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
||||||
var until = i + 1 < beatmap.ControlPointInfo.TimingPoints.Count ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : musicController.CurrentTrack.Length;
|
var until = i + 1 < beatmap.ControlPointInfo.TimingPoints.Count ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : working.Value.Track.Length;
|
||||||
|
|
||||||
int beat = 0;
|
int beat = 0;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Screens.Edit.Components;
|
using osu.Game.Screens.Edit.Components;
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
using osu.Game.Screens.Edit.Components.Menus;
|
||||||
@ -27,7 +28,6 @@ using osu.Framework.Logging;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
using osu.Game.Screens.Edit.Setup;
|
using osu.Game.Screens.Edit.Setup;
|
||||||
@ -53,9 +53,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private MusicController musicController { get; set; }
|
|
||||||
|
|
||||||
private Box bottomBackground;
|
private Box bottomBackground;
|
||||||
private Container screenContainer;
|
private Container screenContainer;
|
||||||
|
|
||||||
@ -82,8 +79,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(musicController.CurrentTrack);
|
clock.ChangeSource(sourceClock);
|
||||||
|
|
||||||
dependencies.CacheAs(clock);
|
dependencies.CacheAs(clock);
|
||||||
AddInternal(clock);
|
AddInternal(clock);
|
||||||
@ -348,7 +346,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private void resetTrack(bool seekToStart = false)
|
private void resetTrack(bool seekToStart = false)
|
||||||
{
|
{
|
||||||
musicController.CurrentTrack.Stop();
|
Beatmap.Value.Track?.Stop();
|
||||||
|
|
||||||
if (seekToStart)
|
if (seekToStart)
|
||||||
{
|
{
|
||||||
|
@ -30,11 +30,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditorClock()
|
|
||||||
: this(new ControlPointInfo(), 1000, new BindableBeatDivisor())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor)
|
public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor)
|
||||||
{
|
{
|
||||||
this.beatDivisor = beatDivisor;
|
this.beatDivisor = beatDivisor;
|
||||||
@ -45,6 +40,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
underlyingClock = new DecoupleableInterpolatingFramedClock();
|
underlyingClock = new DecoupleableInterpolatingFramedClock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditorClock()
|
||||||
|
: this(new ControlPointInfo(), 1000, new BindableBeatDivisor())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Seek to the closest snappable beat from a time.
|
/// Seek to the closest snappable beat from a time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -43,7 +44,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
||||||
{
|
{
|
||||||
Clock.ControlPointInfo = e.NewValue.Beatmap.ControlPointInfo;
|
Clock.ControlPointInfo = e.NewValue.Beatmap.ControlPointInfo;
|
||||||
Clock.ChangeSource(MusicController.CurrentTrack);
|
Clock.ChangeSource((IAdjustableClock)e.NewValue.Track ?? new StopwatchClock());
|
||||||
Clock.ProcessFrame();
|
Clock.ProcessFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user