From 9497db0b0bb38e35c73f6ab6db54d9d09cfc22c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 20:21:25 +0900 Subject: [PATCH 01/17] Add a delay before the loading logo is displayed --- osu.Game/Screens/Loader.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index fb5c5ca84b..28b139c9f9 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -36,7 +36,13 @@ namespace osu.Game.Screens logo.Position = new Vector2(-40); logo.Scale = new Vector2(0.2f); - logo.FadeInFromZero(5000, Easing.OutQuint); + logo.Delay(500).FadeInFromZero(1000, Easing.OutQuint); + } + + protected override void LogoSuspending(OsuLogo logo) + { + base.LogoSuspending(logo); + logo.FadeOut(logo.Alpha * 1000); } private OsuScreen loadScreen; @@ -63,12 +69,6 @@ namespace osu.Game.Screens Push(loadScreen); } - protected override void LogoSuspending(OsuLogo logo) - { - base.LogoSuspending(logo); - logo.FadeOut(100); - } - [BackgroundDependencyLoader] private void load(OsuGameBase game) { From 9ea6ab28ea45ce90de2471f22a1b20de8ce44b5b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 20:21:53 +0900 Subject: [PATCH 02/17] Fix intro potentially starting out-of-sync due to logo's outward animation --- osu.Game/Screens/Menu/Intro.cs | 48 ++++++++++++++++------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c174e2d470..5aca184d24 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -79,31 +79,6 @@ namespace osu.Game.Screens.Menu seeya = audio.Sample.Get(@"seeya"); } - protected override void OnEntering(Screen last) - { - base.OnEntering(last); - - Game.Beatmap.Value = beatmap; - - if (menuVoice) - 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 Manu. - if (menuMusic) - track.Start(); - - LoadComponentAsync(mainMenu = new MainMenu()); - - Scheduler.AddDelayed(delegate - { - DidLoadMenu = true; - Push(mainMenu); - }, delay_step_one); - }, delay_step_two); - } - private const double delay_step_one = 2300; private const double delay_step_two = 600; @@ -113,6 +88,29 @@ namespace osu.Game.Screens.Menu { base.LogoArriving(logo, resuming); + if (!resuming) + { + Game.Beatmap.Value = beatmap; + + if (menuVoice) + 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 Manu. + if (menuMusic) + track.Start(); + + LoadComponentAsync(mainMenu = new MainMenu()); + + Scheduler.AddDelayed(delegate + { + DidLoadMenu = true; + Push(mainMenu); + }, delay_step_one); + }, delay_step_two); + } + logo.RelativePositionAxes = Axes.Both; logo.Colour = Color4.White; logo.Ripple = false; From c161d8247479f401b0719b029459a9107ef3705f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:14:04 +0900 Subject: [PATCH 03/17] Reduce the length of the fadeout animation --- osu.Game/Screens/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 28b139c9f9..c8a80d470b 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens protected override void LogoSuspending(OsuLogo logo) { base.LogoSuspending(logo); - logo.FadeOut(logo.Alpha * 1000); + logo.FadeOut(logo.Alpha * 400); } private OsuScreen loadScreen; From 7487c82ec151b2b3a9fffc7adc260f87794ce182 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:14:47 +0900 Subject: [PATCH 04/17] Stop the logo from beating --- osu.Game/Screens/Loader.cs | 1 + osu.Game/Screens/Menu/OsuLogo.cs | 4 ++++ osu.Game/Screens/OsuScreen.cs | 1 + 3 files changed, 6 insertions(+) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index c8a80d470b..b8c1c31b8c 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -30,6 +30,7 @@ namespace osu.Game.Screens { base.LogoArriving(logo, resuming); + logo.BeatMatching = false; logo.Triangles = false; logo.Origin = Anchor.BottomRight; logo.Anchor = Anchor.BottomRight; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 42a8dbd5da..16482b0e48 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -64,6 +64,8 @@ namespace osu.Game.Screens.Menu set { colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } } + public bool BeatMatching = true; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => logoContainer.ReceiveMouseInputAt(screenSpacePos); public bool Ripple @@ -264,6 +266,8 @@ namespace osu.Game.Screens.Menu { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + if (!BeatMatching) return; + lastBeatIndex = beatIndex; var beatLength = timingPoint.BeatLength; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index db9807b9ab..7f68e5144b 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -225,6 +225,7 @@ namespace osu.Game.Screens logo.Anchor = Anchor.TopLeft; logo.Origin = Anchor.Centre; logo.RelativePositionAxes = Axes.None; + logo.BeatMatching = true; logo.Triangles = true; logo.Ripple = true; } From dfbcf4d7b7df2cde7194ea952a2eec221b81cd87 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:29:59 +0900 Subject: [PATCH 05/17] Add tests --- .../Visual/TestCaseLoaderAnimation.cs | 101 ++++++++++++++++++ osu.Game/Screens/Loader.cs | 4 +- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs diff --git a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs new file mode 100644 index 0000000000..066efb5116 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs @@ -0,0 +1,101 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Threading; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Game.Screens; +using osu.Game.Screens.Menu; +using OpenTK.Graphics; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseLoaderAnimation : OsuTestCase + { + private TestLoader loader; + + public TestCaseLoaderAnimation() + { + bool logoVisible = false; + + AddStep("almost instant display", () => Child = loader = new TestLoader(0.25f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo not visible", () => !logoVisible); + + AddStep("short load", () => Child = loader = new TestLoader(0.8f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo visible", () => logoVisible); + AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + + AddStep("longer load", () => Child = loader = new TestLoader(1.4f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo visible", () => logoVisible); + AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + } + + private class TestLoader : Loader + { + private readonly float secondsDelay; + + public OsuLogo Logo; + + public TestLoader(float secondsDelay) + { + this.secondsDelay = secondsDelay; + } + + protected override void LogoArriving(OsuLogo logo, bool resuming) + { + Logo = logo; + base.LogoArriving(logo, resuming); + } + + protected override OsuScreen CreateLoadableScreen() => new TestScreen(secondsDelay); + + private class TestScreen : OsuScreen + { + private readonly float secondsDelay; + + public TestScreen(float secondsDelay) + { + this.secondsDelay = secondsDelay; + + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.DarkSlateGray, + Alpha = 0, + }; + } + + [BackgroundDependencyLoader] + private void load() + { + Thread.Sleep((int)(secondsDelay * 1000)); + } + + protected override void LogoArriving(OsuLogo logo, bool resuming) + { + base.LogoArriving(logo, resuming); + + Child.FadeInFromZero(200); + } + } + } + } +} diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index b8c1c31b8c..6335700a8f 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -49,12 +49,14 @@ namespace osu.Game.Screens private OsuScreen loadScreen; private ShaderPrecompiler precompiler; + protected virtual OsuScreen CreateLoadableScreen() => showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(); + protected override void OnEntering(Screen last) { base.OnEntering(last); LoadComponentAsync(precompiler = new ShaderPrecompiler(loadIfReady), Add); - LoadComponentAsync(loadScreen = showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(), s => loadIfReady()); + LoadComponentAsync(loadScreen = CreateLoadableScreen(), s => loadIfReady()); } private void loadIfReady() From b68a5f5eabb589b787a844d96d0606915f44d55d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 20:07:44 +0900 Subject: [PATCH 06/17] Tidy up Loader logic --- osu.Game/Screens/Loader.cs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 6335700a8f..c3b3e747fd 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -46,30 +45,32 @@ namespace osu.Game.Screens logo.FadeOut(logo.Alpha * 400); } - private OsuScreen loadScreen; + private OsuScreen loadableScreen; private ShaderPrecompiler precompiler; protected virtual OsuScreen CreateLoadableScreen() => showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(); + protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler(); + protected override void OnEntering(Screen last) { base.OnEntering(last); - LoadComponentAsync(precompiler = new ShaderPrecompiler(loadIfReady), Add); - LoadComponentAsync(loadScreen = CreateLoadableScreen(), s => loadIfReady()); + LoadComponentAsync(precompiler = CreateShaderPrecompiler(), Add); + LoadComponentAsync(loadableScreen = CreateLoadableScreen()); + + checkIfLoaded(); } - private void loadIfReady() + private void checkIfLoaded() { - if (ChildScreen == loadScreen) return; - - if (loadScreen.LoadState != LoadState.Ready) + if (loadableScreen.LoadState != LoadState.Ready || !precompiler.FinishedCompiling) + { + Schedule(checkIfLoaded); return; + } - if (!precompiler.FinishedCompiling) - return; - - Push(loadScreen); + Push(loadableScreen); } [BackgroundDependencyLoader] @@ -83,16 +84,10 @@ namespace osu.Game.Screens /// public class ShaderPrecompiler : Drawable { - private readonly Action onLoaded; private readonly List loadTargets = new List(); public bool FinishedCompiling { get; private set; } - public ShaderPrecompiler(Action onLoaded) - { - this.onLoaded = onLoaded; - } - [BackgroundDependencyLoader] private void load(ShaderManager manager) { @@ -106,16 +101,17 @@ namespace osu.Game.Screens loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE)); } + protected virtual bool AllLoaded => loadTargets.All(s => s.Loaded); + protected override void Update() { base.Update(); // if our target is null we are done. - if (loadTargets.All(s => s.Loaded)) + if (AllLoaded) { FinishedCompiling = true; Expire(); - onLoaded?.Invoke(); } } } From a6f2561be83855dd1075495cc8a44cf5bb173c70 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 20:07:55 +0900 Subject: [PATCH 07/17] Fix automated testing --- .../Visual/TestCaseLoaderAnimation.cs | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs index 066efb5116..600784f8db 100644 --- a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs +++ b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs @@ -1,9 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading; using NUnit.Framework; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Screens; @@ -17,46 +15,53 @@ namespace osu.Game.Tests.Visual { private TestLoader loader; - public TestCaseLoaderAnimation() + protected override void LoadComplete() { - bool logoVisible = false; + base.LoadComplete(); - AddStep("almost instant display", () => Child = loader = new TestLoader(0.25f)); + // required to preload the logo in a headless run (so it doesn't delay the loading itself). + Add(new OsuLogo()); + + bool logoVisible = false; + AddStep("almost instant display", () => Child = loader = new TestLoader(250)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo not visible", () => !logoVisible); - AddStep("short load", () => Child = loader = new TestLoader(0.8f)); + AddStep("short load", () => Child = loader = new TestLoader(800)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo visible", () => logoVisible); - AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone"); - AddStep("longer load", () => Child = loader = new TestLoader(1.4f)); + AddStep("longer load", () => Child = loader = new TestLoader(1400)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo visible", () => logoVisible); - AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone"); } private class TestLoader : Loader { - private readonly float secondsDelay; + private readonly double delay; public OsuLogo Logo; + private TestScreen screen; - public TestLoader(float secondsDelay) + public bool ScreenLoaded => screen.IsCurrentScreen; + + public TestLoader(double delay) { - this.secondsDelay = secondsDelay; + this.delay = delay; } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -65,16 +70,32 @@ namespace osu.Game.Tests.Visual base.LogoArriving(logo, resuming); } - protected override OsuScreen CreateLoadableScreen() => new TestScreen(secondsDelay); + protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen(); + protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(delay); + + private class TestShaderPrecompiler : ShaderPrecompiler + { + private readonly double delay; + private double startTime; + + public TestShaderPrecompiler(double delay) + { + this.delay = delay; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + startTime = Time.Current; + } + + protected override bool AllLoaded => Time.Current > startTime + delay; + } private class TestScreen : OsuScreen { - private readonly float secondsDelay; - - public TestScreen(float secondsDelay) + public TestScreen() { - this.secondsDelay = secondsDelay; - Child = new Box { RelativeSizeAxes = Axes.Both, @@ -83,16 +104,9 @@ namespace osu.Game.Tests.Visual }; } - [BackgroundDependencyLoader] - private void load() - { - Thread.Sleep((int)(secondsDelay * 1000)); - } - protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); - Child.FadeInFromZero(200); } } From b4d621a2cb15f54ad4103bc17da019e0533db160 Mon Sep 17 00:00:00 2001 From: Joehu Date: Thu, 31 May 2018 10:21:22 -0700 Subject: [PATCH 08/17] Add link colour to beatmap source --- osu.Game/Overlays/BeatmapSet/Info.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDetails.cs | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index cd0b7386e8..e10294bbce 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,8 +135,8 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - source.TextColour = description.TextColour = colours.Gray5; - tags.TextColour = colours.BlueDark; + description.TextColour = colours.Gray5; + source.TextColour = tags.TextColour = colours.BlueDark; updateDisplay(); } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index ca36f94eda..69f3cf0ae6 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -124,10 +124,7 @@ namespace osu.Game.Screens.Select { TextColour = Color4.White.Opacity(0.75f), }, - source = new MetadataSection("Source") - { - TextColour = Color4.White.Opacity(0.75f), - }, + source = new MetadataSection("Source"), tags = new MetadataSection("Tags"), }, }, @@ -167,7 +164,7 @@ namespace osu.Game.Screens.Select private void load(OsuColour colours, APIAccess api) { this.api = api; - tags.TextColour = colours.Yellow; + source.TextColour = tags.TextColour = colours.Yellow; } protected override void UpdateAfterChildren() From 5c2a2e394e2bff3b8a2a014c75c26218822423e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Jun 2018 18:03:16 +0900 Subject: [PATCH 09/17] Fix incorrect async logic in BeatmapInfoWedge Closes #2653. Alternative to #2657. --- .../Visual/TestCaseBeatmapInfoWedge.cs | 6 +- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 66 +++++++++++-------- osu.Game/Screens/Select/SongSelect.cs | 2 +- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs index 0d3e08154f..996c3b8695 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual AddStep("show", () => { infoWedge.State = Visibility.Visible; - infoWedge.UpdateBeatmap(beatmap); + infoWedge.Beatmap = beatmap; }); // select part is redundant, but wait for load isn't @@ -133,7 +133,7 @@ namespace osu.Game.Tests.Visual AddStep($"select {b.Metadata.Title} beatmap", () => { infoBefore = infoWedge.Info; - infoWedge.UpdateBeatmap(beatmap.Value = new TestWorkingBeatmap(b)); + infoWedge.Beatmap = beatmap.Value = new TestWorkingBeatmap(b); }); AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load"); @@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual AddStep("select null beatmap", () => { beatmap.Value = beatmap.Default; - infoWedge.UpdateBeatmap(beatmap); + infoWedge.Beatmap = beatmap; }); } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 97f6371cb2..7950018554 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Select { if (osuGame != null) ruleset.BindTo(osuGame.Ruleset); - ruleset.ValueChanged += updateRuleset; + ruleset.ValueChanged += _ => updateDisplay(); } protected override bool BlockPassThroughMouse => false; @@ -78,66 +78,76 @@ namespace osu.Game.Screens.Select private WorkingBeatmap beatmap; - public void UpdateBeatmap(WorkingBeatmap beatmap) + public WorkingBeatmap Beatmap { - this.beatmap = beatmap; - loadBeatmap(); + get => beatmap; + set + { + if (beatmap == value) return; + + beatmap = value; + updateDisplay(); + } } - private void updateRuleset(RulesetInfo ruleset) => loadBeatmap(); + private BufferedWedgeInfo loadingInfo; - private void loadBeatmap() + private void updateDisplay() { - void updateState() + void removeOldInfo() { State = beatmap == null ? Visibility.Hidden : Visibility.Visible; Info?.FadeOut(250); Info?.Expire(); + Info = null; } if (beatmap == null) { - updateState(); + removeOldInfo(); return; } - LoadComponentAsync(new BufferedWedgeInfo(beatmap, ruleset.Value) + LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value) { Shear = -Shear, - Depth = Info?.Depth + 1 ?? 0, - }, newInfo => + Depth = Info?.Depth + 1 ?? 0 + }, loaded => { - updateState(); - Add(Info = newInfo); + // ensure we are the most recent loaded wedge. + if (loaded != loadingInfo) return; + + removeOldInfo(); + Add(Info = loaded); }); } public class BufferedWedgeInfo : BufferedContainer { - private readonly WorkingBeatmap working; public OsuSpriteText VersionLabel { get; private set; } public OsuSpriteText TitleLabel { get; private set; } public OsuSpriteText ArtistLabel { get; private set; } public FillFlowContainer MapperContainer { get; private set; } public FillFlowContainer InfoLabelContainer { get; private set; } + private UnicodeBindableString titleBinding; private UnicodeBindableString artistBinding; + private readonly WorkingBeatmap beatmap; private readonly RulesetInfo ruleset; - public BufferedWedgeInfo(WorkingBeatmap working, RulesetInfo userRuleset) + public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset) { - this.working = working; - - ruleset = userRuleset ?? working.BeatmapInfo.Ruleset; + this.beatmap = beatmap; + ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset; } [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - var beatmapInfo = working.BeatmapInfo; - var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); + var beatmapInfo = beatmap.BeatmapInfo; + var metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); PixelSnapping = true; CacheDrawnFrameBuffer = true; @@ -165,7 +175,7 @@ namespace osu.Game.Screens.Select Children = new[] { // Zoomed-in and cropped beatmap background - new BeatmapBackgroundSprite(working) + new BeatmapBackgroundSprite(beatmap) { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -248,27 +258,27 @@ namespace osu.Game.Screens.Select private InfoLabel[] getInfoLabels() { - var beatmap = working.Beatmap; + var b = beatmap.Beatmap; List labels = new List(); - if (beatmap?.HitObjects?.Any() == true) + if (b?.HitObjects?.Any() == true) { - HitObject lastObject = beatmap.HitObjects.LastOrDefault(); + HitObject lastObject = b.HitObjects.LastOrDefault(); double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0; labels.Add(new InfoLabel(new BeatmapStatistic { Name = "Length", Icon = FontAwesome.fa_clock_o, - Content = TimeSpan.FromMilliseconds(endTime - beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"), + Content = TimeSpan.FromMilliseconds(endTime - b.HitObjects.First().StartTime).ToString(@"m\:ss"), })); labels.Add(new InfoLabel(new BeatmapStatistic { Name = "BPM", Icon = FontAwesome.fa_circle, - Content = getBPMRange(beatmap), + Content = getBPMRange(b), })); IBeatmap playableBeatmap; @@ -276,12 +286,12 @@ namespace osu.Game.Screens.Select try { // Try to get the beatmap with the user's ruleset - playableBeatmap = working.GetPlayableBeatmap(ruleset); + playableBeatmap = beatmap.GetPlayableBeatmap(ruleset); } catch (BeatmapInvalidForRulesetException) { // Can't be converted to the user's ruleset, so use the beatmap's own ruleset - playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset); + playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset); } labels.AddRange(playableBeatmap.GetStatistics().Select(s => new InfoLabel(s))); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e1271aebc4..41ba38cb0f 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -430,7 +430,7 @@ namespace osu.Game.Screens.Select backgroundModeBeatmap.FadeTo(1, 250); } - beatmapInfoWedge.UpdateBeatmap(beatmap); + beatmapInfoWedge.Beatmap = beatmap; } private void ensurePlayingSelected(bool preview = false) From dc2a004c8741aa043ffa7c549d275dc5a8e65e47 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 2 Jun 2018 12:04:58 -0700 Subject: [PATCH 10/17] Remove link colours for all unlinked text --- osu.Game/Overlays/BeatmapSet/Info.cs | 3 +-- osu.Game/Screens/Select/BeatmapDetails.cs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index e10294bbce..35a66b1272 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,8 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - description.TextColour = colours.Gray5; - source.TextColour = tags.TextColour = colours.BlueDark; + description.TextColour = source.TextColour = tags.TextColour = colours.Gray5; updateDisplay(); } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 69f3cf0ae6..013674b397 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using System.Linq; @@ -120,10 +119,7 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] { - description = new MetadataSection("Description") - { - TextColour = Color4.White.Opacity(0.75f), - }, + description = new MetadataSection("Description"), source = new MetadataSection("Source"), tags = new MetadataSection("Tags"), }, @@ -161,10 +157,10 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader] - private void load(OsuColour colours, APIAccess api) + private void load(APIAccess api) { this.api = api; - source.TextColour = tags.TextColour = colours.Yellow; + description.TextColour = source.TextColour = tags.TextColour = Color4.White.Opacity(0.75f); } protected override void UpdateAfterChildren() From 645f6efce78edc8699f9d47443c86cdca3a3b1cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 13:01:52 +0900 Subject: [PATCH 11/17] Fix web request failures not being correctly handled at an APIRequest level --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- osu.Game/Online/API/APIRequest.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index efc0279aa0..806bcc4132 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -170,7 +170,7 @@ namespace osu.Game.Beatmaps { if (error is OperationCanceledException) return; - downloadNotification.State = ProgressNotificationState.Completed; + downloadNotification.State = ProgressNotificationState.Cancelled; Logger.Error(error, "Beatmap download failed!"); currentDownloads.Remove(request); }; diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 9af142b9e8..dfd181b98a 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -73,6 +73,7 @@ namespace osu.Game.Online.API throw new TimeoutException(@"API request timeout hit"); WebRequest = CreateWebRequest(); + WebRequest.Failed += Fail; WebRequest.AllowRetryOnTimeout = false; WebRequest.AddHeader("Authorization", $"Bearer {api.AccessToken}"); From 3795a55808a2f4e591f9f0982efc2c53973b8ec1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 03:26:59 +0900 Subject: [PATCH 12/17] Fix menu flashes not extending to the edge of screen during parallax --- osu.Game/Screens/Menu/MenuSideFlashes.cs | 55 +++++++++++++----------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index fae3e72552..c321c98b24 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -24,8 +24,8 @@ namespace osu.Game.Screens.Menu private readonly Bindable beatmap = new Bindable(); - private readonly Box leftBox; - private readonly Box rightBox; + private Box leftBox; + private Box rightBox; private const float amplitude_dead_zone = 0.25f; private const float alpha_multiplier = (1 - amplitude_dead_zone) / 0.55f; @@ -42,27 +42,6 @@ namespace osu.Game.Screens.Menu RelativeSizeAxes = Axes.Both; Anchor = Anchor.Centre; Origin = Anchor.Centre; - Children = new Drawable[] - { - leftBox = new Box - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Y, - Width = box_width, - Alpha = 0, - Blending = BlendingMode.Additive, - }, - rightBox = new Box - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - RelativeSizeAxes = Axes.Y, - Width = box_width, - Alpha = 0, - Blending = BlendingMode.Additive, - } - }; } [BackgroundDependencyLoader] @@ -72,10 +51,34 @@ namespace osu.Game.Screens.Menu // linear colour looks better in this case, so let's use it for now. Color4 gradientDark = colours.Blue.Opacity(0).ToLinear(); - Color4 gradientLight = colours.Blue.Opacity(0.3f).ToLinear(); + Color4 gradientLight = colours.Blue.Opacity(0.6f).ToLinear(); - leftBox.Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark); - rightBox.Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight); + Children = new Drawable[] + { + leftBox = new Box + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Y, + Width = box_width * 2, + // align off-screen to make sure our edges don't become visible during parallax. + X = -box_width, + Alpha = 0, + Blending = BlendingMode.Additive, + Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark) + }, + rightBox = new Box + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + RelativeSizeAxes = Axes.Y, + Width = box_width * 2, + X = box_width, + Alpha = 0, + Blending = BlendingMode.Additive, + Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight) + } + }; } protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) From 5c713ac2ababa6eb8f9b2db9ae8cb2a6d3cb9007 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 07:51:57 -0700 Subject: [PATCH 13/17] Use default colour in MetadataSection --- osu.Game/Overlays/BeatmapSet/Info.cs | 3 +-- osu.Game/Screens/Select/BeatmapDetails.cs | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 35a66b1272..e962c885ba 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,7 +135,6 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - description.TextColour = source.TextColour = tags.TextColour = colours.Gray5; updateDisplay(); } @@ -194,7 +193,7 @@ namespace osu.Game.Overlays.BeatmapSet [BackgroundDependencyLoader] private void load(OsuColour colours) { - header.Colour = colours.Gray5; + header.Colour = textFlow.Colour = colours.Gray5; } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 013674b397..68e308783e 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -160,7 +160,6 @@ namespace osu.Game.Screens.Select private void load(APIAccess api) { this.api = api; - description.TextColour = source.TextColour = tags.TextColour = Color4.White.Opacity(0.75f); } protected override void UpdateAfterChildren() @@ -374,6 +373,12 @@ namespace osu.Game.Screens.Select get { return textFlow.Colour; } set { textFlow.Colour = value; } } + + [BackgroundDependencyLoader] + private void load() + { + textFlow.Colour = Color4.White.Opacity(0.75f); + } } private class DimmedLoadingAnimation : VisibilityContainer From 7101533926317b26f22ef91f8bfba4d3273f3815 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 08:02:57 -0700 Subject: [PATCH 14/17] Remove 'description' field --- osu.Game/Overlays/BeatmapSet/Info.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index e962c885ba..53216ad666 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet private const float metadata_width = 225; private const float spacing = 20; - private readonly MetadataSection description, source, tags; + private readonly MetadataSection source, tags; private readonly Box successRateBackground; private readonly SuccessRate successRate; @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet Child = new Container { RelativeSizeAxes = Axes.Both, - Child = description = new MetadataSection("Description"), + Child = new MetadataSection("Description"), }, }, new Container From bd7c9cd8bffcf880518b0cc8159a3f32ab5f2fc6 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 17:41:34 -0700 Subject: [PATCH 15/17] Set 'Colour' when creating 'textFlow' --- osu.Game/Screens/Select/BeatmapDetails.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 68e308783e..f1bd2b945f 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -356,7 +356,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Colour = textFlow.Colour, + Colour = Color4.White.Opacity(0.75f), Text = text }, loaded => { @@ -367,18 +367,6 @@ namespace osu.Game.Screens.Select this.FadeIn(transition_duration); }); } - - public Color4 TextColour - { - get { return textFlow.Colour; } - set { textFlow.Colour = value; } - } - - [BackgroundDependencyLoader] - private void load() - { - textFlow.Colour = Color4.White.Opacity(0.75f); - } } private class DimmedLoadingAnimation : VisibilityContainer From db4c26e1ab5371ea7307f3c1e8c358143eef39d1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 3 Jun 2018 22:22:44 -0300 Subject: [PATCH 16/17] Rewrite ScoreComponentLabel. --- .../Select/Leaderboards/LeaderboardScore.cs | 74 ++++++++++++------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index baab973ae5..c39c4e43d3 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -142,6 +142,8 @@ namespace osu.Game.Screens.Select.Leaderboards { flagBadgeContainer = new Container { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, Size = new Vector2(87f, 20f), Masking = true, Children = new Drawable[] @@ -155,10 +157,12 @@ namespace osu.Game.Screens.Select.Leaderboards }, new FillFlowContainer { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10f, 0f), - Margin = new MarginPadding { Left = edge_margin, }, + Margin = new MarginPadding { Left = edge_margin }, Children = new Drawable[] { maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()), @@ -307,35 +311,55 @@ namespace osu.Game.Screens.Select.Leaderboards private class ScoreComponentLabel : Container { + private const float icon_size = 20; + + private readonly FillFlowContainer content; + + protected override Container Content => content; + public ScoreComponentLabel(FontAwesome icon, string value) { - Anchor = Anchor.CentreLeft; - Origin = Anchor.CentreLeft; - Size = new Vector2(60f, 20f); - Padding = new MarginPadding { Top = 10f, }; + AutoSizeAxes = Axes.Y; + Width = 60; - Children = new Drawable[] + InternalChild = content = new FillFlowContainer { - new SpriteIcon + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new Drawable[] { - Origin = Anchor.Centre, - Icon = FontAwesome.fa_square, - Colour = OsuColour.FromHex(@"3087ac"), - Rotation = 45, - Size = new Vector2(20), - Shadow = true, - }, - new SpriteIcon - { - Origin = Anchor.Centre, - Icon = icon, - Colour = OsuColour.FromHex(@"a4edff"), - Size = new Vector2(14), - }, - new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) - { - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 15, }, + new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size), + Rotation = 45, + Colour = OsuColour.FromHex(@"3087ac"), + Icon = FontAwesome.fa_square, + Shadow = true, + }, + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size - 6), + Colour = OsuColour.FromHex(@"a4edff"), + Icon = icon, + }, + }, + }, + new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, }, }; } From a7bab14b303b70e59aa333519a7db16601b312ff Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 3 Jun 2018 22:26:30 -0300 Subject: [PATCH 17/17] Add tooltip to ScoreComponentLabel. --- .../Select/Leaderboards/LeaderboardScore.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index c39c4e43d3..19732107c7 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; @@ -165,8 +166,8 @@ namespace osu.Game.Screens.Select.Leaderboards Margin = new MarginPadding { Left = edge_margin }, Children = new Drawable[] { - maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()), - accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy)), + maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString(), "Max Combo"), + accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy), "Accuracy"), }, }, }, @@ -309,20 +310,24 @@ namespace osu.Game.Screens.Select.Leaderboards } } - private class ScoreComponentLabel : Container + private class ScoreComponentLabel : Container, IHasTooltip { private const float icon_size = 20; + private readonly string name; private readonly FillFlowContainer content; - protected override Container Content => content; + public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos); - public ScoreComponentLabel(FontAwesome icon, string value) + public string TooltipText => name; + + public ScoreComponentLabel(FontAwesome icon, string value, string name) { + this.name = name; AutoSizeAxes = Axes.Y; Width = 60; - InternalChild = content = new FillFlowContainer + Child = content = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal,