From 803cbddfe224e756a52696e965a2168736943ccc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2017 16:58:47 +0900 Subject: [PATCH 1/2] Ensure score's user is set directly from API Previously would fail in visualtests due to `OsuGame` case. --- osu.Game/Screens/Play/Player.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3f399d69e6..992c5c5f6f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -23,6 +23,7 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Ranking; using osu.Framework.Audio.Sample; using osu.Game.Beatmaps; +using osu.Game.Online.API; namespace osu.Game.Screens.Play { @@ -50,6 +51,8 @@ namespace osu.Game.Screens.Play private RulesetInfo ruleset; + private APIAccess api; + private ScoreProcessor scoreProcessor; protected RulesetContainer RulesetContainer; @@ -69,9 +72,12 @@ namespace osu.Game.Screens.Play private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader(permitNulls: true)] - private void load(AudioManager audio, OsuConfigManager config, OsuGame osu) + private void load(AudioManager audio, OsuConfigManager config, OsuGame osu, APIAccess api) { + this.api = api; + dimLevel = config.GetBindable(OsuSetting.DimLevel); + mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); sampleRestart = audio.Sample.Get(@"Gameplay/restart"); @@ -235,7 +241,7 @@ namespace osu.Game.Screens.Play Ruleset = ruleset }; scoreProcessor.PopulateScore(score); - score.User = RulesetContainer.Replay?.User ?? (Game as OsuGame)?.API?.LocalUser?.Value; + score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value; Push(new Results(score)); }); } From c5a20e337274356283092a6f67b7184019dfb824 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2017 18:02:38 +0900 Subject: [PATCH 2/2] Remove permitNulls --- osu.Game/Screens/Play/Player.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 992c5c5f6f..615e04d6c2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -71,8 +71,8 @@ namespace osu.Game.Screens.Play private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; - [BackgroundDependencyLoader(permitNulls: true)] - private void load(AudioManager audio, OsuConfigManager config, OsuGame osu, APIAccess api) + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuConfigManager config, APIAccess api) { this.api = api; @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play if (beatmap == null) throw new InvalidOperationException("Beatmap was not loaded"); - ruleset = osu?.Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset; + ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset; var rulesetInstance = ruleset.CreateInstance(); try