1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Update inspections

This commit is contained in:
smoogipoo 2020-08-07 20:51:56 +09:00
parent 61b632516e
commit 5002d69f69
26 changed files with 42 additions and 65 deletions

View File

@ -343,7 +343,7 @@ namespace osu.Game.Rulesets.Mania.Tests
judgementResults = new List<JudgementResult>();
});
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack?.CurrentTime == 0);
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack.CurrentTime == 0);
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
}

View File

@ -385,7 +385,7 @@ namespace osu.Game.Rulesets.Osu.Tests
judgementResults = new List<JudgementResult>();
});
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack?.CurrentTime == 0);
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack.CurrentTime == 0);
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
}

View File

@ -366,7 +366,7 @@ namespace osu.Game.Rulesets.Osu.Tests
judgementResults = new List<JudgementResult>();
});
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack?.CurrentTime == 0);
AddUntilStep("Beatmap at 0", () => MusicController.CurrentTrack.CurrentTime == 0);
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
}

View File

@ -31,6 +31,6 @@ namespace osu.Game.Tests.Skins
public void TestRetrieveOggSample() => AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo("sample")) != null);
[Test]
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () => MusicController.CurrentTrack?.IsDummyDevice == false);
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () => MusicController.CurrentTrack.IsDummyDevice == false);
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;

View File

@ -288,7 +288,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void confirmNoTrackAdjustments()
{
AddAssert("track has no adjustments", () => MusicController.CurrentTrack?.AggregateFrequency.Value == 1);
AddAssert("track has no adjustments", () => MusicController.CurrentTrack.AggregateFrequency.Value == 1);
}
private void restart() => AddStep("restart", () => Player.Restart());

View File

@ -77,12 +77,12 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("load dummy beatmap", () => ResetPlayer(false, () => SelectedMods.Value = new[] { new OsuModNightcore() }));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddAssert("mod rate applied", () => MusicController.CurrentTrack?.Rate != 1);
AddAssert("mod rate applied", () => MusicController.CurrentTrack.Rate != 1);
AddStep("exit loader", () => loader.Exit());
AddUntilStep("wait for not current", () => !loader.IsCurrentScreen());
AddAssert("player did not load", () => !player.IsLoaded);
AddUntilStep("player disposed", () => loader.DisposalTask?.IsCompleted == true);
AddAssert("mod rate still applied", () => MusicController.CurrentTrack?.Rate != 1);
AddAssert("mod rate still applied", () => MusicController.CurrentTrack.Rate != 1);
}
[Test]

View File

@ -87,9 +87,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private void restart()
{
MusicController.CurrentTrack?.Reset();
MusicController.CurrentTrack.Reset();
loadStoryboard(Beatmap.Value);
MusicController.CurrentTrack?.Start();
MusicController.CurrentTrack.Start();
}
private void loadStoryboard(WorkingBeatmap working)

View File

@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Menus
{
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
AddAssert("check if menu music loops", () => MusicController.CurrentTrack?.Looping == true);
AddAssert("check if menu music loops", () => MusicController.CurrentTrack.Looping);
}
}
}

View File

@ -4,7 +4,6 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
@ -62,12 +61,12 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("wait for fail", () => player.HasFailed);
AddUntilStep("wait for track stop", () => !MusicController.IsPlaying);
AddAssert("Ensure time before preview point", () => MusicController.CurrentTrack?.CurrentTime < beatmap().Metadata.PreviewTime);
AddAssert("Ensure time before preview point", () => MusicController.CurrentTrack.CurrentTime < beatmap().Metadata.PreviewTime);
pushEscape();
AddUntilStep("wait for track playing", () => MusicController.IsPlaying);
AddAssert("Ensure time wasn't reset to preview point", () => MusicController.CurrentTrack?.CurrentTime < beatmap().Metadata.PreviewTime);
AddAssert("Ensure time wasn't reset to preview point", () => MusicController.CurrentTrack.CurrentTime < beatmap().Metadata.PreviewTime);
}
[Test]
@ -77,11 +76,11 @@ namespace osu.Game.Tests.Visual.Navigation
PushAndConfirm(() => songSelect = new TestSongSelect());
AddUntilStep("wait for no track", () => MusicController.CurrentTrack?.IsDummyDevice == true);
AddUntilStep("wait for no track", () => MusicController.CurrentTrack.IsDummyDevice);
AddStep("return to menu", () => songSelect.Exit());
AddUntilStep("wait for track", () => MusicController.CurrentTrack?.IsDummyDevice == false && MusicController.IsPlaying);
AddUntilStep("wait for track", () => MusicController.CurrentTrack.IsDummyDevice == false && MusicController.IsPlaying);
}
[Test]

View File

@ -8,7 +8,6 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;

View File

@ -80,12 +80,12 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("Store track", () => currentBeatmap = Beatmap.Value);
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
AddUntilStep(@"Wait for current time to update", () => musicController.CurrentTrack?.CurrentTime > 5000);
AddUntilStep(@"Wait for current time to update", () => musicController.CurrentTrack.CurrentTime > 5000);
AddStep(@"Set previous", () => musicController.PreviousTrack());
AddAssert(@"Check beatmap didn't change", () => currentBeatmap == Beatmap.Value);
AddUntilStep("Wait for current time to update", () => musicController.CurrentTrack?.CurrentTime < 5000);
AddUntilStep("Wait for current time to update", () => musicController.CurrentTrack.CurrentTime < 5000);
AddStep(@"Set previous", () => musicController.PreviousTrack());
AddAssert(@"Check beatmap did change", () => currentBeatmap != Beatmap.Value);

View File

@ -48,7 +48,7 @@ namespace osu.Game.Audio
track.Started += () => Schedule(() =>
{
CurrentTrack?.Stop();
CurrentTrack.Stop();
CurrentTrack = track;
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
});

View File

@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Music
if (toSelect != null)
{
beatmap.Value = beatmaps.GetWorkingBeatmap(toSelect);
musicController.CurrentTrack?.Restart();
musicController.CurrentTrack.Restart();
}
};
}
@ -119,12 +119,12 @@ namespace osu.Game.Overlays.Music
{
if (set.ID == (beatmap.Value?.BeatmapSetInfo?.ID ?? -1))
{
musicController.CurrentTrack?.Seek(0);
musicController.CurrentTrack.Seek(0);
return;
}
beatmap.Value = beatmaps.GetWorkingBeatmap(set.Beatmaps.First());
musicController.CurrentTrack?.Restart();
musicController.CurrentTrack.Restart();
}
}

View File

@ -3,8 +3,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
@ -64,6 +64,7 @@ namespace osu.Game.Overlays
[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }
[NotNull]
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
@ -102,12 +103,12 @@ namespace osu.Game.Overlays
/// <summary>
/// Returns whether the beatmap track is playing.
/// </summary>
public bool IsPlaying => CurrentTrack?.IsRunning ?? false;
public bool IsPlaying => CurrentTrack.IsRunning;
/// <summary>
/// Returns whether the beatmap track is loaded.
/// </summary>
public bool TrackLoaded => CurrentTrack?.IsLoaded == true;
public bool TrackLoaded => CurrentTrack.IsLoaded;
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet)
{
@ -140,7 +141,7 @@ namespace osu.Game.Overlays
seekDelegate = Schedule(() =>
{
if (!beatmap.Disabled)
CurrentTrack?.Seek(position);
CurrentTrack.Seek(position);
});
}
@ -152,7 +153,7 @@ namespace osu.Game.Overlays
{
if (IsUserPaused) return;
if (CurrentTrack == null || CurrentTrack.IsDummyDevice)
if (CurrentTrack.IsDummyDevice)
{
if (beatmap.Disabled)
return;
@ -173,9 +174,6 @@ namespace osu.Game.Overlays
{
IsUserPaused = false;
if (CurrentTrack == null)
return false;
if (restart)
CurrentTrack.Restart();
else if (!IsPlaying)
@ -190,7 +188,7 @@ namespace osu.Game.Overlays
public void Stop()
{
IsUserPaused = true;
if (CurrentTrack?.IsRunning == true)
if (CurrentTrack.IsRunning)
CurrentTrack.Stop();
}
@ -200,7 +198,7 @@ namespace osu.Game.Overlays
/// <returns>Whether the operation was successful.</returns>
public bool TogglePause()
{
if (CurrentTrack?.IsRunning == true)
if (CurrentTrack.IsRunning)
Stop();
else
Play();
@ -222,7 +220,7 @@ namespace osu.Game.Overlays
if (beatmap.Disabled)
return PreviousTrackResult.None;
var currentTrackPosition = CurrentTrack?.CurrentTime;
var currentTrackPosition = CurrentTrack.CurrentTime;
if (currentTrackPosition >= restart_cutoff_point)
{
@ -276,7 +274,7 @@ namespace osu.Game.Overlays
{
// if not scheduled, the previously track will be stopped one frame later (see ScheduleAfterChildren logic in GameBase).
// we probably want to move this to a central method for switching to a new working beatmap in the future.
Schedule(() => CurrentTrack?.Restart());
Schedule(() => CurrentTrack.Restart());
}
private WorkingBeatmap current;
@ -310,7 +308,7 @@ namespace osu.Game.Overlays
current = beatmap.NewValue;
if (CurrentTrack == null || !beatmap.OldValue.BeatmapInfo.AudioEquals(current?.BeatmapInfo))
if (CurrentTrack.IsDummyDevice || !beatmap.OldValue.BeatmapInfo.AudioEquals(current?.BeatmapInfo))
changeTrack();
TrackChanged?.Invoke(current, direction);
@ -322,7 +320,7 @@ namespace osu.Game.Overlays
private void changeTrack()
{
CurrentTrack?.Expire();
CurrentTrack.Expire();
CurrentTrack = null;
if (current != null)
@ -340,8 +338,6 @@ namespace osu.Game.Overlays
if (current != workingBeatmap)
return;
Debug.Assert(CurrentTrack != null);
if (!CurrentTrack.Looping && !beatmap.Disabled)
NextTrack();
}
@ -366,9 +362,6 @@ namespace osu.Game.Overlays
public void ResetTrackAdjustments()
{
if (CurrentTrack == null)
return;
CurrentTrack.ResetSpeedAdjustments();
if (allowRateAdjustments)

View File

@ -66,12 +66,12 @@ namespace osu.Game.Screens.Edit.Components
}
};
musicController.CurrentTrack?.AddAdjustment(AdjustableProperty.Tempo, tempo);
musicController.CurrentTrack.AddAdjustment(AdjustableProperty.Tempo, tempo);
}
protected override void Dispose(bool isDisposing)
{
musicController?.CurrentTrack?.RemoveAdjustment(AdjustableProperty.Tempo, tempo);
musicController?.CurrentTrack.RemoveAdjustment(AdjustableProperty.Tempo, tempo);
base.Dispose(isDisposing);
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osuTK;

View File

@ -3,7 +3,6 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Overlays;

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Edit
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
var sourceClock = (IAdjustableClock)musicController.CurrentTrack ?? new StopwatchClock();
clock = new EditorClock(Beatmap.Value, musicController.CurrentTrack?.Length ?? 0, beatDivisor) { IsCoupled = false };
clock = new EditorClock(Beatmap.Value, musicController.CurrentTrack.Length, beatDivisor) { IsCoupled = false };
clock.ChangeSource(sourceClock);
dependencies.CacheAs(clock);

View File

@ -19,7 +19,6 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Utils;
using osu.Game.Overlays;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using System.Linq;
using osuTK;
using osuTK.Graphics;

View File

@ -330,7 +330,7 @@ namespace osu.Game.Screens.Menu
const float velocity_adjust_cutoff = 0.98f;
const float paused_velocity = 0.5f;
if (musicController.CurrentTrack?.IsRunning == true)
if (musicController.CurrentTrack.IsRunning)
{
var maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0;
logoAmplitudeContainer.Scale = new Vector2((float)Interpolation.Damp(logoAmplitudeContainer.Scale.X, 1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 0.9f, Time.Elapsed));

View File

@ -104,7 +104,7 @@ namespace osu.Game.Screens.Multi.Match.Components
return;
}
bool hasEnoughTime = musicController.CurrentTrack != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(musicController.CurrentTrack.Length) < endDate.Value;
bool hasEnoughTime = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(musicController.CurrentTrack.Length) < endDate.Value;
Enabled.Value = hasBeatmap && hasEnoughTime;
}

View File

@ -342,15 +342,12 @@ namespace osu.Game.Screens.Multi
private void updateTrack(ValueChangedEvent<WorkingBeatmap> _ = null)
{
if (screenStack.CurrentScreen is MatchSubScreen)
{
if (musicController.CurrentTrack != null)
{
musicController.CurrentTrack.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
musicController.CurrentTrack.Looping = true;
musicController.EnsurePlayingSomething();
}
}
else
{
cancelLooping();
@ -358,13 +355,10 @@ namespace osu.Game.Screens.Multi
}
private void cancelLooping()
{
if (musicController.CurrentTrack != null)
{
musicController.CurrentTrack.Looping = false;
musicController.CurrentTrack.RestartPoint = 0;
}
}
protected override void Dispose(bool isDisposing)
{

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
namespace osu.Game.Tests.Visual
{
/// <summary>