From 2747d7692b1db44559f305c3e4873e78048a6f48 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 14:55:05 +0900 Subject: [PATCH 1/9] Create ReplayPlayerLoader for local mod caching --- osu.Game/OsuGame.cs | 3 +- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 32 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Screens/Play/ReplayPlayerLoader.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 0a472d4dc1..ab7efc6e38 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -284,9 +284,8 @@ namespace osu.Game { Ruleset.Value = databasedScoreInfo.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); - Mods.Value = databasedScoreInfo.Mods; - menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); + menuScreen.Push(new ReplayPlayerLoader(() => new ReplayPlayer(databasedScore), databasedScoreInfo.Mods)); }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); } diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs new file mode 100644 index 0000000000..1c24709e41 --- /dev/null +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Screens.Play +{ + public class ReplayPlayerLoader : PlayerLoader + { + private readonly IReadOnlyList mods; + + public ReplayPlayerLoader(Func player, IReadOnlyList mods) + : base(player) + { + this.mods = mods; + } + + private DependencyContainer dependencies; + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + dependencies = new DependencyContainer(parent); + dependencies.Cache(new Bindable>(mods)); + + return base.CreateChildDependencies(dependencies); + } + } +} From 5853a877c257a14316cf03e5a39dd2a70e912e90 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 15:40:10 +0900 Subject: [PATCH 2/9] create base dependencies before caching, create player in playerloader --- osu.Game/OsuGame.cs | 2 +- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ab7efc6e38..1c426d928f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -285,7 +285,7 @@ namespace osu.Game Ruleset.Value = databasedScoreInfo.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); - menuScreen.Push(new ReplayPlayerLoader(() => new ReplayPlayer(databasedScore), databasedScoreInfo.Mods)); + menuScreen.Push(new ReplayPlayerLoader(databasedScore, databasedScoreInfo.Mods)); }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); } diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index 1c24709e41..41f02b5cb1 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -1,32 +1,33 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Rulesets.Mods; +using osu.Game.Scoring; namespace osu.Game.Screens.Play { public class ReplayPlayerLoader : PlayerLoader { - private readonly IReadOnlyList mods; + private readonly Bindable> mods; - public ReplayPlayerLoader(Func player, IReadOnlyList mods) - : base(player) + public ReplayPlayerLoader(Score score, IReadOnlyList mods) + : base(() => new ReplayPlayer(score)) { - this.mods = mods; + this.mods = new Bindable>(mods); } - private DependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - dependencies = new DependencyContainer(parent); - dependencies.Cache(new Bindable>(mods)); + var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + dependencies.Cache(mods); - return base.CreateChildDependencies(dependencies); + // Overwrite the global mods here for use in the mod hud. + Mods.Value = mods.Value; + + return dependencies; } } } From 6a86f62d17b05a899059337ed9f82d25a92f2d5d Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 16:13:03 +0900 Subject: [PATCH 3/9] Get mods from score info --- osu.Game/OsuGame.cs | 2 +- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1c426d928f..2260c5bb57 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -285,7 +285,7 @@ namespace osu.Game Ruleset.Value = databasedScoreInfo.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); - menuScreen.Push(new ReplayPlayerLoader(databasedScore, databasedScoreInfo.Mods)); + menuScreen.Push(new ReplayPlayerLoader(databasedScore)); }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); } diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index 41f02b5cb1..da30ed80b6 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -13,10 +13,10 @@ namespace osu.Game.Screens.Play { private readonly Bindable> mods; - public ReplayPlayerLoader(Score score, IReadOnlyList mods) + public ReplayPlayerLoader(Score score) : base(() => new ReplayPlayer(score)) { - this.mods = new Bindable>(mods); + mods = new Bindable>(score.ScoreInfo.Mods); } protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) From ef22ab9340d152cb9713b4aded8957321f6b5412 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 16:32:11 +0900 Subject: [PATCH 4/9] remove bindable --- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index da30ed80b6..b877e7e2ca 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -11,21 +11,20 @@ namespace osu.Game.Screens.Play { public class ReplayPlayerLoader : PlayerLoader { - private readonly Bindable> mods; + private readonly IReadOnlyList mods; public ReplayPlayerLoader(Score score) : base(() => new ReplayPlayer(score)) { - mods = new Bindable>(score.ScoreInfo.Mods); + mods = score.ScoreInfo.Mods; } protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); - dependencies.Cache(mods); // Overwrite the global mods here for use in the mod hud. - Mods.Value = mods.Value; + Mods.Value = mods; return dependencies; } From e78e326f34d84ce8cc3abbcc581adf35f8194bad Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 17:02:42 +0900 Subject: [PATCH 5/9] remove unused using --- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index b877e7e2ca..62edb661b9 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Game.Rulesets.Mods; using osu.Game.Scoring; From fbd300e6643a582b9fab5299265633e907e16d6b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 17:37:20 +0900 Subject: [PATCH 6/9] Move ruleset into ReplayPlayerLoader as well --- osu.Game/OsuGame.cs | 1 - osu.Game/Screens/Play/ReplayPlayerLoader.cs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 2260c5bb57..361ff62155 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -282,7 +282,6 @@ namespace osu.Game performFromMainMenu(() => { - Ruleset.Value = databasedScoreInfo.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); menuScreen.Push(new ReplayPlayerLoader(databasedScore)); diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index 62edb661b9..329e799f7c 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -1,21 +1,19 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Game.Rulesets.Mods; using osu.Game.Scoring; namespace osu.Game.Screens.Play { public class ReplayPlayerLoader : PlayerLoader { - private readonly IReadOnlyList mods; + private readonly ScoreInfo scoreInfo; public ReplayPlayerLoader(Score score) : base(() => new ReplayPlayer(score)) { - mods = score.ScoreInfo.Mods; + scoreInfo = score.ScoreInfo; } protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) @@ -23,7 +21,8 @@ namespace osu.Game.Screens.Play var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); // Overwrite the global mods here for use in the mod hud. - Mods.Value = mods; + Mods.Value = scoreInfo.Mods; + Ruleset.Value = scoreInfo.Ruleset; return dependencies; } From d489a77fe18c3a3f06b1cccb733fdb8a410bcb39 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 17:57:29 +0900 Subject: [PATCH 7/9] remove new container and comment --- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index 329e799f7c..8681ae6887 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -18,9 +18,8 @@ namespace osu.Game.Screens.Play protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + var dependencies = base.CreateChildDependencies(parent); - // Overwrite the global mods here for use in the mod hud. Mods.Value = scoreInfo.Mods; Ruleset.Value = scoreInfo.Ruleset; From 54f5e6aedf4ffcce98f62a830020f1252eb42d93 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 8 Jul 2019 22:37:39 +0900 Subject: [PATCH 8/9] Add assertion and comment about lease logic --- osu.Game/Screens/Play/ReplayPlayerLoader.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Screens/Play/ReplayPlayerLoader.cs b/osu.Game/Screens/Play/ReplayPlayerLoader.cs index 8681ae6887..86179ef067 100644 --- a/osu.Game/Screens/Play/ReplayPlayerLoader.cs +++ b/osu.Game/Screens/Play/ReplayPlayerLoader.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Game.Scoring; @@ -13,6 +14,9 @@ namespace osu.Game.Screens.Play public ReplayPlayerLoader(Score score) : base(() => new ReplayPlayer(score)) { + if (score.Replay == null) + throw new ArgumentNullException(nameof(score.Replay), $"{nameof(score)} must have a non-null {nameof(score.Replay)}."); + scoreInfo = score.ScoreInfo; } @@ -20,6 +24,7 @@ namespace osu.Game.Screens.Play { var dependencies = base.CreateChildDependencies(parent); + // these will be reverted thanks to PlayerLoader's lease. Mods.Value = scoreInfo.Mods; Ruleset.Value = scoreInfo.Ruleset; From 2472c6b4b121d788c5ef835e5156eb179d582f8e Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Tue, 9 Jul 2019 21:07:29 +0930 Subject: [PATCH 9/9] Fix iOS visual tests not supporting raw keyboard handler --- osu.Game.Rulesets.Catch.Tests.iOS/Application.cs | 2 +- osu.Game.Rulesets.Mania.Tests.iOS/Application.cs | 2 +- osu.Game.Rulesets.Osu.Tests.iOS/Application.cs | 2 +- osu.Game.Rulesets.Taiko.Tests.iOS/Application.cs | 2 +- osu.Game.Tests.iOS/Application.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests.iOS/Application.cs b/osu.Game.Rulesets.Catch.Tests.iOS/Application.cs index 44817c1304..beca477943 100644 --- a/osu.Game.Rulesets.Catch.Tests.iOS/Application.cs +++ b/osu.Game.Rulesets.Catch.Tests.iOS/Application.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Catch.Tests.iOS { public static void Main(string[] args) { - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, "GameUIApplication", "AppDelegate"); } } } diff --git a/osu.Game.Rulesets.Mania.Tests.iOS/Application.cs b/osu.Game.Rulesets.Mania.Tests.iOS/Application.cs index d47ac4643f..0362402320 100644 --- a/osu.Game.Rulesets.Mania.Tests.iOS/Application.cs +++ b/osu.Game.Rulesets.Mania.Tests.iOS/Application.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mania.Tests.iOS { public static void Main(string[] args) { - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, "GameUIApplication", "AppDelegate"); } } } diff --git a/osu.Game.Rulesets.Osu.Tests.iOS/Application.cs b/osu.Game.Rulesets.Osu.Tests.iOS/Application.cs index 7a0797a909..3718264a42 100644 --- a/osu.Game.Rulesets.Osu.Tests.iOS/Application.cs +++ b/osu.Game.Rulesets.Osu.Tests.iOS/Application.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Tests.iOS { public static void Main(string[] args) { - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, "GameUIApplication", "AppDelegate"); } } } diff --git a/osu.Game.Rulesets.Taiko.Tests.iOS/Application.cs b/osu.Game.Rulesets.Taiko.Tests.iOS/Application.cs index 6613e9e2b4..330cb42901 100644 --- a/osu.Game.Rulesets.Taiko.Tests.iOS/Application.cs +++ b/osu.Game.Rulesets.Taiko.Tests.iOS/Application.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.iOS { public static void Main(string[] args) { - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, "GameUIApplication", "AppDelegate"); } } } diff --git a/osu.Game.Tests.iOS/Application.cs b/osu.Game.Tests.iOS/Application.cs index a23fe4e129..d96a3e27a4 100644 --- a/osu.Game.Tests.iOS/Application.cs +++ b/osu.Game.Tests.iOS/Application.cs @@ -9,7 +9,7 @@ namespace osu.Game.Tests.iOS { public static void Main(string[] args) { - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, "GameUIApplication", "AppDelegate"); } } }