mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Expose track from MusicController
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
@ -94,7 +95,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
base.Update();
|
||||
|
||||
if (musicController.TrackLoaded)
|
||||
marker.X = (float)(editorClock.CurrentTime / musicController.TrackLength);
|
||||
{
|
||||
Debug.Assert(musicController.CurrentTrack != null);
|
||||
marker.X = (float)(editorClock.CurrentTime / musicController.CurrentTrack.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void confirmNoTrackAdjustments()
|
||||
{
|
||||
AddAssert("track has no adjustments", () => MusicController.AggregateFrequency.Value == 1);
|
||||
AddAssert("track has no adjustments", () => MusicController.CurrentTrack?.AggregateFrequency.Value == 1);
|
||||
}
|
||||
|
||||
private void restart() => AddStep("restart", () => Player.Restart());
|
||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(MusicController);
|
||||
mod.ApplyToTrack(MusicController.CurrentTrack);
|
||||
|
||||
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||
loader = new TestPlayerLoader(() =>
|
||||
@ -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.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.Rate != 1);
|
||||
AddAssert("mod rate still applied", () => MusicController.CurrentTrack?.Rate != 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -87,9 +87,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void restart()
|
||||
{
|
||||
MusicController.Reset();
|
||||
MusicController.CurrentTrack?.Reset();
|
||||
loadStoryboard(Beatmap.Value);
|
||||
MusicController.Play(true);
|
||||
MusicController.CurrentTrack?.Start();
|
||||
}
|
||||
|
||||
private void loadStoryboard(WorkingBeatmap working)
|
||||
@ -104,7 +104,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
storyboard.Passing = false;
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(musicController.GetTrackClock());
|
||||
decoupledClock.ChangeSource(musicController.CurrentTrack);
|
||||
}
|
||||
|
||||
private void loadStoryboardNoVideo()
|
||||
@ -127,7 +127,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
storyboard = sb.CreateDrawable(Beatmap.Value);
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(musicController.GetTrackClock());
|
||||
decoupledClock.ChangeSource(musicController.CurrentTrack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
|
||||
|
||||
AddAssert("check if menu music loops", () => MusicController.Looping);
|
||||
AddAssert("check if menu music loops", () => MusicController.CurrentTrack?.Looping == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
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;
|
||||
@ -61,12 +62,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.CurrentTrackTime < 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.CurrentTrackTime < beatmap().Metadata.PreviewTime);
|
||||
AddAssert("Ensure time wasn't reset to preview point", () => MusicController.CurrentTrack?.CurrentTime < beatmap().Metadata.PreviewTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -76,11 +77,11 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
PushAndConfirm(() => songSelect = new TestSongSelect());
|
||||
|
||||
AddUntilStep("wait for no track", () => MusicController.IsDummyDevice);
|
||||
AddUntilStep("wait for no track", () => MusicController.CurrentTrack?.IsDummyDevice == true);
|
||||
|
||||
AddStep("return to menu", () => songSelect.Exit());
|
||||
|
||||
AddUntilStep("wait for track", () => !MusicController.IsDummyDevice && MusicController.IsPlaying);
|
||||
AddUntilStep("wait for track", () => MusicController.CurrentTrack?.IsDummyDevice == false && MusicController.IsPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -135,8 +136,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("Wait for music controller", () => Game.MusicController.IsLoaded);
|
||||
AddStep("Seek close to end", () =>
|
||||
{
|
||||
Game.MusicController.SeekTo(MusicController.TrackLength - 1000);
|
||||
// MusicController.Completed += () => trackCompleted = true;
|
||||
Game.MusicController.SeekTo(MusicController.CurrentTrack.AsNonNull().Length - 1000);
|
||||
MusicController.CurrentTrack.AsNonNull().Completed += () => trackCompleted = true;
|
||||
});
|
||||
|
||||
AddUntilStep("Track was completed", () => trackCompleted);
|
||||
|
@ -8,6 +8,7 @@ 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;
|
||||
@ -168,7 +169,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
if (timingPoints.Count == 0) return 0;
|
||||
|
||||
if (timingPoints[^1] == current)
|
||||
return (int)Math.Ceiling((musicController.TrackLength - current.Time) / current.BeatLength);
|
||||
return (int)Math.Ceiling((musicController.CurrentTrack.AsNonNull().Length - current.Time) / current.BeatLength);
|
||||
|
||||
return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength);
|
||||
}
|
||||
|
@ -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.CurrentTrackTime > 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.CurrentTrackTime < 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);
|
||||
|
Reference in New Issue
Block a user