mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:17:51 +08:00
Merge branch 'master' into ruleset-container-refactor
This commit is contained in:
commit
6f1610be79
@ -13,7 +13,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public class TestCaseAutoJuiceStream : TestCasePlayer
|
||||
public class TestCaseAutoJuiceStream : PlayerTestCase
|
||||
{
|
||||
public TestCaseAutoJuiceStream()
|
||||
: base(new CatchRuleset())
|
||||
|
@ -8,11 +8,12 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseBananaShower : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseBananaShower : PlayerTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
|
@ -2,11 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseCatchPlayer : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseCatchPlayer : PlayerTestCase
|
||||
{
|
||||
public TestCaseCatchPlayer()
|
||||
: base(new CatchRuleset())
|
||||
|
@ -4,11 +4,12 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseCatchStacker : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseCatchStacker : PlayerTestCase
|
||||
{
|
||||
public TestCaseCatchStacker()
|
||||
: base(new CatchRuleset())
|
||||
|
@ -1,22 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseHyperDash : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseHyperDash : PlayerTestCase
|
||||
{
|
||||
public TestCaseHyperDash()
|
||||
: base(new CatchRuleset())
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
|
||||
}
|
||||
|
||||
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
@ -28,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
}
|
||||
};
|
||||
|
||||
// Should produce a hperdash
|
||||
// Should produce a hyper-dash
|
||||
beatmap.HitObjects.Add(new Fruit { StartTime = 816, X = 308 / 512f, NewCombo = true });
|
||||
beatmap.HitObjects.Add(new Fruit { StartTime = 1008, X = 56 / 512f, });
|
||||
|
||||
@ -38,11 +44,5 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps(Func<Player> player)
|
||||
{
|
||||
base.AddCheckSteps(player);
|
||||
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,13 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
|
||||
public void ApplyToHitObject(HitObject hitObject)
|
||||
{
|
||||
if (hitObject is JuiceStream stream)
|
||||
{
|
||||
lastPosition = stream.EndX;
|
||||
lastStartTime = stream.EndTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(hitObject is Fruit))
|
||||
return;
|
||||
|
||||
@ -70,7 +77,7 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
private void applyRandomOffset(ref float position, double maxOffset)
|
||||
{
|
||||
bool right = RNG.NextBool();
|
||||
float rand = Math.Min(20, (float)RNG.NextDouble(0, maxOffset)) / CatchPlayfield.BASE_WIDTH;
|
||||
float rand = Math.Min(20, (float)RNG.NextDouble(0, Math.Max(0, maxOffset))) / CatchPlayfield.BASE_WIDTH;
|
||||
|
||||
if (right)
|
||||
{
|
||||
|
@ -4,12 +4,13 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseHitCircleLongCombo : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseHitCircleLongCombo : PlayerTestCase
|
||||
{
|
||||
public TestCaseHitCircleLongCombo()
|
||||
: base(new OsuRuleset())
|
||||
|
@ -2,11 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseOsuPlayer : Game.Tests.Visual.TestCasePlayer
|
||||
public class TestCaseOsuPlayer : PlayerTestCase
|
||||
{
|
||||
public TestCaseOsuPlayer()
|
||||
: base(new OsuRuleset())
|
||||
|
@ -242,6 +242,61 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportWithDuplicateBeatmapIDs()
|
||||
{
|
||||
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWithDuplicateBeatmapID"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
|
||||
var metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = "SomeArtist",
|
||||
AuthorString = "SomeAuthor"
|
||||
};
|
||||
|
||||
var difficulty = new BeatmapDifficulty();
|
||||
|
||||
var toImport = new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = 1,
|
||||
Metadata = metadata,
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 2,
|
||||
Metadata = metadata,
|
||||
BaseDifficulty = difficulty
|
||||
},
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 2,
|
||||
Metadata = metadata,
|
||||
Status = BeatmapSetOnlineStatus.Loved,
|
||||
BaseDifficulty = difficulty
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
var imported = manager.Import(toImport);
|
||||
|
||||
Assert.NotNull(imported);
|
||||
Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID);
|
||||
Assert.AreEqual(null, imported.Beatmaps[1].OnlineBeatmapID);
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[NonParallelizable]
|
||||
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseAllPlayers : TestCasePlayer
|
||||
{
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
@ -11,7 +10,7 @@ using osu.Game.Screens.Play;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("Player instantiated with an autoplay mod.")]
|
||||
public class TestCaseAutoplay : TestCasePlayer
|
||||
public class TestCaseAutoplay : AllPlayersTestCase
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
@ -24,11 +23,10 @@ namespace osu.Game.Tests.Visual
|
||||
};
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps(Func<Player> player)
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
base.AddCheckSteps(player);
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
}
|
||||
|
||||
private class ScoreAccessiblePlayer : Player
|
||||
|
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.cs
Normal file
56
osu.Game.Tests/Visual/TestCasePlayerReferenceLeaking.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCasePlayerReferenceLeaking : AllPlayersTestCase
|
||||
{
|
||||
private readonly WeakList<WorkingBeatmap> workingWeakReferences = new WeakList<WorkingBeatmap>();
|
||||
|
||||
private readonly WeakList<Player> playerWeakReferences = new WeakList<Player>();
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("no leaked beatmaps", () =>
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
int count = 0;
|
||||
|
||||
workingWeakReferences.ForEachAlive(_ => count++);
|
||||
return count == 1;
|
||||
});
|
||||
|
||||
AddUntilStep("no leaked players", () =>
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
int count = 0;
|
||||
|
||||
playerWeakReferences.ForEachAlive(_ => count++);
|
||||
return count == 1;
|
||||
});
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock)
|
||||
{
|
||||
var working = base.CreateWorkingBeatmap(beatmap, clock);
|
||||
workingWeakReferences.Add(working);
|
||||
return working;
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
var player = base.CreatePlayer(ruleset);
|
||||
playerWeakReferences.Add(player);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
@ -12,7 +11,7 @@ using osu.Game.Screens.Play;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("Player instantiated with a replay.")]
|
||||
public class TestCaseReplay : TestCasePlayer
|
||||
public class TestCaseReplay : AllPlayersTestCase
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
@ -21,11 +20,10 @@ namespace osu.Game.Tests.Visual
|
||||
return new ScoreAccessibleReplayPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps(Func<Player> player)
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
base.AddCheckSteps(player);
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)player()).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
}
|
||||
|
||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
|
@ -105,11 +105,14 @@ namespace osu.Game.Beatmaps
|
||||
validateOnlineIds(beatmapSet);
|
||||
|
||||
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
||||
fetchAndPopulateOnlineValues(b, beatmapSet.Beatmaps);
|
||||
fetchAndPopulateOnlineValues(b);
|
||||
}
|
||||
|
||||
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (beatmapSet.Beatmaps.Any(b => b.BaseDifficulty == null))
|
||||
throw new InvalidOperationException($"Cannot import {nameof(BeatmapInfo)} with null {nameof(BeatmapInfo.BaseDifficulty)}.");
|
||||
|
||||
// check if a set already exists with the same online id, delete if it does.
|
||||
if (beatmapSet.OnlineBeatmapSetID != null)
|
||||
{
|
||||
@ -382,7 +385,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
|
||||
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
|
||||
/// <returns>True if population was successful.</returns>
|
||||
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, IEnumerable<BeatmapInfo> otherBeatmaps, bool force = false)
|
||||
private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, bool force = false)
|
||||
{
|
||||
if (api?.State != APIState.Online)
|
||||
return false;
|
||||
@ -405,13 +408,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
beatmap.Status = res.Status;
|
||||
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
||||
|
||||
if (otherBeatmaps.Any(b => b.OnlineBeatmapID == res.OnlineBeatmapID))
|
||||
{
|
||||
Logger.Log("Another beatmap in the same set already mapped to this ID. We'll skip adding it this time.", LoggingTarget.Database);
|
||||
return false;
|
||||
}
|
||||
|
||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
||||
|
||||
|
@ -11,6 +11,7 @@ namespace osu.Game.Screens
|
||||
public class BackgroundScreenStack : ScreenStack
|
||||
{
|
||||
public BackgroundScreenStack()
|
||||
: base(false)
|
||||
{
|
||||
Scale = new Vector2(1.06f);
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -26,7 +27,24 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public virtual WorkingBeatmap Beatmap
|
||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
InternalChild = fadeContainer = CreateFadeContainer();
|
||||
fadeContainer.EnableUserDim.BindTo(EnableUserDim);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var background = new BeatmapBackground(beatmap);
|
||||
LoadComponent(background);
|
||||
switchBackground(background);
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationSource;
|
||||
|
||||
public WorkingBeatmap Beatmap
|
||||
{
|
||||
get => beatmap;
|
||||
set
|
||||
@ -38,54 +56,52 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() =>
|
||||
{
|
||||
float newDepth = 0;
|
||||
if (Background != null)
|
||||
{
|
||||
newDepth = Background.Depth + 1;
|
||||
Background.FinishTransforms();
|
||||
Background.FadeOut(250);
|
||||
Background.Expire();
|
||||
}
|
||||
if ((Background as BeatmapBackground)?.Beatmap == beatmap)
|
||||
return;
|
||||
|
||||
b.Depth = newDepth;
|
||||
fadeContainer.Add(Background = b);
|
||||
Background.BlurSigma = BlurTarget;
|
||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||
}));
|
||||
cancellationSource?.Cancel();
|
||||
LoadComponentAsync(new BeatmapBackground(beatmap), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||
private void switchBackground(BeatmapBackground b)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
InternalChild = fadeContainer = CreateFadeContainer();
|
||||
fadeContainer.EnableUserDim.BindTo(EnableUserDim);
|
||||
float newDepth = 0;
|
||||
if (Background != null)
|
||||
{
|
||||
newDepth = Background.Depth + 1;
|
||||
Background.FinishTransforms();
|
||||
Background.FadeOut(250);
|
||||
Background.Expire();
|
||||
}
|
||||
|
||||
b.Depth = newDepth;
|
||||
fadeContainer.Add(Background = b);
|
||||
Background.BlurSigma = BlurTarget;
|
||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||
}
|
||||
|
||||
public override bool Equals(BackgroundScreen other)
|
||||
{
|
||||
var otherBeatmapBackground = other as BackgroundScreenBeatmap;
|
||||
if (otherBeatmapBackground == null) return false;
|
||||
if (!(other is BackgroundScreenBeatmap otherBeatmapBackground)) return false;
|
||||
|
||||
return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap;
|
||||
}
|
||||
|
||||
protected class BeatmapBackground : Background
|
||||
{
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
public readonly WorkingBeatmap Beatmap;
|
||||
|
||||
public BeatmapBackground(WorkingBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
||||
Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
currentDisplay = RNG.Next(0, background_count);
|
||||
|
||||
Next();
|
||||
display(createBackground());
|
||||
}
|
||||
|
||||
private void display(Background newBackground)
|
||||
@ -51,19 +51,21 @@ namespace osu.Game.Screens.Backgrounds
|
||||
public void Next()
|
||||
{
|
||||
nextTask?.Cancel();
|
||||
nextTask = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
Background background;
|
||||
nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
|
||||
}
|
||||
|
||||
if (user.Value?.IsSupporter ?? false)
|
||||
background = new SkinnedBackground(skin.Value, backgroundName);
|
||||
else
|
||||
background = new Background(backgroundName);
|
||||
private Background createBackground()
|
||||
{
|
||||
Background background;
|
||||
|
||||
background.Depth = currentDisplay;
|
||||
if (user.Value?.IsSupporter ?? false)
|
||||
background = new SkinnedBackground(skin.Value, backgroundName);
|
||||
else
|
||||
background = new Background(backgroundName);
|
||||
|
||||
LoadComponentAsync(background, display);
|
||||
}, 100);
|
||||
background.Depth = currentDisplay;
|
||||
|
||||
return background;
|
||||
}
|
||||
|
||||
private class SkinnedBackground : Background
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Screens
|
||||
|
||||
protected Vector2 BlurTarget;
|
||||
|
||||
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
|
||||
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration = 0, Easing easing = Easing.None)
|
||||
{
|
||||
BlurTarget = sigma;
|
||||
return Background?.BlurTo(BlurTarget, duration, easing);
|
||||
|
@ -40,7 +40,9 @@ namespace osu.Game.Screens.Menu
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||
private BackgroundScreenDefault background;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => background;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game = null)
|
||||
@ -89,6 +91,7 @@ namespace osu.Game.Screens.Menu
|
||||
buttons.OnDirect = game.ToggleDirect;
|
||||
}
|
||||
|
||||
LoadComponentAsync(background = new BackgroundScreenDefault());
|
||||
preloadSongSelect();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Play
|
||||
/// Called when background elements require updates, usually due to a user changing a setting.
|
||||
/// </summary>
|
||||
/// <param name="userChange"></param>
|
||||
protected virtual void UpdateBackgroundElements()
|
||||
protected void UpdateBackgroundElements()
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
@ -61,7 +61,12 @@ namespace osu.Game.Screens.Select
|
||||
/// </summary>
|
||||
protected readonly Container FooterPanels;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||
protected override BackgroundScreen CreateBackground()
|
||||
{
|
||||
var background = new BackgroundScreenBeatmap();
|
||||
background.BlurTo(background_blur);
|
||||
return background;
|
||||
}
|
||||
|
||||
protected readonly BeatmapCarousel Carousel;
|
||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||
|
94
osu.Game/Tests/Visual/AllPlayersTestCase.cs
Normal file
94
osu.Game/Tests/Visual/AllPlayersTestCase.cs
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class which runs <see cref="Player"/> test for all available rulesets.
|
||||
/// Steps to be run for each ruleset should be added via <see cref="AddCheckSteps"/>.
|
||||
/// </summary>
|
||||
public abstract class AllPlayersTestCase : RateAdjustedBeatmapTestCase
|
||||
{
|
||||
protected Player Player;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Depth = int.MaxValue
|
||||
});
|
||||
|
||||
foreach (var r in rulesets.AvailableRulesets)
|
||||
{
|
||||
Player p = null;
|
||||
AddStep(r.Name, () => p = loadPlayerFor(r));
|
||||
AddUntilStep(() =>
|
||||
{
|
||||
if (p?.IsLoaded == true)
|
||||
{
|
||||
p = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, "player loaded");
|
||||
|
||||
AddCheckSteps();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void AddCheckSteps();
|
||||
|
||||
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock) =>
|
||||
new TestWorkingBeatmap(beatmap, Clock);
|
||||
|
||||
private Player loadPlayerFor(RulesetInfo ri)
|
||||
{
|
||||
Ruleset.Value = ri;
|
||||
var r = ri.CreateInstance();
|
||||
|
||||
var beatmap = CreateBeatmap(r);
|
||||
var working = CreateWorkingBeatmap(beatmap, Clock);
|
||||
|
||||
Beatmap.Value = working;
|
||||
Beatmap.Value.Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) };
|
||||
|
||||
Player?.Exit();
|
||||
Player = null;
|
||||
|
||||
var player = CreatePlayer(r);
|
||||
|
||||
LoadComponentAsync(player, p =>
|
||||
{
|
||||
Player = p;
|
||||
LoadScreen(p);
|
||||
});
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player
|
||||
{
|
||||
AllowPause = false,
|
||||
AllowLeadIn = false,
|
||||
AllowResults = false,
|
||||
};
|
||||
}
|
||||
}
|
69
osu.Game/Tests/Visual/PlayerTestCase.cs
Normal file
69
osu.Game/Tests/Visual/PlayerTestCase.cs
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public abstract class PlayerTestCase : RateAdjustedBeatmapTestCase
|
||||
{
|
||||
private readonly Ruleset ruleset;
|
||||
|
||||
protected Player Player;
|
||||
|
||||
protected PlayerTestCase(Ruleset ruleset)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Depth = int.MaxValue
|
||||
});
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
||||
AddUntilStep(() => Player.IsLoaded, "player loaded");
|
||||
}
|
||||
|
||||
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
protected virtual bool AllowFail => false;
|
||||
|
||||
private void loadPlayer()
|
||||
{
|
||||
var beatmap = CreateBeatmap(ruleset);
|
||||
|
||||
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
|
||||
|
||||
if (!AllowFail)
|
||||
Beatmap.Value.Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
||||
|
||||
LoadComponentAsync(Player = CreatePlayer(ruleset), p =>
|
||||
{
|
||||
Player = p;
|
||||
LoadScreen(p);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player
|
||||
{
|
||||
AllowPause = false,
|
||||
AllowLeadIn = false,
|
||||
AllowResults = false,
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user