mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 18:47:27 +08:00
allow test scenes to specify replays manually
This commit is contained in:
parent
24f9ef4005
commit
b4e516c535
@ -5,8 +5,12 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -50,18 +54,37 @@ namespace osu.Game.Tests.Visual
|
|||||||
return CreateModPlayer(ruleset);
|
return CreateModPlayer(ruleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual TestPlayer CreateModPlayer(Ruleset ruleset) => new ModTestPlayer(AllowFail);
|
protected virtual TestPlayer CreateModPlayer(Ruleset ruleset) => new ModTestPlayer(currentTestData, AllowFail);
|
||||||
|
|
||||||
protected class ModTestPlayer : TestPlayer
|
protected class ModTestPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
private readonly bool allowFail;
|
private readonly bool allowFail;
|
||||||
|
private ModTestData currentTestData;
|
||||||
|
|
||||||
protected override bool CheckModsAllowFailure() => allowFail;
|
protected override bool CheckModsAllowFailure() => allowFail;
|
||||||
|
|
||||||
public ModTestPlayer(bool allowFail)
|
public ModTestPlayer(ModTestData data, bool allowFail)
|
||||||
: base(false, false)
|
: base(false, false)
|
||||||
{
|
{
|
||||||
this.allowFail = allowFail;
|
this.allowFail = allowFail;
|
||||||
|
currentTestData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PrepareReplay()
|
||||||
|
{
|
||||||
|
if (currentTestData.Autoplay && currentTestData.Frames?.Count > 0)
|
||||||
|
throw new InvalidOperationException(@$"{nameof(ModTestData.Autoplay)} must be false when {nameof(ModTestData.Frames)} is specified.");
|
||||||
|
|
||||||
|
if (currentTestData.Frames != null)
|
||||||
|
{
|
||||||
|
DrawableRuleset?.SetReplayScore(new Score
|
||||||
|
{
|
||||||
|
Replay = new Replay { Frames = currentTestData.Frames },
|
||||||
|
ScoreInfo = new ScoreInfo { User = new APIUser { Username = @"Test" } },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
base.PrepareReplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +95,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Autoplay = true;
|
public bool Autoplay = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The frames to use for replay. <see cref="Autoplay"/> must be set to false.
|
||||||
|
/// </summary>
|
||||||
|
[CanBeNull]
|
||||||
|
public List<ReplayFrame> Frames;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The beatmap for this test case.
|
/// The beatmap for this test case.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user