From 5024770544999feda8849f7463102b1db5fe2283 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Mon, 23 Sep 2019 20:52:44 +0800 Subject: [PATCH 01/43] move common logic to IntroScreen --- osu.Game/Screens/Menu/IntroCircles.cs | 74 ++++++----------------- osu.Game/Screens/Menu/IntroScreen.cs | 80 +++++++++++++++++++++++-- osu.Game/Screens/Menu/IntroTriangles.cs | 65 ++++---------------- 3 files changed, 104 insertions(+), 115 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroCircles.cs b/osu.Game/Screens/Menu/IntroCircles.cs index c069f82134..d5d7f5cb7a 100644 --- a/osu.Game/Screens/Menu/IntroCircles.cs +++ b/osu.Game/Screens/Menu/IntroCircles.cs @@ -2,86 +2,46 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Audio.Sample; -using osu.Framework.Audio.Track; -using osu.Framework.Bindables; +using osu.Framework.Audio; using osu.Framework.Screens; using osu.Framework.Graphics; -using osu.Framework.MathUtils; -using osu.Game.Beatmaps; -using osu.Game.Configuration; -using osu.Game.IO.Archives; namespace osu.Game.Screens.Menu { public class IntroCircles : IntroScreen { - private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; + protected override string BeatmapHash => "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; - private SampleChannel welcome; - - private Bindable menuMusic; - - private Track track; - - private WorkingBeatmap introBeatmap; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, ISampleStore samples) - { - menuMusic = config.GetBindable(OsuSetting.MenuMusic); - - BeatmapSetInfo setInfo = null; - - if (!menuMusic.Value) - { - var sets = beatmaps.GetAllUsableBeatmapSets(); - if (sets.Count > 0) - setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID); - } - - if (setInfo == null) - { - setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash); - - if (setInfo == null) - { - // we need to import the default menu background beatmap - setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz")).Result; - - setInfo.Protected = true; - beatmaps.Update(setInfo); - } - } - - introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); - track = introBeatmap.Track; - - if (config.Get(OsuSetting.MenuVoice)) - welcome = samples.Get(@"welcome"); - } + protected override string BeatmapFile => "circles.osz"; private const double delay_step_one = 2300; private const double delay_step_two = 600; + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + if (MenuVoice.Value) + SetWelcome(); + } + protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); if (!resuming) { - Beatmap.Value = introBeatmap; - introBeatmap = null; + Beatmap.Value = IntroBeatmap; + IntroBeatmap = null; - welcome?.Play(); + Welcome?.Play(); Scheduler.AddDelayed(delegate { // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. - if (menuMusic.Value) + if (MenuMusic.Value) { - track.Restart(); - track = null; + Track.Restart(); + Track = null; } PrepareMenuLoad(); @@ -97,7 +57,7 @@ namespace osu.Game.Screens.Menu public override void OnSuspending(IScreen next) { - track = null; + Track = null; this.FadeOut(300); base.OnSuspending(next); diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 4d0f7ff87a..651fa7583d 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -4,12 +4,19 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.MathUtils; using osu.Framework.Screens; +using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.IO.Archives; using osu.Game.Screens.Backgrounds; +using osu.Game.Skinning; +using osu.Game.Online.API; +using osu.Game.Users; using osuTK; using osuTK.Graphics; @@ -17,6 +24,10 @@ namespace osu.Game.Screens.Menu { public abstract class IntroScreen : StartupScreen { + protected abstract string BeatmapHash { get; } + + protected abstract string BeatmapFile { get; } + private readonly BindableDouble exitingVolumeFade = new BindableDouble(1); public const int EXIT_DELAY = 3000; @@ -24,24 +35,83 @@ namespace osu.Game.Screens.Menu [Resolved] private AudioManager audio { get; set; } + protected SampleChannel Welcome; + private SampleChannel seeya; - private Bindable menuVoice; + protected Bindable MenuVoice; + + protected Bindable MenuMusic; + + protected Track Track; + + protected WorkingBeatmap IntroBeatmap; private LeasedBindable beatmap; public new Bindable Beatmap => beatmap; + protected Bindable User; + + protected Bindable Skin; + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); [BackgroundDependencyLoader] - private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) + private void load(OsuConfigManager config, IAPIProvider api, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) { // prevent user from changing beatmap while the intro is still runnning. beatmap = base.Beatmap.BeginLease(false); - menuVoice = config.GetBindable(OsuSetting.MenuVoice); - seeya = audio.Samples.Get(@"seeya"); + MenuVoice = config.GetBindable(OsuSetting.MenuVoice); + MenuMusic = config.GetBindable(OsuSetting.MenuMusic); + + User = api.LocalUser.GetBoundCopy(); + Skin = skinManager.CurrentSkin.GetBoundCopy(); + + Skin.BindValueChanged(_ => updateSeeya(), true); + + BeatmapSetInfo setInfo = null; + + if (!MenuMusic.Value) + { + var sets = beatmaps.GetAllUsableBeatmapSets(); + if (sets.Count > 0) + setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID); + } + + if (setInfo == null) + { + setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash); + + if (setInfo == null) + { + // we need to import the default menu background beatmap + setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream($"Tracks/{BeatmapFile}"), BeatmapFile)).Result; + + setInfo.Protected = true; + beatmaps.Update(setInfo); + } + } + + IntroBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); + Track = IntroBeatmap.Track; + } + + private void updateSeeya() + { + if (User.Value?.IsSupporter ?? false) + seeya = Skin.Value.GetSample(new SampleInfo("seeya")) ?? audio.Samples.Get(@"seeya"); + else + seeya = audio.Samples.Get(@"seeya"); + } + + protected void SetWelcome() + { + if (User.Value?.IsSupporter ?? false) + Welcome = Skin.Value.GetSample(new SampleInfo("welcome")) ?? audio.Samples.Get(@"welcome"); + else + Welcome = audio.Samples.Get(@"welcome"); } /// @@ -61,7 +131,7 @@ namespace osu.Game.Screens.Menu double fadeOutTime = EXIT_DELAY; //we also handle the exit transition. - if (menuVoice.Value) + if (MenuVoice.Value) seeya.Play(); else fadeOutTime = 500; diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index db970dd76e..77700900a8 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -6,9 +6,6 @@ using System.Collections.Generic; using System.IO; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Audio.Track; -using osu.Framework.Bindables; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,12 +14,9 @@ using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Video; using osu.Framework.MathUtils; using osu.Framework.Timing; -using osu.Game.Beatmaps; -using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.IO.Archives; using osu.Game.Rulesets; using osu.Game.Screens.Backgrounds; using osuTK; @@ -32,9 +26,9 @@ namespace osu.Game.Screens.Menu { public class IntroTriangles : IntroScreen { - private const string menu_music_beatmap_hash = "a1556d0801b3a6b175dda32ef546f0ec812b400499f575c44fccbe9c67f9b1e5"; + protected override string BeatmapHash => "a1556d0801b3a6b175dda32ef546f0ec812b400499f575c44fccbe9c67f9b1e5"; - private SampleChannel welcome; + protected override string BeatmapFile => "triangles.osz"; protected override BackgroundScreen CreateBackground() => background = new BackgroundScreenDefault(false) { @@ -44,48 +38,13 @@ namespace osu.Game.Screens.Menu [Resolved] private AudioManager audio { get; set; } - private Bindable menuMusic; - private Track track; - private WorkingBeatmap introBeatmap; - private BackgroundScreenDefault background; [BackgroundDependencyLoader] - private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) + private void load(AudioManager audio) { - menuMusic = config.GetBindable(OsuSetting.MenuMusic); - - BeatmapSetInfo setInfo = null; - - if (!menuMusic.Value) - { - var sets = beatmaps.GetAllUsableBeatmapSets(); - if (sets.Count > 0) - setInfo = beatmaps.QueryBeatmapSet(s => s.ID == sets[RNG.Next(0, sets.Count - 1)].ID); - } - - if (setInfo == null) - { - setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash); - - if (setInfo == null) - { - // we need to import the default menu background beatmap - setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream(@"Tracks/triangles.osz"), "triangles.osz")).Result; - - setInfo.Protected = true; - beatmaps.Update(setInfo); - } - } - - introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); - - track = introBeatmap.Track; - track.Reset(); - - if (config.Get(OsuSetting.MenuVoice) && !menuMusic.Value) - // triangles has welcome sound included in the track. only play this if the user doesn't want menu music. - welcome = audio.Samples.Get(@"welcome"); + if (MenuVoice.Value && !MenuMusic.Value) + SetWelcome(); } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -96,24 +55,24 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Beatmap.Value = introBeatmap; - introBeatmap = null; + Beatmap.Value = IntroBeatmap; + IntroBeatmap = null; PrepareMenuLoad(); LoadComponentAsync(new TrianglesIntroSequence(logo, background) { RelativeSizeAxes = Axes.Both, - Clock = new FramedClock(menuMusic.Value ? track : null), + Clock = new FramedClock(MenuMusic.Value ? Track : null), LoadMenu = LoadMenu }, t => { AddInternal(t); - welcome?.Play(); + Welcome?.Play(); // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. - if (menuMusic.Value) - track.Start(); + if (MenuMusic.Value) + Track.Start(); }); } } @@ -126,7 +85,7 @@ namespace osu.Game.Screens.Menu public override void OnSuspending(IScreen next) { - track = null; + Track = null; base.OnSuspending(next); } From ec78889e94178357e1d18303ca0f7164f5e31955 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 08:14:20 +0800 Subject: [PATCH 02/43] remove unused dependencies --- osu.Game/Screens/Menu/IntroCircles.cs | 3 +-- osu.Game/Screens/Menu/IntroTriangles.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroCircles.cs b/osu.Game/Screens/Menu/IntroCircles.cs index d5d7f5cb7a..a861d54663 100644 --- a/osu.Game/Screens/Menu/IntroCircles.cs +++ b/osu.Game/Screens/Menu/IntroCircles.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Screens; using osu.Framework.Graphics; @@ -18,7 +17,7 @@ namespace osu.Game.Screens.Menu private const double delay_step_two = 600; [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load() { if (MenuVoice.Value) SetWelcome(); diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index 77700900a8..5b49a81a5a 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Menu private BackgroundScreenDefault background; [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load() { if (MenuVoice.Value && !MenuMusic.Value) SetWelcome(); From afa043aa7de522e6436276d2c000f9820800b970 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 18:17:27 +0800 Subject: [PATCH 03/43] always use default samples --- osu.Game/Screens/Menu/IntroCircles.cs | 5 +++-- osu.Game/Screens/Menu/IntroScreen.cs | 30 ++----------------------- osu.Game/Screens/Menu/IntroTriangles.cs | 4 ++-- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroCircles.cs b/osu.Game/Screens/Menu/IntroCircles.cs index a861d54663..6c643860a0 100644 --- a/osu.Game/Screens/Menu/IntroCircles.cs +++ b/osu.Game/Screens/Menu/IntroCircles.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Screens; using osu.Framework.Graphics; @@ -17,10 +18,10 @@ namespace osu.Game.Screens.Menu private const double delay_step_two = 600; [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio) { if (MenuVoice.Value) - SetWelcome(); + Welcome = audio.Samples.Get(@"welcome"); } protected override void LogoArriving(OsuLogo logo, bool resuming) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 651fa7583d..c81fef6436 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -9,14 +9,11 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Screens; -using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.IO.Archives; using osu.Game.Screens.Backgrounds; using osu.Game.Skinning; -using osu.Game.Online.API; -using osu.Game.Users; using osuTK; using osuTK.Graphics; @@ -51,14 +48,10 @@ namespace osu.Game.Screens.Menu public new Bindable Beatmap => beatmap; - protected Bindable User; - - protected Bindable Skin; - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); [BackgroundDependencyLoader] - private void load(OsuConfigManager config, IAPIProvider api, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) + private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) { // prevent user from changing beatmap while the intro is still runnning. beatmap = base.Beatmap.BeginLease(false); @@ -66,10 +59,7 @@ namespace osu.Game.Screens.Menu MenuVoice = config.GetBindable(OsuSetting.MenuVoice); MenuMusic = config.GetBindable(OsuSetting.MenuMusic); - User = api.LocalUser.GetBoundCopy(); - Skin = skinManager.CurrentSkin.GetBoundCopy(); - - Skin.BindValueChanged(_ => updateSeeya(), true); + seeya = audio.Samples.Get(@"seeya"); BeatmapSetInfo setInfo = null; @@ -98,22 +88,6 @@ namespace osu.Game.Screens.Menu Track = IntroBeatmap.Track; } - private void updateSeeya() - { - if (User.Value?.IsSupporter ?? false) - seeya = Skin.Value.GetSample(new SampleInfo("seeya")) ?? audio.Samples.Get(@"seeya"); - else - seeya = audio.Samples.Get(@"seeya"); - } - - protected void SetWelcome() - { - if (User.Value?.IsSupporter ?? false) - Welcome = Skin.Value.GetSample(new SampleInfo("welcome")) ?? audio.Samples.Get(@"welcome"); - else - Welcome = audio.Samples.Get(@"welcome"); - } - /// /// Whether we have loaded the menu previously. /// diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index 5b49a81a5a..590069ab43 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -41,10 +41,10 @@ namespace osu.Game.Screens.Menu private BackgroundScreenDefault background; [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio) { if (MenuVoice.Value && !MenuMusic.Value) - SetWelcome(); + Welcome = audio.Samples.Get(@"welcome"); } protected override void LogoArriving(OsuLogo logo, bool resuming) From d2c9a29c0d4bf8f805dbead933156a57ea466d75 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 4 Oct 2019 10:45:18 +0800 Subject: [PATCH 04/43] Remove unnecessary local assign --- osu.Game/Screens/Select/SongSelect.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 5ab49fa2b9..e97fac96c5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -66,11 +66,7 @@ namespace osu.Game.Screens.Select /// protected readonly Container FooterPanels; - protected override BackgroundScreen CreateBackground() - { - var background = new BackgroundScreenBeatmap(); - return background; - } + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); protected readonly BeatmapCarousel Carousel; private readonly BeatmapInfoWedge beatmapInfoWedge; From 3c0b1be7f48c32db7714b04ce6fda76ffeefdcb8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 11:52:16 +0900 Subject: [PATCH 05/43] Add xmldoc where applicable --- osu.Game/Screens/Menu/IntroScreen.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index c81fef6436..1052ebdd5b 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -21,8 +21,15 @@ namespace osu.Game.Screens.Menu { public abstract class IntroScreen : StartupScreen { + /// + /// A hash used to find the associated beatmap if already imported. + /// protected abstract string BeatmapHash { get; } + /// + /// A source file to use as an import source if the intro beatmap is not yet present. + /// Should be within the "Tracks" namespace of game resources. + /// protected abstract string BeatmapFile { get; } private readonly BindableDouble exitingVolumeFade = new BindableDouble(1); From c3d56088d87d8f12fe7abbe2912b8a6f89e73bc1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 11:54:39 +0900 Subject: [PATCH 06/43] Make constant private --- osu.Game/Screens/Menu/IntroScreen.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 1052ebdd5b..5d560c0c2a 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Menu private readonly BindableDouble exitingVolumeFade = new BindableDouble(1); - public const int EXIT_DELAY = 3000; + private const int exit_delay = 3000; [Resolved] private AudioManager audio { get; set; } @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Menu { this.FadeIn(300); - double fadeOutTime = EXIT_DELAY; + double fadeOutTime = exit_delay; //we also handle the exit transition. if (MenuVoice.Value) seeya.Play(); @@ -151,8 +151,8 @@ namespace osu.Game.Screens.Menu .ScaleTo(1, initialMovementTime, Easing.OutQuint) .FadeIn(quick_appear, Easing.OutQuint) .Then() - .RotateTo(20, EXIT_DELAY * 1.5f) - .FadeOut(EXIT_DELAY); + .RotateTo(20, exit_delay * 1.5f) + .FadeOut(exit_delay); } } From 449e53ee6d5c57db401884b9924eb4d5158dda20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:03:42 +0900 Subject: [PATCH 07/43] Centralise track handling --- osu.Game/Screens/Menu/IntroCircles.cs | 12 +----------- osu.Game/Screens/Menu/IntroScreen.cs | 18 +++++++++++++++++- osu.Game/Screens/Menu/IntroTriangles.cs | 13 +------------ 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroCircles.cs b/osu.Game/Screens/Menu/IntroCircles.cs index 6c643860a0..8f3b4f43c5 100644 --- a/osu.Game/Screens/Menu/IntroCircles.cs +++ b/osu.Game/Screens/Menu/IntroCircles.cs @@ -30,19 +30,11 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Beatmap.Value = IntroBeatmap; - IntroBeatmap = null; - Welcome?.Play(); Scheduler.AddDelayed(delegate { - // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. - if (MenuMusic.Value) - { - Track.Restart(); - Track = null; - } + StartTrack(); PrepareMenuLoad(); @@ -57,8 +49,6 @@ namespace osu.Game.Screens.Menu public override void OnSuspending(IScreen next) { - Track = null; - this.FadeOut(300); base.OnSuspending(next); } diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 5d560c0c2a..c00d105e12 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -47,7 +47,7 @@ namespace osu.Game.Screens.Menu protected Bindable MenuMusic; - protected Track Track; + protected Track Track { get; private set; } protected WorkingBeatmap IntroBeatmap; @@ -57,6 +57,13 @@ namespace osu.Game.Screens.Menu protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); + protected void StartTrack() + { + // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. + if (MenuMusic.Value) + Track.Restart(); + } + [BackgroundDependencyLoader] private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) { @@ -136,6 +143,9 @@ namespace osu.Game.Screens.Menu if (!resuming) { + Beatmap.Value = IntroBeatmap; + IntroBeatmap = null; + logo.MoveTo(new Vector2(0.5f)); logo.ScaleTo(Vector2.One); logo.Hide(); @@ -156,6 +166,12 @@ namespace osu.Game.Screens.Menu } } + public override void OnSuspending(IScreen next) + { + base.OnSuspending(next); + Track = null; + } + private MainMenu mainMenu; protected void PrepareMenuLoad() diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index 590069ab43..08941eca37 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -55,9 +55,6 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Beatmap.Value = IntroBeatmap; - IntroBeatmap = null; - PrepareMenuLoad(); LoadComponentAsync(new TrianglesIntroSequence(logo, background) @@ -70,9 +67,7 @@ namespace osu.Game.Screens.Menu AddInternal(t); Welcome?.Play(); - // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. - if (MenuMusic.Value) - Track.Start(); + StartTrack(); }); } } @@ -83,12 +78,6 @@ namespace osu.Game.Screens.Menu background.FadeOut(100); } - public override void OnSuspending(IScreen next) - { - Track = null; - base.OnSuspending(next); - } - private class TrianglesIntroSequence : CompositeDrawable { private readonly OsuLogo logo; From a0bb19334219edf1f37282a95aa11893cb2fd954 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:04:13 +0900 Subject: [PATCH 08/43] Remove unnecessary beatmap storage --- osu.Game/Screens/Menu/IntroScreen.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index c00d105e12..ccb7b8ef3d 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -53,8 +53,6 @@ namespace osu.Game.Screens.Menu private LeasedBindable beatmap; - public new Bindable Beatmap => beatmap; - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); protected void StartTrack() @@ -68,7 +66,7 @@ namespace osu.Game.Screens.Menu private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) { // prevent user from changing beatmap while the intro is still runnning. - beatmap = base.Beatmap.BeginLease(false); + beatmap = Beatmap.BeginLease(false); MenuVoice = config.GetBindable(OsuSetting.MenuVoice); MenuMusic = config.GetBindable(OsuSetting.MenuMusic); From 4ba2dccde30caac207687d4bff7bbb62a2d770cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:05:52 +0900 Subject: [PATCH 09/43] Reorder file contents --- osu.Game/Screens/Menu/IntroScreen.cs | 73 +++++++++++++--------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index ccb7b8ef3d..c638d4f3c9 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -21,6 +21,11 @@ namespace osu.Game.Screens.Menu { public abstract class IntroScreen : StartupScreen { + /// + /// Whether we have loaded the menu previously. + /// + public bool DidLoadMenu { get; private set; } + /// /// A hash used to find the associated beatmap if already imported. /// @@ -32,35 +37,28 @@ namespace osu.Game.Screens.Menu /// protected abstract string BeatmapFile { get; } - private readonly BindableDouble exitingVolumeFade = new BindableDouble(1); - - private const int exit_delay = 3000; - - [Resolved] - private AudioManager audio { get; set; } - protected SampleChannel Welcome; - private SampleChannel seeya; - protected Bindable MenuVoice; protected Bindable MenuMusic; + protected WorkingBeatmap IntroBeatmap; + protected Track Track { get; private set; } - protected WorkingBeatmap IntroBeatmap; + private readonly BindableDouble exitingVolumeFade = new BindableDouble(1); + + private const int exit_delay = 3000; + + private SampleChannel seeya; private LeasedBindable beatmap; - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); + private MainMenu mainMenu; - protected void StartTrack() - { - // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. - if (MenuMusic.Value) - Track.Restart(); - } + [Resolved] + private AudioManager audio { get; set; } [BackgroundDependencyLoader] private void load(OsuConfigManager config, SkinManager skinManager, BeatmapManager beatmaps, Framework.Game game) @@ -100,16 +98,7 @@ namespace osu.Game.Screens.Menu Track = IntroBeatmap.Track; } - /// - /// Whether we have loaded the menu previously. - /// - public bool DidLoadMenu { get; private set; } - - public override bool OnExiting(IScreen next) - { - //cancel exiting if we haven't loaded the menu yet. - return !DidLoadMenu; - } + public override bool OnExiting(IScreen next) => !DidLoadMenu; public override void OnResuming(IScreen last) { @@ -131,6 +120,21 @@ namespace osu.Game.Screens.Menu base.OnResuming(last); } + public override void OnSuspending(IScreen next) + { + base.OnSuspending(next); + Track = null; + } + + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); + + protected void StartTrack() + { + // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Menu. + if (MenuMusic.Value) + Track.Restart(); + } + protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); @@ -151,7 +155,7 @@ namespace osu.Game.Screens.Menu else { const int quick_appear = 350; - int initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0; + var initialMovementTime = logo.Alpha > 0.2f ? quick_appear : 0; logo.MoveTo(new Vector2(0.5f), initialMovementTime, Easing.OutQuint); @@ -164,18 +168,7 @@ namespace osu.Game.Screens.Menu } } - public override void OnSuspending(IScreen next) - { - base.OnSuspending(next); - Track = null; - } - - private MainMenu mainMenu; - - protected void PrepareMenuLoad() - { - LoadComponentAsync(mainMenu = new MainMenu()); - } + protected void PrepareMenuLoad() => LoadComponentAsync(mainMenu = new MainMenu()); protected void LoadMenu() { From b8b2ff2674001e9bc3334a7799a8931b5004e7d9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:07:59 +0900 Subject: [PATCH 10/43] Move welcome to local usages --- osu.Game/Screens/Menu/IntroCircles.cs | 7 +++++-- osu.Game/Screens/Menu/IntroScreen.cs | 2 -- osu.Game/Screens/Menu/IntroTriangles.cs | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroCircles.cs b/osu.Game/Screens/Menu/IntroCircles.cs index 8f3b4f43c5..aa9cee969c 100644 --- a/osu.Game/Screens/Menu/IntroCircles.cs +++ b/osu.Game/Screens/Menu/IntroCircles.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Screens; using osu.Framework.Graphics; @@ -17,11 +18,13 @@ namespace osu.Game.Screens.Menu private const double delay_step_one = 2300; private const double delay_step_two = 600; + private SampleChannel welcome; + [BackgroundDependencyLoader] private void load(AudioManager audio) { if (MenuVoice.Value) - Welcome = audio.Samples.Get(@"welcome"); + welcome = audio.Samples.Get(@"welcome"); } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -30,7 +33,7 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Welcome?.Play(); + welcome?.Play(); Scheduler.AddDelayed(delegate { diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index c638d4f3c9..0c192552eb 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -37,8 +37,6 @@ namespace osu.Game.Screens.Menu /// protected abstract string BeatmapFile { get; } - protected SampleChannel Welcome; - protected Bindable MenuVoice; protected Bindable MenuMusic; diff --git a/osu.Game/Screens/Menu/IntroTriangles.cs b/osu.Game/Screens/Menu/IntroTriangles.cs index 08941eca37..c86f1393a4 100644 --- a/osu.Game/Screens/Menu/IntroTriangles.cs +++ b/osu.Game/Screens/Menu/IntroTriangles.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using osu.Framework.Allocation; using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -40,11 +41,13 @@ namespace osu.Game.Screens.Menu private BackgroundScreenDefault background; + private SampleChannel welcome; + [BackgroundDependencyLoader] private void load(AudioManager audio) { if (MenuVoice.Value && !MenuMusic.Value) - Welcome = audio.Samples.Get(@"welcome"); + welcome = audio.Samples.Get(@"welcome"); } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -65,7 +68,7 @@ namespace osu.Game.Screens.Menu }, t => { AddInternal(t); - Welcome?.Play(); + welcome?.Play(); StartTrack(); }); From c280bee894df7e9c01c88332df579d2964f401e1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:08:47 +0900 Subject: [PATCH 11/43] Protect configuration bindables --- osu.Game/Screens/Menu/IntroScreen.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 0c192552eb..feb472ba88 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -37,9 +37,9 @@ namespace osu.Game.Screens.Menu /// protected abstract string BeatmapFile { get; } - protected Bindable MenuVoice; + protected IBindable MenuVoice { get; private set; } - protected Bindable MenuMusic; + protected IBindable MenuMusic { get; private set; } protected WorkingBeatmap IntroBeatmap; From cbb120cd3874044673e3197a9fc78942433a3edd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:09:42 +0900 Subject: [PATCH 12/43] Switch beatmap to private --- osu.Game/Screens/Menu/IntroScreen.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index feb472ba88..f5ef839b06 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Menu protected IBindable MenuMusic { get; private set; } - protected WorkingBeatmap IntroBeatmap; + private WorkingBeatmap introBeatmap; protected Track Track { get; private set; } @@ -92,8 +92,8 @@ namespace osu.Game.Screens.Menu } } - IntroBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); - Track = IntroBeatmap.Track; + introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); + Track = introBeatmap.Track; } public override bool OnExiting(IScreen next) => !DidLoadMenu; @@ -143,8 +143,8 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Beatmap.Value = IntroBeatmap; - IntroBeatmap = null; + Beatmap.Value = introBeatmap; + introBeatmap = null; logo.MoveTo(new Vector2(0.5f)); logo.ScaleTo(Vector2.One); From 52770f803d8844c135c3cfb05a4abb1d119e087c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Oct 2019 12:14:53 +0900 Subject: [PATCH 13/43] Fix incorrect beatmap usage --- osu.Game/Screens/Menu/IntroScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index f5ef839b06..df83e98494 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -143,7 +143,7 @@ namespace osu.Game.Screens.Menu if (!resuming) { - Beatmap.Value = introBeatmap; + beatmap.Value = introBeatmap; introBeatmap = null; logo.MoveTo(new Vector2(0.5f)); From 08d043f44715b02f1f65ecdc59fe21ce6190ec2a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Oct 2019 18:57:03 +0900 Subject: [PATCH 14/43] Move selection relative to the hitobject start positions --- .../Blueprints/ManiaSelectionBlueprint.cs | 2 +- .../Edit/ManiaSelectionHandler.cs | 23 ++++---- .../Edit/OsuSelectionHandler.cs | 5 +- osu.Game/Rulesets/Edit/SelectionBlueprint.cs | 11 +++- .../Compose/Components/BlueprintContainer.cs | 9 +++- .../Compose/Components/SelectionDragEvent.cs | 53 +++++++++++++++++++ .../Compose/Components/SelectionHandler.cs | 2 +- 7 files changed, 87 insertions(+), 18 deletions(-) create mode 100644 osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs index d3c12b1944..cc50459a0c 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints public Vector2 ScreenSpaceDragPosition { get; private set; } public Vector2 DragPosition { get; private set; } - protected new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject; + public new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject; protected IClock EditorClock { get; private set; } diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs index 6f49c7f0c4..389837b059 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs @@ -3,7 +3,6 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Input.Events; using osu.Framework.Timing; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Edit.Blueprints; @@ -31,11 +30,14 @@ namespace osu.Game.Rulesets.Mania.Edit editorClock = clock; } - public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent) + public override void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) { - adjustOrigins((ManiaSelectionBlueprint)blueprint); + var maniaBlueprint = (ManiaSelectionBlueprint)blueprint; + int lastColumn = maniaBlueprint.HitObject.HitObject.Column; + + adjustOrigins(maniaBlueprint); performDragMovement(dragEvent); - performColumnMovement(dragEvent); + performColumnMovement(lastColumn, dragEvent); base.HandleDrag(blueprint, dragEvent); } @@ -62,7 +64,7 @@ namespace osu.Game.Rulesets.Mania.Edit b.HitObject.Y += movementDelta; } - private void performDragMovement(DragEvent dragEvent) + private void performDragMovement(SelectionDragEvent dragEvent) { foreach (var b in SelectedBlueprints) { @@ -72,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Edit // Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame // without the position having been updated by the parenting ScrollingHitObjectContainer - hitObject.Y += dragEvent.Delta.Y; + hitObject.Y += dragEvent.InstantDragDelta.Y; float targetPosition; @@ -94,14 +96,13 @@ namespace osu.Game.Rulesets.Mania.Edit } } - private void performColumnMovement(DragEvent dragEvent) + private void performColumnMovement(int lastColumn, SelectionDragEvent dragEvent) { - var lastColumn = composer.ColumnAt(dragEvent.ScreenSpaceLastMousePosition); - var currentColumn = composer.ColumnAt(dragEvent.ScreenSpaceMousePosition); - if (lastColumn == null || currentColumn == null) + var currentColumn = composer.ColumnAt(dragEvent.ScreenSpaceDragPosition); + if (currentColumn == null) return; - int columnDelta = currentColumn.Index - lastColumn.Index; + int columnDelta = currentColumn.Index - lastColumn; if (columnDelta == 0) return; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index 1ab1219ab0..4a0e88889b 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Framework.Input.Events; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Screens.Edit.Compose.Components; @@ -11,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Edit { public class OsuSelectionHandler : SelectionHandler { - public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent) + public override void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) { foreach (var h in SelectedHitObjects.OfType()) { @@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Edit continue; } - h.Position += dragEvent.Delta; + h.Position += dragEvent.InstantDragDelta; } base.HandleDrag(blueprint, dragEvent); diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs index 0f77b8d584..aa0dd1cc25 100644 --- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs +++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs @@ -45,6 +45,11 @@ namespace osu.Game.Rulesets.Edit /// public readonly DrawableHitObject HitObject; + /// + /// The screen-space position of when a drag was started. + /// + public Vector2 ScreenSpaceDragStartPosition { get; private set; } + protected override bool ShouldBeAlive => (HitObject.IsAlive && HitObject.IsPresent) || State == SelectionState.Selected; public override bool HandlePositionalInput => ShouldBeAlive; public override bool RemoveWhenNotAlive => false; @@ -131,7 +136,11 @@ namespace osu.Game.Rulesets.Edit return base.OnClick(e); } - protected override bool OnDragStart(DragStartEvent e) => true; + protected override bool OnDragStart(DragStartEvent e) + { + ScreenSpaceDragStartPosition = HitObject.ToScreenSpace(HitObject.OriginPosition); + return true; + } protected override bool OnDrag(DragEvent e) { diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index d96d88c2b9..3286be4be6 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -216,7 +216,14 @@ namespace osu.Game.Screens.Edit.Compose.Components private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionHandler.HandleSelectionRequested(blueprint, state); - private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) => selectionHandler.HandleDrag(blueprint, dragEvent); + private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) + { + var dragPosition = blueprint.ScreenSpaceDragStartPosition + dragEvent.ScreenSpaceMousePosition - dragEvent.ScreenSpaceMouseDownPosition; + + // Todo: Snap dragPosition + + selectionHandler.HandleDrag(blueprint, new SelectionDragEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition)); + } protected override void Dispose(bool isDisposing) { diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs new file mode 100644 index 0000000000..8e00e8c30c --- /dev/null +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs @@ -0,0 +1,53 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Edit; +using osuTK; + +namespace osu.Game.Screens.Edit.Compose.Components +{ + /// + /// An event which occurs when a is dragged. + /// + public class SelectionDragEvent + { + /// + /// The dragged . + /// + public readonly SelectionBlueprint DraggedBlueprint; + + /// + /// The screen-space position of the hitobject at the start of the drag. + /// + public readonly Vector2 ScreenSpaceDragStartPosition; + + /// + /// The new screen-space position of the hitobject at the current drag point. + /// + public readonly Vector2 ScreenSpaceDragPosition; + + /// + /// The distance between and the hitobject's current position, in the coordinate-space of the hitobject's parent. + /// + /// + /// This does not use and does not represent the cumulative drag distance. + /// + public readonly Vector2 InstantDragDelta; + + public SelectionDragEvent(SelectionBlueprint blueprint, Vector2 screenSpaceDragStartPosition, Vector2 screenSpaceDragPosition) + { + DraggedBlueprint = blueprint; + ScreenSpaceDragStartPosition = screenSpaceDragStartPosition; + ScreenSpaceDragPosition = screenSpaceDragPosition; + + InstantDragDelta = toLocalSpace(ScreenSpaceDragPosition) - DraggedBlueprint.HitObject.Position; + } + + /// + /// Converts a screen-space position into the coordinate space of the hitobject's parents. + /// + /// The screen-space position. + /// The position in the coordinate space of the hitobject's parent. + private Vector2 toLocalSpace(Vector2 screenSpacePosition) => DraggedBlueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition); + } +} diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 11e649168f..3fb06c8ee8 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Edit.Compose.Components /// /// The that received the drag event. /// The drag event. - public virtual void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent) + public virtual void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) { } From 8b661e624d25334b7c1b67db6b6c83c138a51ec1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Oct 2019 19:08:23 +0900 Subject: [PATCH 15/43] Remove drag from class/method namings + refactor --- .../Edit/ManiaSelectionHandler.cs | 19 ++++--- .../Edit/OsuSelectionHandler.cs | 7 ++- .../Compose/Components/BlueprintContainer.cs | 2 +- .../Compose/Components/MoveSelectionEvent.cs | 53 +++++++++++++++++++ .../Compose/Components/SelectionDragEvent.cs | 53 ------------------- .../Compose/Components/SelectionHandler.cs | 7 ++- 6 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs delete mode 100644 osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs index 389837b059..f576c43e52 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs @@ -4,7 +4,6 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Timing; -using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Edit.Blueprints; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.UI; @@ -30,16 +29,16 @@ namespace osu.Game.Rulesets.Mania.Edit editorClock = clock; } - public override void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) + public override void HandleMovement(MoveSelectionEvent moveEvent) { - var maniaBlueprint = (ManiaSelectionBlueprint)blueprint; + var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint; int lastColumn = maniaBlueprint.HitObject.HitObject.Column; adjustOrigins(maniaBlueprint); - performDragMovement(dragEvent); - performColumnMovement(lastColumn, dragEvent); + performDragMovement(moveEvent); + performColumnMovement(lastColumn, moveEvent); - base.HandleDrag(blueprint, dragEvent); + base.HandleMovement(moveEvent); } /// @@ -64,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.Edit b.HitObject.Y += movementDelta; } - private void performDragMovement(SelectionDragEvent dragEvent) + private void performDragMovement(MoveSelectionEvent moveEvent) { foreach (var b in SelectedBlueprints) { @@ -74,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Edit // Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame // without the position having been updated by the parenting ScrollingHitObjectContainer - hitObject.Y += dragEvent.InstantDragDelta.Y; + hitObject.Y += moveEvent.InstantDelta.Y; float targetPosition; @@ -96,9 +95,9 @@ namespace osu.Game.Rulesets.Mania.Edit } } - private void performColumnMovement(int lastColumn, SelectionDragEvent dragEvent) + private void performColumnMovement(int lastColumn, MoveSelectionEvent moveEvent) { - var currentColumn = composer.ColumnAt(dragEvent.ScreenSpaceDragPosition); + var currentColumn = composer.ColumnAt(moveEvent.ScreenSpacePosition); if (currentColumn == null) return; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index 4a0e88889b..472267eb66 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Screens.Edit.Compose.Components; @@ -10,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Edit { public class OsuSelectionHandler : SelectionHandler { - public override void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) + public override void HandleMovement(MoveSelectionEvent moveEvent) { foreach (var h in SelectedHitObjects.OfType()) { @@ -20,10 +19,10 @@ namespace osu.Game.Rulesets.Osu.Edit continue; } - h.Position += dragEvent.InstantDragDelta; + h.Position += moveEvent.InstantDelta; } - base.HandleDrag(blueprint, dragEvent); + base.HandleMovement(moveEvent); } } } diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 3286be4be6..593d70b24f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -222,7 +222,7 @@ namespace osu.Game.Screens.Edit.Compose.Components // Todo: Snap dragPosition - selectionHandler.HandleDrag(blueprint, new SelectionDragEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition)); + selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition)); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs new file mode 100644 index 0000000000..a75226d2bc --- /dev/null +++ b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs @@ -0,0 +1,53 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Edit; +using osuTK; + +namespace osu.Game.Screens.Edit.Compose.Components +{ + /// + /// An event which occurs when a is moved. + /// + public class MoveSelectionEvent + { + /// + /// The that triggered this . + /// + public readonly SelectionBlueprint Blueprint; + + /// + /// The starting screen-space position of the hitobject. + /// + public readonly Vector2 ScreenSpaceStartPosition; + + /// + /// The expected screen-space position of the hitobject at the current cursor position. + /// + public readonly Vector2 ScreenSpacePosition; + + /// + /// The distance between and the hitobject's current position, in the coordinate-space of the hitobject's parent. + /// + /// + /// This does not use and does not represent the cumulative movement distance. + /// + public readonly Vector2 InstantDelta; + + public MoveSelectionEvent(SelectionBlueprint blueprint, Vector2 screenSpaceStartPosition, Vector2 screenSpacePosition) + { + Blueprint = blueprint; + ScreenSpaceStartPosition = screenSpaceStartPosition; + ScreenSpacePosition = screenSpacePosition; + + InstantDelta = toLocalSpace(ScreenSpacePosition) - Blueprint.HitObject.Position; + } + + /// + /// Converts a screen-space position into the coordinate space of the hitobject's parents. + /// + /// The screen-space position. + /// The position in the coordinate space of the hitobject's parent. + private Vector2 toLocalSpace(Vector2 screenSpacePosition) => Blueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition); + } +} diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs deleted file mode 100644 index 8e00e8c30c..0000000000 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionDragEvent.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Edit; -using osuTK; - -namespace osu.Game.Screens.Edit.Compose.Components -{ - /// - /// An event which occurs when a is dragged. - /// - public class SelectionDragEvent - { - /// - /// The dragged . - /// - public readonly SelectionBlueprint DraggedBlueprint; - - /// - /// The screen-space position of the hitobject at the start of the drag. - /// - public readonly Vector2 ScreenSpaceDragStartPosition; - - /// - /// The new screen-space position of the hitobject at the current drag point. - /// - public readonly Vector2 ScreenSpaceDragPosition; - - /// - /// The distance between and the hitobject's current position, in the coordinate-space of the hitobject's parent. - /// - /// - /// This does not use and does not represent the cumulative drag distance. - /// - public readonly Vector2 InstantDragDelta; - - public SelectionDragEvent(SelectionBlueprint blueprint, Vector2 screenSpaceDragStartPosition, Vector2 screenSpaceDragPosition) - { - DraggedBlueprint = blueprint; - ScreenSpaceDragStartPosition = screenSpaceDragStartPosition; - ScreenSpaceDragPosition = screenSpaceDragPosition; - - InstantDragDelta = toLocalSpace(ScreenSpaceDragPosition) - DraggedBlueprint.HitObject.Position; - } - - /// - /// Converts a screen-space position into the coordinate space of the hitobject's parents. - /// - /// The screen-space position. - /// The position in the coordinate space of the hitobject's parent. - private Vector2 toLocalSpace(Vector2 screenSpacePosition) => DraggedBlueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition); - } -} diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 3fb06c8ee8..c9e862d99e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -65,11 +65,10 @@ namespace osu.Game.Screens.Edit.Compose.Components #region User Input Handling /// - /// Handles the selected s being dragged. + /// Handles the selected s being moved. /// - /// The that received the drag event. - /// The drag event. - public virtual void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent) + /// The move event. + public virtual void HandleMovement(MoveSelectionEvent moveEvent) { } From c1db11fa0612622cce5182a987847dc96701e66b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Oct 2019 19:24:58 +0900 Subject: [PATCH 16/43] More removal of "drag" --- osu.Game/Rulesets/Edit/SelectionBlueprint.cs | 6 +++--- .../Screens/Edit/Compose/Components/BlueprintContainer.cs | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs index aa0dd1cc25..838984b223 100644 --- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs +++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs @@ -46,9 +46,9 @@ namespace osu.Game.Rulesets.Edit public readonly DrawableHitObject HitObject; /// - /// The screen-space position of when a drag was started. + /// The screen-space position of prior to handling a movement event. /// - public Vector2 ScreenSpaceDragStartPosition { get; private set; } + internal Vector2 ScreenSpaceMovementStartPosition { get; private set; } protected override bool ShouldBeAlive => (HitObject.IsAlive && HitObject.IsPresent) || State == SelectionState.Selected; public override bool HandlePositionalInput => ShouldBeAlive; @@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Edit protected override bool OnDragStart(DragStartEvent e) { - ScreenSpaceDragStartPosition = HitObject.ToScreenSpace(HitObject.OriginPosition); + ScreenSpaceMovementStartPosition = HitObject.ToScreenSpace(HitObject.OriginPosition); return true; } diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 593d70b24f..2de5ecf633 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -218,11 +218,9 @@ namespace osu.Game.Screens.Edit.Compose.Components private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) { - var dragPosition = blueprint.ScreenSpaceDragStartPosition + dragEvent.ScreenSpaceMousePosition - dragEvent.ScreenSpaceMouseDownPosition; + var movePosition = blueprint.ScreenSpaceMovementStartPosition + dragEvent.ScreenSpaceMousePosition - dragEvent.ScreenSpaceMouseDownPosition; - // Todo: Snap dragPosition - - selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition)); + selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceMovementStartPosition, movePosition)); } protected override void Dispose(bool isDisposing) From 179656788dd87caae95c35c3e8e4b0372106bcbd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Oct 2019 19:27:59 +0900 Subject: [PATCH 17/43] Remove unnecessary method --- .../Edit/Compose/Components/MoveSelectionEvent.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs index a75226d2bc..13945381bb 100644 --- a/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs +++ b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs @@ -40,14 +40,7 @@ namespace osu.Game.Screens.Edit.Compose.Components ScreenSpaceStartPosition = screenSpaceStartPosition; ScreenSpacePosition = screenSpacePosition; - InstantDelta = toLocalSpace(ScreenSpacePosition) - Blueprint.HitObject.Position; + InstantDelta = Blueprint.HitObject.Parent.ToLocalSpace(ScreenSpacePosition) - Blueprint.HitObject.Position; } - - /// - /// Converts a screen-space position into the coordinate space of the hitobject's parents. - /// - /// The screen-space position. - /// The position in the coordinate space of the hitobject's parent. - private Vector2 toLocalSpace(Vector2 screenSpacePosition) => Blueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition); } } From f74c79c2b85422fda49a147c2ee0d9441bbd49df Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Oct 2019 11:58:43 +0900 Subject: [PATCH 18/43] Fix audio playback position being reset after resuming to song select --- .../Visual/Menus/TestSceneScreenNavigation.cs | 80 ++++++++++++++----- osu.Game/Screens/Select/SongSelect.cs | 12 ++- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs index 17535cae98..124d3bb453 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs @@ -5,12 +5,15 @@ using System; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Framework.Testing; +using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; @@ -18,7 +21,9 @@ using osu.Game.Overlays; using osu.Game.Overlays.Mods; using osu.Game.Screens; using osu.Game.Screens.Menu; +using osu.Game.Screens.Play; using osu.Game.Screens.Select; +using osu.Game.Tests.Beatmaps.IO; using osuTK; using osuTK.Graphics; using osuTK.Input; @@ -31,11 +36,11 @@ namespace osu.Game.Tests.Visual.Menus private const float click_padding = 25; private GameHost host; - private TestOsuGame osuGame; + private TestOsuGame game; - private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, osuGame.LayoutRectangle.Bottom - click_padding)); + private Vector2 backButtonPosition => game.ToScreenSpace(new Vector2(click_padding, game.LayoutRectangle.Bottom - click_padding)); - private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, click_padding)); + private Vector2 optionsButtonPosition => game.ToScreenSpace(new Vector2(click_padding, click_padding)); [BackgroundDependencyLoader] private void load(GameHost host) @@ -54,23 +59,23 @@ namespace osu.Game.Tests.Visual.Menus { AddStep("Create new game instance", () => { - if (osuGame != null) + if (game != null) { - Remove(osuGame); - osuGame.Dispose(); + Remove(game); + game.Dispose(); } - osuGame = new TestOsuGame(LocalStorage, API); - osuGame.SetHost(host); + game = new TestOsuGame(LocalStorage, API); + game.SetHost(host); // todo: this can be removed once we can run audio trakcs without a device present // see https://github.com/ppy/osu/issues/1302 - osuGame.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles); + game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles); - Add(osuGame); + Add(game); }); - AddUntilStep("Wait for load", () => osuGame.IsLoaded); - AddUntilStep("Wait for intro", () => osuGame.ScreenStack.CurrentScreen is IntroScreen); + AddUntilStep("Wait for load", () => game.IsLoaded); + AddUntilStep("Wait for intro", () => game.ScreenStack.CurrentScreen is IntroScreen); confirmAtMainMenu(); } @@ -82,11 +87,39 @@ namespace osu.Game.Tests.Visual.Menus pushAndConfirm(() => songSelect = new TestSongSelect()); AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show()); AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible); - AddStep("Press escape", () => pressAndRelease(Key.Escape)); + pushEscape(); AddAssert("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden); exitViaEscapeAndConfirm(); } + [Test] + public void TestSongContinuesAfterExitPlayer() + { + Player player = null; + + WorkingBeatmap beatmap() => game.Beatmap.Value; + Track track() => beatmap().Track; + + pushAndConfirm(() => new TestSongSelect()); + + AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game).Wait()); + + AddUntilStep("wait for selected", () => !(track() is TrackVirtual)); + + AddStep("press enter", () => pressAndRelease(Key.Enter)); + + AddUntilStep("wait for player", () => (player = game.ScreenStack.CurrentScreen as Player) != null); + AddUntilStep("wait for fail", () => player.HasFailed); + + AddUntilStep("wait for track stop", () => !track().IsRunning); + AddAssert("Ensure time before preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime); + + pushEscape(); + + AddUntilStep("wait for track playing", () => track().IsRunning); + AddAssert("Ensure time wasn't reset to preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime); + } + [Test] public void TestExitSongSelectWithClick() { @@ -98,7 +131,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition)); // BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered. - AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == osuGame.BackButton)); + AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == game.BackButton)); AddStep("Click back button", () => InputManager.Click(MouseButton.Left)); AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden); @@ -122,25 +155,28 @@ namespace osu.Game.Tests.Visual.Menus [Test] public void TestOpenOptionsAndExitWithEscape() { - AddUntilStep("Wait for options to load", () => osuGame.Settings.IsLoaded); + AddUntilStep("Wait for options to load", () => game.Settings.IsLoaded); AddStep("Enter menu", () => pressAndRelease(Key.Enter)); AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition)); AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left)); - AddAssert("Options overlay was opened", () => osuGame.Settings.State.Value == Visibility.Visible); + AddAssert("Options overlay was opened", () => game.Settings.State.Value == Visibility.Visible); AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape)); - AddAssert("Options overlay was closed", () => osuGame.Settings.State.Value == Visibility.Hidden); + AddAssert("Options overlay was closed", () => game.Settings.State.Value == Visibility.Hidden); } private void pushAndConfirm(Func newScreen) { Screen screen = null; - AddStep("Push new screen", () => osuGame.ScreenStack.Push(screen = newScreen())); - AddUntilStep("Wait for new screen", () => osuGame.ScreenStack.CurrentScreen == screen && screen.IsLoaded); + AddStep("Push new screen", () => game.ScreenStack.Push(screen = newScreen())); + AddUntilStep("Wait for new screen", () => game.ScreenStack.CurrentScreen == screen && screen.IsLoaded); } + private void pushEscape() => + AddStep("Press escape", () => pressAndRelease(Key.Escape)); + private void exitViaEscapeAndConfirm() { - AddStep("Press escape", () => pressAndRelease(Key.Escape)); + pushEscape(); confirmAtMainMenu(); } @@ -151,7 +187,7 @@ namespace osu.Game.Tests.Visual.Menus confirmAtMainMenu(); } - private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => osuGame.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded); + private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded); private void pressAndRelease(Key key) { @@ -169,6 +205,8 @@ namespace osu.Game.Tests.Visual.Menus public new OsuConfigManager LocalConfig => base.LocalConfig; + public new Bindable Beatmap => base.Beatmap; + protected override Loader CreateLoader() => new TestLoader(); public TestOsuGame(Storage storage, IAPIProvider api) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6c5f64ed6c..0025188ad4 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -490,7 +490,7 @@ namespace osu.Game.Screens.Select if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) { UpdateBeatmap(Beatmap.Value); - ensurePlayingSelected(); + ensurePlayingSelected(false); } base.OnResuming(last); @@ -587,7 +587,8 @@ namespace osu.Game.Screens.Select /// Ensures some music is playing for the current track. /// Will resume playback from a manual user pause if the track has changed. /// - private void ensurePlayingSelected() + /// Whether to restart from the preview point, rather than resuming from previous location. + private void ensurePlayingSelected(bool fromPreviewPoint = true) { Track track = Beatmap.Value.Track; @@ -596,7 +597,12 @@ namespace osu.Game.Screens.Select track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; if (!track.IsRunning && (music?.IsUserPaused != true || isNewTrack)) - track.Restart(); + { + if (fromPreviewPoint) + track.Restart(); + else + track.Start(); + } lastTrack.SetTarget(track); } From e66f9adb8653a68b570d7fbee47f8854a7f61084 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Oct 2019 16:52:51 +0900 Subject: [PATCH 19/43] Fix user pause not being cancelled when playing audio --- osu.Game/Overlays/MusicController.cs | 45 ++++++++++++++++++--------- osu.Game/Screens/Select/SongSelect.cs | 7 +---- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index f5c36a9cac..2547d7515e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -98,20 +98,13 @@ namespace osu.Game.Overlays /// /// Start playing the current track (if not already playing). /// - public void Play() - { - if (!IsPlaying) - TogglePause(); - } - - /// - /// Toggle pause / play. - /// /// Whether the operation was successful. - public bool TogglePause() + public bool Play(bool restart = false) { var track = current?.Track; + IsUserPaused = false; + if (track == null) { if (beatmap.Disabled) @@ -121,16 +114,40 @@ namespace osu.Game.Overlays return true; } + if (restart) + track.Restart(); + else if (!IsPlaying) + track.Start(); + + return true; + } + + /// + /// Stop playing the current track and pause at the current position. + /// + public void Stop() + { + var track = current?.Track; + if (track.IsRunning) { IsUserPaused = true; track.Stop(); } + } + + /// + /// Toggle pause / play. + /// + /// Whether the operation was successful. + public bool TogglePause() + { + var track = current?.Track; + + if (track?.IsRunning == true) + Stop(); else - { - track.Start(); - IsUserPaused = false; - } + Play(); return true; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 0025188ad4..8187dd04d1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -597,12 +597,7 @@ namespace osu.Game.Screens.Select track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; if (!track.IsRunning && (music?.IsUserPaused != true || isNewTrack)) - { - if (fromPreviewPoint) - track.Restart(); - else - track.Start(); - } + music?.Play(fromPreviewPoint); lastTrack.SetTarget(track); } From 65df7902f3f933baa68df1df3211f0077147b40f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2019 08:15:47 +0000 Subject: [PATCH 20/43] Bump ppy.osu.Framework.NativeLibs from 2019.813.0 to 2019.1010.0 Bumps [ppy.osu.Framework.NativeLibs](https://github.com/ppy/osu-framework) from 2019.813.0 to 2019.1010.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.813.0...2019.1010.0) Signed-off-by: dependabot-preview[bot] --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index a15cae55c4..e59f613c98 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -124,6 +124,6 @@ - + From efa5cedf4fef1c3393fdb6ef5926873072c8e6c5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2019 08:16:07 +0000 Subject: [PATCH 21/43] Bump ppy.osu.Framework.Android from 2019.930.0 to 2019.1010.0 Bumps [ppy.osu.Framework.Android](https://github.com/ppy/osu-framework) from 2019.930.0 to 2019.1010.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.930.0...2019.1010.0) Signed-off-by: dependabot-preview[bot] --- osu.Android.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Android.props b/osu.Android.props index 51245351b6..fa940a7c89 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -62,6 +62,6 @@ - + From bc4c1a237140da50f9958fcaf3ee7b0535e945db Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2019 08:16:28 +0000 Subject: [PATCH 22/43] Bump ppy.osu.Framework from 2019.930.0 to 2019.1010.0 Bumps [ppy.osu.Framework](https://github.com/ppy/osu-framework) from 2019.930.0 to 2019.1010.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.930.0...2019.1010.0) Signed-off-by: dependabot-preview[bot] --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8cbc8b0af3..4e3130b64c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -26,7 +26,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index a15cae55c4..8a9dc01f38 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -118,7 +118,7 @@ - + From e50d8419fda384b0f57a11e0bf4d838ab66d8783 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2019 08:30:37 +0000 Subject: [PATCH 23/43] Bump ppy.osu.Framework.iOS from 2019.930.0 to 2019.1010.0 Bumps [ppy.osu.Framework.iOS](https://github.com/ppy/osu-framework) from 2019.930.0 to 2019.1010.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.930.0...2019.1010.0) Signed-off-by: dependabot-preview[bot] --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index a15cae55c4..7069960ce1 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -119,7 +119,7 @@ - + From 8df2e359c48d458cebaa3923e9d7342428259be2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Oct 2019 17:39:41 +0900 Subject: [PATCH 24/43] Fix tests on CI --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 4 ++-- osu.Game.Tests/Resources/TestResources.cs | 6 +++--- osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 6da8d8cb71..b24171a231 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -456,9 +456,9 @@ namespace osu.Game.Tests.Beatmaps.IO } } - public static async Task LoadOszIntoOsu(OsuGameBase osu, string path = null) + public static async Task LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false) { - var temp = path ?? TestResources.GetTestBeatmapForImport(); + var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack); var manager = osu.Dependencies.Get(); diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs index 9cb85a63bf..66084a3204 100644 --- a/osu.Game.Tests/Resources/TestResources.cs +++ b/osu.Game.Tests/Resources/TestResources.cs @@ -11,13 +11,13 @@ namespace osu.Game.Tests.Resources { public static Stream OpenResource(string name) => new DllResourceStore("osu.Game.Tests.dll").GetStream($"Resources/{name}"); - public static Stream GetTestBeatmapStream() => new DllResourceStore("osu.Game.Resources.dll").GetStream("Beatmaps/241526 Soleily - Renatus.osz"); + public static Stream GetTestBeatmapStream(bool virtualTrack = false) => new DllResourceStore("osu.Game.Resources.dll").GetStream($"Beatmaps/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}.osz"); - public static string GetTestBeatmapForImport() + public static string GetTestBeatmapForImport(bool virtualTrack = false) { var temp = Path.GetTempFileName() + ".osz"; - using (var stream = GetTestBeatmapStream()) + using (var stream = GetTestBeatmapStream(virtualTrack)) using (var newFile = File.Create(temp)) stream.CopyTo(newFile); diff --git a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs index 124d3bb453..e74992e37a 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs @@ -102,9 +102,9 @@ namespace osu.Game.Tests.Visual.Menus pushAndConfirm(() => new TestSongSelect()); - AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game).Wait()); + AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Wait()); - AddUntilStep("wait for selected", () => !(track() is TrackVirtual)); + AddUntilStep("wait for selected", () => !game.Beatmap.IsDefault); AddStep("press enter", () => pressAndRelease(Key.Enter)); From 5d6648d9c95df7f5e05b5008e280f525410ccfe7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Oct 2019 17:45:38 +0900 Subject: [PATCH 25/43] Update 2.2 references --- .../CatchRuleset__Tests_.xml | 4 +-- .../ManiaRuleset__Tests_.xml | 4 +-- .../runConfigurations/OsuRuleset__Tests_.xml | 4 +-- .../TaikoRuleset__Tests_.xml | 4 +-- .../.idea/runConfigurations/Tournament.xml | 4 +-- .../.idea/runConfigurations/osu_.xml | 4 +-- .../.idea/runConfigurations/osu___Tests_.xml | 4 +-- .vscode/launch.json | 32 +++++++++---------- .vscode/tasks.json | 2 +- README.md | 4 +-- osu.Desktop/osu.Desktop.csproj | 2 +- .../.vscode/launch.json | 4 +-- .../osu.Game.Rulesets.Catch.Tests.csproj | 2 +- .../.vscode/launch.json | 4 +-- .../osu.Game.Rulesets.Mania.Tests.csproj | 2 +- .../.vscode/launch.json | 4 +-- .../osu.Game.Rulesets.Osu.Tests.csproj | 2 +- .../.vscode/launch.json | 4 +-- .../osu.Game.Rulesets.Taiko.Tests.csproj | 2 +- osu.Game.Tests/osu.Game.Tests.csproj | 2 +- .../osu.Game.Tournament.Tests.csproj | 2 +- 21 files changed, 48 insertions(+), 48 deletions(-) diff --git a/.idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml b/.idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml index 6463dd6ea5..5372b6f28a 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/CatchRuleset__Tests_.xml @@ -1,6 +1,6 @@ -