From 65097fddc154808e06546d53595b3f5fe786e01a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 May 2019 22:34:36 +0900 Subject: [PATCH 01/10] Hide music controller when exiting via Alt-F4 Closes #4764. --- osu.Game/OsuGame.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7b2a8184d1..a431802a1d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -147,12 +147,17 @@ namespace osu.Game /// /// Close all game-wide overlays. /// - /// Whether the toolbar should also be hidden. - public void CloseAllOverlays(bool toolbar = true) + /// Whether the toolbar (and accompanying controls) should also be hidden. + public void CloseAllOverlays(bool hideToolbarElements = true) { foreach (var overlay in overlays) overlay.State = Visibility.Hidden; - if (toolbar) Toolbar.State = Visibility.Hidden; + + if (hideToolbarElements) + { + Toolbar.State = Visibility.Hidden; + musicController.State = Visibility.Hidden; + } } private DependencyContainer dependencies; From ad5ad8ccb5eaf4c05eb17e43d16560a2b82b3b37 Mon Sep 17 00:00:00 2001 From: Alten Date: Mon, 13 May 2019 23:29:24 -0400 Subject: [PATCH 02/10] Fix hard crash --- osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs index 17fffbd974..b7df4f2f2b 100644 --- a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs @@ -63,8 +63,13 @@ namespace osu.Game.Rulesets.Osu.UI { get { - var first = (OsuHitObject)Objects.First(); - return first.StartTime - Math.Max(2000, first.TimePreempt); + if (Objects.Any()) + { + var first = (OsuHitObject)Objects.First(); + return first.StartTime - Math.Max(2000, first.TimePreempt); + } + + return 0; } } } From 0d57cf659921006ebd311e4b31375867a0655d5f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 13:13:51 +0900 Subject: [PATCH 03/10] Remember FPS display state after changing via Ctrl+F11 hotkey --- osu.Game/OsuGameBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 66552c43e0..c068c5b0d4 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -220,8 +220,10 @@ namespace osu.Game // TODO: This is temporary until we reimplement the local FPS display. // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. fpsDisplayVisible = LocalConfig.GetBindable(OsuSetting.ShowFpsDisplay); - fpsDisplayVisible.ValueChanged += visible => { FrameStatisticsMode = visible.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; + fpsDisplayVisible.ValueChanged += visible => { FrameStatistics.Value = visible.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; fpsDisplayVisible.TriggerChange(); + + FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None; } private void runMigrations() From ec5b024fa605bce0706d0f608b1dcb2dfade6691 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 18:34:25 +0900 Subject: [PATCH 04/10] Define toolbarElements --- osu.Game/OsuGame.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c1004ce5eb..1f4b78f5fb 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -99,6 +99,8 @@ namespace osu.Game private readonly List overlays = new List(); + private readonly List toolbarElements = new List(); + private readonly List visibleBlockingOverlays = new List(); // todo: move this to SongSelect once Screen has the ability to unsuspend. @@ -142,8 +144,8 @@ namespace osu.Game if (hideToolbarElements) { - Toolbar.State = Visibility.Hidden; - musicController.State = Visibility.Hidden; + foreach (var overlay in toolbarElements) + overlay.State = Visibility.Hidden; } } @@ -420,7 +422,11 @@ namespace osu.Game CloseAllOverlays(false); menuScreen?.MakeCurrent(); }, - }, topMostOverlayContent.Add); + }, d => + { + topMostOverlayContent.Add(d); + toolbarElements.Add(d); + }); loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add); loadComponentSingleFile(new OnScreenDisplay(), Add, true); @@ -455,7 +461,11 @@ namespace osu.Game GetToolbarHeight = () => ToolbarOffset, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - }, rightFloatingOverlayContent.Add, true); + }, d => + { + rightFloatingOverlayContent.Add(d); + toolbarElements.Add(d); + }, true); loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); From f2e5beec11f86959985d4ed35e1feb53e5bc8606 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 18:35:35 +0900 Subject: [PATCH 05/10] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8f733a5c55..66d298f8c1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index e5b4d61615..ccec475d98 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From d5e25c05b3b6ccdea3bce018e835db72b7053f90 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 14 May 2019 18:39:03 +0900 Subject: [PATCH 06/10] Increase loader animation test wait --- osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs index eb275cbceb..3f0d965c99 100644 --- a/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs +++ b/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Menus bool logoVisible = false; AddStep("begin loading", () => LoadScreen(loader = new TestLoader())); - AddWaitStep("wait", 2); + AddWaitStep("wait", 3); AddStep("finish loading", () => { logoVisible = loader.Logo?.Alpha > 0; From 4c221e43a97d412ce237012a3e289432d9aed2da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 18:39:56 +0900 Subject: [PATCH 07/10] Apply minimal changes to make framework compile --- .../Visual/UserInterface/TestCaseLoadingAnimation.cs | 2 +- .../Visual/UserInterface/TestCaseOsuIcon.cs | 3 +-- osu.Game/Tests/Visual/OsuTestCase.cs | 12 ++++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseLoadingAnimation.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseLoadingAnimation.cs index 43f6f0e4db..1cfd56e2c8 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseLoadingAnimation.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseLoadingAnimation.cs @@ -9,7 +9,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { - public class TestCaseLoadingAnimation : GridTestCase + public class TestCaseLoadingAnimation : GridTestScene //todo: this should be an OsuTestCase { public TestCaseLoadingAnimation() : base(2, 2) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs index a57e11cb0c..cef122ff58 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Testing; using osu.Game.Graphics; using osuTK; using osuTK.Graphics; @@ -17,7 +16,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { [TestFixture] - public class TestCaseOsuIcon : TestCase + public class TestCaseOsuIcon : OsuTestCase { public TestCaseOsuIcon() { diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 1f475209a4..3a40db4571 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -15,7 +15,7 @@ using osu.Game.Rulesets.Mods; namespace osu.Game.Tests.Visual { - public abstract class OsuTestCase : TestCase + public abstract class OsuTestCase : TestScene { [Cached(typeof(Bindable))] [Cached(typeof(IBindable))] @@ -76,21 +76,21 @@ namespace osu.Game.Tests.Visual } } - protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner(); + protected override ITestSceneTestRunner CreateRunner() => new OsuTestCaseTestRunner(); - public class OsuTestCaseTestRunner : OsuGameBase, ITestCaseTestRunner + public class OsuTestCaseTestRunner : OsuGameBase, ITestSceneTestRunner { - private TestCaseTestRunner.TestRunner runner; + private TestSceneTestRunner.TestRunner runner; protected override void LoadAsyncComplete() { // this has to be run here rather than LoadComplete because // TestCase.cs is checking the IsLoaded state (on another thread) and expects // the runner to be loaded at that point. - Add(runner = new TestCaseTestRunner.TestRunner()); + Add(runner = new TestSceneTestRunner.TestRunner()); } - public void RunTestBlocking(TestCase test) => runner.RunTestBlocking(test); + public void RunTestBlocking(TestScene test) => runner.RunTestBlocking(test); } private class OsuTestBeatmap : BindableBeatmap From 37ec722a1d075a0910aa460c0a956f165e2805c8 Mon Sep 17 00:00:00 2001 From: Alten Date: Tue, 14 May 2019 16:18:46 -0400 Subject: [PATCH 08/10] Shorten code --- osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs index b7df4f2f2b..1630370bd1 100644 --- a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs @@ -63,13 +63,10 @@ namespace osu.Game.Rulesets.Osu.UI { get { - if (Objects.Any()) - { - var first = (OsuHitObject)Objects.First(); + if (Objects.FirstOrDefault() is OsuHitObject first) return first.StartTime - Math.Max(2000, first.TimePreempt); - } - - return 0; + else + return 0; } } } From cbf662eb566c97703d1e5905fb33256b1ae79292 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 15 May 2019 10:55:02 +0900 Subject: [PATCH 09/10] Remove redundant else statement --- osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs index 1630370bd1..d185d7d4c9 100644 --- a/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/UI/DrawableOsuRuleset.cs @@ -65,8 +65,8 @@ namespace osu.Game.Rulesets.Osu.UI { if (Objects.FirstOrDefault() is OsuHitObject first) return first.StartTime - Math.Max(2000, first.TimePreempt); - else - return 0; + + return 0; } } } From 1fd44d7945c1513844b7704b9e86c7d2da1bd580 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 13:00:11 +0900 Subject: [PATCH 10/10] Move OsuScreenDependencies to GameBase --- osu.Game.Tests/Visual/TestCaseOsuGame.cs | 29 +++++++++++++++++++----- osu.Game/OsuGame.cs | 23 +++++-------------- osu.Game/OsuGameBase.cs | 12 +++++++++- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseOsuGame.cs b/osu.Game.Tests/Visual/TestCaseOsuGame.cs index dd98ff088c..b87ea433fe 100644 --- a/osu.Game.Tests/Visual/TestCaseOsuGame.cs +++ b/osu.Game.Tests/Visual/TestCaseOsuGame.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -23,6 +22,7 @@ using osu.Game.Online.API; using osu.Game.Online.Chat; using osu.Game.Overlays; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens.Menu; using osu.Game.Skinning; @@ -43,8 +43,6 @@ namespace osu.Game.Tests.Visual { typeof(OsuGame), typeof(RavenLogger), - typeof(Bindable), - typeof(IBindable), typeof(OsuLogo), typeof(IdleTracker), typeof(OnScreenDisplay), @@ -60,12 +58,17 @@ namespace osu.Game.Tests.Visual typeof(MusicController), typeof(AccountCreationOverlay), typeof(DialogOverlay), + typeof(ScreenshotManager) }; private IReadOnlyList requiredGameBaseDependencies => new[] { typeof(OsuGameBase), typeof(DatabaseContextFactory), + typeof(Bindable), + typeof(IBindable), + typeof(Bindable>), + typeof(IBindable>), typeof(LargeTextureStore), typeof(OsuConfigManager), typeof(SkinManager), @@ -86,7 +89,7 @@ namespace osu.Game.Tests.Visual }; [BackgroundDependencyLoader] - private void load(GameHost host) + private void load(GameHost host, OsuGameBase gameBase) { OsuGame game = new OsuGame(); game.SetHost(host); @@ -103,8 +106,22 @@ namespace osu.Game.Tests.Visual AddUntilStep("wait for load", () => game.IsLoaded); - AddAssert("check OsuGame DI members", () => requiredGameDependencies.All(d => game.Dependencies.Get(d) != null)); - AddAssert("check OsuGameBase DI members", () => requiredGameBaseDependencies.All(d => Dependencies.Get(d) != null)); + AddAssert("check OsuGame DI members", () => + { + foreach (var type in requiredGameDependencies) + if (game.Dependencies.Get(type) == null) + throw new Exception($"{type} has not been cached"); + + return true; + }); + AddAssert("check OsuGameBase DI members", () => + { + foreach (var type in requiredGameBaseDependencies) + if (gameBase.Dependencies.Get(type) == null) + throw new Exception($"{type} has not been cached"); + + return true; + }); } } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1f4b78f5fb..d108bb45f3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -31,11 +31,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Input; using osu.Game.Overlays.Notifications; -using osu.Game.Rulesets; using osu.Game.Screens.Play; using osu.Game.Input.Bindings; using osu.Game.Online.Chat; -using osu.Game.Rulesets.Mods; using osu.Game.Skinning; using osuTK.Graphics; using osu.Game.Overlays.Volume; @@ -89,7 +87,6 @@ namespace osu.Game private Intro introScreen; private Bindable configRuleset; - private readonly Bindable ruleset = new Bindable(); private Bindable configSkin; @@ -103,11 +100,6 @@ namespace osu.Game private readonly List visibleBlockingOverlays = new List(); - // todo: move this to SongSelect once Screen has the ability to unsuspend. - [Cached] - [Cached(typeof(IBindable>))] - private readonly Bindable> mods = new Bindable>(Array.Empty()); - public OsuGame(string[] args = null) { this.args = args; @@ -176,15 +168,12 @@ namespace osu.Game dependencies.Cache(RavenLogger); - dependencies.CacheAs(ruleset); - dependencies.CacheAs>(ruleset); - dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 }); // bind config int to database RulesetInfo configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); - ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First(); - ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0; + Ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First(); + Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0; // bind config int to database SkinInfo configSkin = LocalConfig.GetBindable(OsuSetting.Skin); @@ -255,9 +244,9 @@ namespace osu.Game } // Use first beatmap available for current ruleset, else switch ruleset. - var first = databasedSet.Beatmaps.Find(b => b.Ruleset == ruleset.Value) ?? databasedSet.Beatmaps.First(); + var first = databasedSet.Beatmaps.Find(b => b.Ruleset == Ruleset.Value) ?? databasedSet.Beatmaps.First(); - ruleset.Value = first.Ruleset; + Ruleset.Value = first.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first); }, $"load {beatmap}", bypassScreenAllowChecks: true, targetScreen: typeof(PlaySongSelect)); } @@ -287,9 +276,9 @@ namespace osu.Game performFromMainMenu(() => { - ruleset.Value = databasedScoreInfo.Ruleset; + Ruleset.Value = databasedScoreInfo.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); - mods.Value = databasedScoreInfo.Mods; + Mods.Value = databasedScoreInfo.Mods; menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index c068c5b0d4..7b9aed8364 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -29,6 +29,7 @@ using osu.Game.Input; using osu.Game.Input.Bindings; using osu.Game.IO; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Skinning; using osuTK.Input; @@ -69,7 +70,16 @@ namespace osu.Game protected override Container Content => content; - private Bindable beatmap; + private Bindable beatmap; // cached via load() method + + [Cached] + [Cached(typeof(IBindable))] + protected readonly Bindable Ruleset = new Bindable(); + + // todo: move this to SongSelect once Screen has the ability to unsuspend. + [Cached] + [Cached(Type = typeof(IBindable>))] + protected readonly Bindable> Mods = new Bindable>(Array.Empty()); protected Bindable Beatmap => beatmap;