From 97d65783dbe51988980324f18512bc7a92708e63 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jun 2019 12:48:45 +0900 Subject: [PATCH 1/5] Remove osu!-side DebugUtils --- osu.Desktop/Overlays/VersionManager.cs | 4 ++-- osu.Game/OsuGameBase.cs | 4 ++-- osu.Game/Overlays/Settings/SettingsFooter.cs | 4 ++-- osu.Game/Utils/DebugUtils.cs | 21 -------------------- 4 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 osu.Game/Utils/DebugUtils.cs diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 5a8cf32f14..1f1d2cea5f 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -12,7 +13,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; -using osu.Game.Utils; using osuTK; using osuTK.Graphics; @@ -61,7 +61,7 @@ private void load(NotificationOverlay notification, OsuColour colours, TextureSt }, new OsuSpriteText { - Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, + Colour = DebugUtils.IsDebugBuild ? colours.Red : Color4.White, Text = game.Version }, } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 637708a0e5..87ff721bbb 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.IO.Stores; @@ -34,7 +35,6 @@ using osu.Game.Scoring; using osu.Game.Skinning; using osuTK.Input; -using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game { @@ -97,7 +97,7 @@ public string Version get { if (!IsDeployedBuild) - return @"local " + (DebugUtils.IsDebug ? @"debug" : @"release"); + return @"local " + (DebugUtils.IsDebugBuild ? @"debug" : @"release"); var version = AssemblyVersion; return $@"{version.Major}.{version.Minor}.{version.Build}"; diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index b5ee4b4f0c..a815480094 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -12,7 +13,6 @@ using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; -using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game.Overlays.Settings { @@ -59,7 +59,7 @@ private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) Text = game.Name, Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), }, - new BuildDisplay(game.Version, DebugUtils.IsDebug) + new BuildDisplay(game.Version, DebugUtils.IsDebugBuild) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Utils/DebugUtils.cs b/osu.Game/Utils/DebugUtils.cs deleted file mode 100644 index 9b1d355a83..0000000000 --- a/osu.Game/Utils/DebugUtils.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Utils -{ - public static class DebugUtils - { - public static bool IsDebug - { - get - { - // ReSharper disable once RedundantAssignment - bool isDebug = false; - // Debug.Assert conditions are only evaluated in debug mode - System.Diagnostics.Debug.Assert(isDebug = true); - // ReSharper disable once ConditionIsAlwaysTrueOrFalse - return isDebug; - } - } - } -} From 52ca5f9c006a56e30f4e076f9925457ecccdd713 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jun 2019 23:06:07 +0900 Subject: [PATCH 2/5] Fix mod icons in ModSelect being loaded in a blocking fashion --- osu.Game/Overlays/Mods/ModSection.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 4c44aad87d..ba83af9f28 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -10,6 +10,7 @@ using System; using System.Linq; using System.Collections.Generic; +using System.Threading; using osu.Framework.Input.Events; using osu.Game.Graphics; @@ -33,6 +34,8 @@ public string Header public IEnumerable SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null); + private CancellationTokenSource modsLoadCts; + public IEnumerable Mods { set @@ -48,7 +51,9 @@ public IEnumerable Mods }; }).ToArray(); - ButtonsContainer.Children = modContainers; + modsLoadCts?.Cancel(); + LoadComponentsAsync(modContainers, c => ButtonsContainer.ChildrenEnumerable = c, (modsLoadCts = new CancellationTokenSource()).Token); + buttons = modContainers.OfType().ToArray(); if (value.Any()) From 7b4180ce86836d2bae532d9858265511f1b77fe9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jun 2019 23:51:47 +0900 Subject: [PATCH 3/5] Fix failing test --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index c04c7127fd..c3894471ee 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -232,10 +232,10 @@ private void testRankedText(Mod mod) private void checkSelected(Mod mod) { - AddAssert($"check {mod.Name} is selected", () => + AddUntilStep($"check {mod.Name} is selected", () => { var button = modSelect.GetModButton(mod); - return modSelect.SelectedMods.Value.Single(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected; + return modSelect.SelectedMods.Value.SingleOrDefault(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected; }); } From fa263b91a75456f09ca78b667f42b97b2d3ee09a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jun 2019 00:12:39 +0900 Subject: [PATCH 4/5] Attempt to fix tests --- .../TestSceneModSelectOverlay.cs | 19 ++++++++++++++----- osu.Game/Overlays/Mods/ModSection.cs | 13 ++++++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index c3894471ee..91446bddcf 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -216,13 +216,13 @@ private void testMultiplierTextColour(Mod mod, Color4 colour) private void testRankedText(Mod mod) { - AddWaitStep("wait for fade", 1); + waitForLoad(); AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0); selectNext(mod); - AddWaitStep("wait for fade", 1); + waitForLoad(); AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0); selectPrevious(mod); - AddWaitStep("wait for fade", 1); + waitForLoad(); AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0); } @@ -232,15 +232,22 @@ private void testRankedText(Mod mod) private void checkSelected(Mod mod) { - AddUntilStep($"check {mod.Name} is selected", () => + waitForLoad(); + AddAssert($"check {mod.Name} is selected", () => { var button = modSelect.GetModButton(mod); - return modSelect.SelectedMods.Value.SingleOrDefault(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected; + return modSelect.SelectedMods.Value.Single(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected; }); } + private void waitForLoad() + { + AddAssert("wait for icons to load", () => modSelect.AllLoaded); + } + private void checkNotSelected(Mod mod) { + waitForLoad(); AddAssert($"check {mod.Name} is not selected", () => { var button = modSelect.GetModButton(mod); @@ -254,6 +261,8 @@ private class TestModSelectOverlay : ModSelectOverlay { public new Bindable> SelectedMods => base.SelectedMods; + public bool AllLoaded => ModSectionsContainer.Children.All(c => c.ModIconsLoaded); + public ModButton GetModButton(Mod mod) { var section = ModSectionsContainer.Children.Single(s => s.ModType == mod.Type); diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index ba83af9f28..dedd397fa5 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -36,6 +36,11 @@ public string Header private CancellationTokenSource modsLoadCts; + /// + /// True when all mod icons have completed loading. + /// + public bool ModIconsLoaded { get; private set; } = true; + public IEnumerable Mods { set @@ -52,7 +57,13 @@ public IEnumerable Mods }).ToArray(); modsLoadCts?.Cancel(); - LoadComponentsAsync(modContainers, c => ButtonsContainer.ChildrenEnumerable = c, (modsLoadCts = new CancellationTokenSource()).Token); + ModIconsLoaded = false; + + LoadComponentsAsync(modContainers, c => + { + ModIconsLoaded = true; + ButtonsContainer.ChildrenEnumerable = c; + }, (modsLoadCts = new CancellationTokenSource()).Token); buttons = modContainers.OfType().ToArray(); From fa94f063be2321a62db2c80570605eab1eb47ee6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jun 2019 00:26:55 +0900 Subject: [PATCH 5/5] Use correct button type --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 91446bddcf..5a903b9417 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -242,7 +242,7 @@ private void checkSelected(Mod mod) private void waitForLoad() { - AddAssert("wait for icons to load", () => modSelect.AllLoaded); + AddUntilStep("wait for icons to load", () => modSelect.AllLoaded); } private void checkNotSelected(Mod mod)