Merge remote-tracking branch 'refs/remotes/ppy/master' into beatmap-video

This commit is contained in:
Andrei Zavatski
2019-09-13 13:39:58 +03:00
293 changed files with 4485 additions and 1259 deletions

View File

@ -16,6 +16,7 @@ using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Tests.Beatmaps;
@ -47,6 +48,12 @@ namespace osu.Game.Tests.Visual
private readonly Lazy<DatabaseContextFactory> contextFactory;
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
/// <summary>
/// Whether this test scene requires API access
/// Setting this will cache an actual <see cref="APIAccess"/>.
/// </summary>
protected virtual bool RequiresAPIAccess => false;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
// This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
@ -57,7 +64,17 @@ namespace osu.Game.Tests.Visual
Default = working
};
return Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
if (!RequiresAPIAccess)
{
var dummyAPI = new DummyAPIAccess();
Dependencies.CacheAs<IAPIProvider>(dummyAPI);
Add(dummyAPI);
}
return Dependencies;
}
protected OsuTestScene()

View File

@ -3,6 +3,7 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets;
@ -40,6 +41,8 @@ namespace osu.Game.Tests.Visual
protected virtual bool AllowFail => false;
protected virtual bool Autoplay => false;
private void loadPlayer()
{
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
@ -47,7 +50,18 @@ namespace osu.Game.Tests.Visual
Beatmap.Value = CreateWorkingBeatmap(beatmap);
if (!AllowFail)
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
{
var noFailMod = ruleset.GetAllMods().FirstOrDefault(m => m is ModNoFail);
if (noFailMod != null)
Mods.Value = new[] { noFailMod };
}
if (Autoplay)
{
var mod = ruleset.GetAutoplayMod();
if (mod != null)
Mods.Value = Mods.Value.Concat(mod.Yield()).ToArray();
}
Player = CreatePlayer(ruleset);
LoadScreen(Player);