mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 22:22:54 +08:00
Ensure CurrentTrack is never null
This commit is contained in:
parent
bf21fdd6da
commit
61b632516e
@ -95,12 +95,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (musicController.TrackLoaded)
|
if (musicController.TrackLoaded)
|
||||||
{
|
|
||||||
Debug.Assert(musicController.CurrentTrack != null);
|
|
||||||
marker.X = (float)(editorClock.CurrentTime / musicController.CurrentTrack.Length);
|
marker.X = (float)(editorClock.CurrentTime / musicController.CurrentTrack.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private class StartStopButton : OsuButton
|
private class StartStopButton : OsuButton
|
||||||
{
|
{
|
||||||
|
@ -136,8 +136,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddUntilStep("Wait for music controller", () => Game.MusicController.IsLoaded);
|
AddUntilStep("Wait for music controller", () => Game.MusicController.IsLoaded);
|
||||||
AddStep("Seek close to end", () =>
|
AddStep("Seek close to end", () =>
|
||||||
{
|
{
|
||||||
Game.MusicController.SeekTo(MusicController.CurrentTrack.AsNonNull().Length - 1000);
|
Game.MusicController.SeekTo(MusicController.CurrentTrack.Length - 1000);
|
||||||
MusicController.CurrentTrack.AsNonNull().Completed += () => trackCompleted = true;
|
MusicController.CurrentTrack.Completed += () => trackCompleted = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("Track was completed", () => trackCompleted);
|
AddUntilStep("Track was completed", () => trackCompleted);
|
||||||
|
@ -169,7 +169,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
if (timingPoints.Count == 0) return 0;
|
if (timingPoints.Count == 0) return 0;
|
||||||
|
|
||||||
if (timingPoints[^1] == current)
|
if (timingPoints[^1] == current)
|
||||||
return (int)Math.Ceiling((musicController.CurrentTrack.AsNonNull().Length - current.Time) / current.BeatLength);
|
return (int)Math.Ceiling((musicController.CurrentTrack.Length - current.Time) / current.BeatLength);
|
||||||
|
|
||||||
return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength);
|
return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -65,8 +64,7 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private OnScreenDisplay onScreenDisplay { get; set; }
|
private OnScreenDisplay onScreenDisplay { get; set; }
|
||||||
|
|
||||||
[CanBeNull]
|
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
||||||
public DrawableTrack CurrentTrack { get; private set; }
|
|
||||||
|
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>> managerRemoved;
|
private IBindable<WeakReference<BeatmapSetInfo>> managerRemoved;
|
||||||
@ -312,7 +310,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
current = beatmap.NewValue;
|
current = beatmap.NewValue;
|
||||||
|
|
||||||
if (!beatmap.OldValue.BeatmapInfo.AudioEquals(current?.BeatmapInfo))
|
if (CurrentTrack == null || !beatmap.OldValue.BeatmapInfo.AudioEquals(current?.BeatmapInfo))
|
||||||
changeTrack();
|
changeTrack();
|
||||||
|
|
||||||
TrackChanged?.Invoke(current, direction);
|
TrackChanged?.Invoke(current, direction);
|
||||||
|
@ -58,7 +58,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Assert(musicController.CurrentTrack != null);
|
|
||||||
content.RelativeChildSize = new Vector2((float)Math.Max(1, musicController.CurrentTrack.Length), 1);
|
content.RelativeChildSize = new Vector2((float)Math.Max(1, musicController.CurrentTrack.Length), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,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.AsNonNull().Length;
|
var until = i + 1 < beatmap.ControlPointInfo.TimingPoints.Count ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : musicController.CurrentTrack.Length;
|
||||||
|
|
||||||
int beat = 0;
|
int beat = 0;
|
||||||
|
|
||||||
|
@ -109,14 +109,14 @@ namespace osu.Game.Screens.Menu
|
|||||||
private void updateAmplitudes()
|
private void updateAmplitudes()
|
||||||
{
|
{
|
||||||
var effect = beatmap.Value.BeatmapLoaded && musicController.TrackLoaded
|
var effect = beatmap.Value.BeatmapLoaded && musicController.TrackLoaded
|
||||||
? beatmap.Value.Beatmap?.ControlPointInfo.EffectPointAt(musicController.CurrentTrack.AsNonNull().CurrentTime)
|
? beatmap.Value.Beatmap?.ControlPointInfo.EffectPointAt(musicController.CurrentTrack.CurrentTime)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
for (int i = 0; i < temporalAmplitudes.Length; i++)
|
for (int i = 0; i < temporalAmplitudes.Length; i++)
|
||||||
temporalAmplitudes[i] = 0;
|
temporalAmplitudes[i] = 0;
|
||||||
|
|
||||||
if (musicController.TrackLoaded)
|
if (musicController.TrackLoaded)
|
||||||
addAmplitudesFromSource(musicController.CurrentTrack.AsNonNull());
|
addAmplitudesFromSource(musicController.CurrentTrack);
|
||||||
|
|
||||||
foreach (var source in amplitudeSources)
|
foreach (var source in amplitudeSources)
|
||||||
addAmplitudesFromSource(source);
|
addAmplitudesFromSource(source);
|
||||||
|
@ -179,8 +179,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
if (last is IntroScreen && music.TrackLoaded)
|
if (last is IntroScreen && music.TrackLoaded)
|
||||||
{
|
{
|
||||||
Debug.Assert(music.CurrentTrack != null);
|
|
||||||
|
|
||||||
if (!music.CurrentTrack.IsRunning)
|
if (!music.CurrentTrack.IsRunning)
|
||||||
{
|
{
|
||||||
music.CurrentTrack.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * music.CurrentTrack.Length);
|
music.CurrentTrack.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * music.CurrentTrack.Length);
|
||||||
|
@ -170,10 +170,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
rulesetDependencies?.Dispose();
|
rulesetDependencies?.Dispose();
|
||||||
|
|
||||||
if (MusicController?.TrackLoaded == true)
|
if (MusicController?.TrackLoaded == true)
|
||||||
{
|
|
||||||
Debug.Assert(MusicController.CurrentTrack != null);
|
|
||||||
MusicController.CurrentTrack.Stop();
|
MusicController.CurrentTrack.Stop();
|
||||||
}
|
|
||||||
|
|
||||||
if (contextFactory.IsValueCreated)
|
if (contextFactory.IsValueCreated)
|
||||||
contextFactory.Value.ResetDatabase();
|
contextFactory.Value.ResetDatabase();
|
||||||
|
@ -16,10 +16,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
// note that this will override any mod rate application
|
// note that this will override any mod rate application
|
||||||
if (MusicController.TrackLoaded)
|
if (MusicController.TrackLoaded)
|
||||||
{
|
|
||||||
Debug.Assert(MusicController.CurrentTrack != null);
|
|
||||||
MusicController.CurrentTrack.Tempo.Value = Clock.Rate;
|
MusicController.CurrentTrack.Tempo.Value = Clock.Rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user