mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 00:07:20 +08:00
Revert "Merge branch 'fix-legacy-skin-test' into catch-hide-combo-workaround"
This reverts commit 380d004683ad658d9ecbc408f7844eaa4c2b43c8, reversing changes made to ff419af5128a3e0f2d188e10fcb05aed712ac128.
This commit is contained in:
parent
076fcec3df
commit
e7d2f42149
@ -1,151 +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 System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Screens.Menu;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.SongSelect
|
|
||||||
{
|
|
||||||
public class TestSceneBeatmapMetadataDisplay : OsuTestScene
|
|
||||||
{
|
|
||||||
private BeatmapMetadataDisplay display;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private BeatmapManager manager { get; set; }
|
|
||||||
|
|
||||||
[Cached(typeof(BeatmapDifficultyCache))]
|
|
||||||
private readonly TestBeatmapDifficultyCache testDifficultyCache = new TestBeatmapDifficultyCache();
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestLocal([Values("Beatmap", "Some long title and stuff")]
|
|
||||||
string title,
|
|
||||||
[Values("Trial", "Some1's very hardest difficulty")]
|
|
||||||
string version)
|
|
||||||
{
|
|
||||||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
|
|
||||||
{
|
|
||||||
BeatmapInfo =
|
|
||||||
{
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Title = title,
|
|
||||||
},
|
|
||||||
Version = version,
|
|
||||||
StarDifficulty = RNG.NextDouble(0, 10),
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestDelayedStarRating()
|
|
||||||
{
|
|
||||||
AddStep("block calculation", () => testDifficultyCache.BlockCalculation = true);
|
|
||||||
|
|
||||||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
|
|
||||||
{
|
|
||||||
BeatmapInfo =
|
|
||||||
{
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Title = "Heavy beatmap",
|
|
||||||
},
|
|
||||||
Version = "10k objects",
|
|
||||||
StarDifficulty = 99.99f,
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
AddStep("allow calculation", () => testDifficultyCache.BlockCalculation = false);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestRandomFromDatabase()
|
|
||||||
{
|
|
||||||
showMetadataForBeatmap(() =>
|
|
||||||
{
|
|
||||||
var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
|
|
||||||
if (allBeatmapSets.Count == 0)
|
|
||||||
return manager.DefaultBeatmap;
|
|
||||||
|
|
||||||
var randomBeatmapSet = allBeatmapSets[RNG.Next(0, allBeatmapSets.Count - 1)];
|
|
||||||
var randomBeatmap = randomBeatmapSet.Beatmaps[RNG.Next(0, randomBeatmapSet.Beatmaps.Count - 1)];
|
|
||||||
|
|
||||||
return manager.GetWorkingBeatmap(randomBeatmap);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap)
|
|
||||||
{
|
|
||||||
AddStep("setup display", () =>
|
|
||||||
{
|
|
||||||
var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();
|
|
||||||
|
|
||||||
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };
|
|
||||||
|
|
||||||
Remove(testDifficultyCache);
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
testDifficultyCache,
|
|
||||||
display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), logo)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Alpha = 0f,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
display.FadeIn(400, Easing.OutQuint);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddWaitStep("wait a bit", 5);
|
|
||||||
|
|
||||||
AddStep("finish loading", () => display.Loading = false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestBeatmapDifficultyCache : BeatmapDifficultyCache
|
|
||||||
{
|
|
||||||
private TaskCompletionSource<bool> calculationBlocker;
|
|
||||||
|
|
||||||
private bool blockCalculation;
|
|
||||||
|
|
||||||
public bool BlockCalculation
|
|
||||||
{
|
|
||||||
get => blockCalculation;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == blockCalculation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
blockCalculation = value;
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
calculationBlocker = new TaskCompletionSource<bool>();
|
|
||||||
else
|
|
||||||
calculationBlocker?.SetResult(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<StarDifficulty> GetDifficultyAsync(BeatmapInfo beatmapInfo, RulesetInfo rulesetInfo = null, IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
if (blockCalculation)
|
|
||||||
await calculationBlocker.Task;
|
|
||||||
|
|
||||||
return await base.GetDifficultyAsync(beatmapInfo, rulesetInfo, mods, cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -103,8 +103,8 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with.</param>
|
||||||
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops computing the star difficulty.</param>
|
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops computing the star difficulty.</param>
|
||||||
/// <returns>The <see cref="StarDifficulty"/>.</returns>
|
/// <returns>The <see cref="StarDifficulty"/>.</returns>
|
||||||
public virtual Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null,
|
public Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null, [CanBeNull] IEnumerable<Mod> mods = null,
|
||||||
[CanBeNull] IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
||||||
rulesetInfo ??= beatmapInfo.Ruleset;
|
rulesetInfo ??= beatmapInfo.Ruleset;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -15,7 +14,6 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking.Expanded;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -27,7 +25,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
private readonly Bindable<IReadOnlyList<Mod>> mods;
|
private readonly Bindable<IReadOnlyList<Mod>> mods;
|
||||||
private readonly Drawable logoFacade;
|
private readonly Drawable facade;
|
||||||
private LoadingSpinner loading;
|
private LoadingSpinner loading;
|
||||||
|
|
||||||
public IBindable<IReadOnlyList<Mod>> Mods => mods;
|
public IBindable<IReadOnlyList<Mod>> Mods => mods;
|
||||||
@ -43,24 +41,19 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable logoFacade)
|
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
this.logoFacade = logoFacade;
|
this.facade = facade;
|
||||||
|
|
||||||
this.mods = new Bindable<IReadOnlyList<Mod>>();
|
this.mods = new Bindable<IReadOnlyList<Mod>>();
|
||||||
this.mods.BindTo(mods);
|
this.mods.BindTo(mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBindable<StarDifficulty?> starDifficulty;
|
|
||||||
|
|
||||||
private FillFlowContainer versionFlow;
|
|
||||||
private StarRatingDisplay starRatingDisplay;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapDifficultyCache difficultyCache)
|
private void load()
|
||||||
{
|
{
|
||||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -73,7 +66,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
logoFacade.With(d =>
|
facade.With(d =>
|
||||||
{
|
{
|
||||||
d.Anchor = Anchor.TopCentre;
|
d.Anchor = Anchor.TopCentre;
|
||||||
d.Origin = Anchor.TopCentre;
|
d.Origin = Anchor.TopCentre;
|
||||||
@ -114,30 +107,16 @@ namespace osu.Game.Screens.Play
|
|||||||
loading = new LoadingLayer(true)
|
loading = new LoadingLayer(true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
versionFlow = new FillFlowContainer
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
Text = beatmap?.BeatmapInfo?.Version,
|
||||||
Anchor = Anchor.TopCentre,
|
Font = OsuFont.GetFont(size: 26, italics: true),
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Direction = FillDirection.Vertical,
|
Anchor = Anchor.TopCentre,
|
||||||
Spacing = new Vector2(5f),
|
Margin = new MarginPadding
|
||||||
Margin = new MarginPadding { Bottom = 40 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
Bottom = 40
|
||||||
{
|
},
|
||||||
Text = beatmap?.BeatmapInfo?.Version,
|
|
||||||
Font = OsuFont.GetFont(size: 26, italics: true),
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
},
|
|
||||||
starRatingDisplay = new StarRatingDisplay(default)
|
|
||||||
{
|
|
||||||
Alpha = 0f,
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
@ -180,38 +159,9 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
starDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo);
|
|
||||||
|
|
||||||
Loading = true;
|
Loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
if (starDifficulty.Value != null)
|
|
||||||
{
|
|
||||||
starRatingDisplay.Current.Value = starDifficulty.Value.Value;
|
|
||||||
starRatingDisplay.Show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
starRatingDisplay.Hide();
|
|
||||||
|
|
||||||
starDifficulty.ValueChanged += d =>
|
|
||||||
{
|
|
||||||
Debug.Assert(d.NewValue != null);
|
|
||||||
|
|
||||||
starRatingDisplay.Current.Value = d.NewValue.Value;
|
|
||||||
|
|
||||||
versionFlow.AutoSizeDuration = 300;
|
|
||||||
versionFlow.AutoSizeEasing = Easing.OutQuint;
|
|
||||||
|
|
||||||
starRatingDisplay.FadeIn(300, Easing.InQuint);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MetadataLineLabel : OsuSpriteText
|
private class MetadataLineLabel : OsuSpriteText
|
||||||
{
|
{
|
||||||
public MetadataLineLabel(string text)
|
public MetadataLineLabel(string text)
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Framework.Timing;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Storyboards;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -24,9 +18,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
|
||||||
=> new LegacySkinWorkingBeatmap(beatmap, storyboard, Clock, Audio);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase game, SkinManager skins)
|
private void load(OsuGameBase game, SkinManager skins)
|
||||||
{
|
{
|
||||||
@ -34,14 +25,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
legacySkinSource = new SkinProvidingContainer(LegacySkin);
|
legacySkinSource = new SkinProvidingContainer(LegacySkin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetUpSteps()
|
|
||||||
{
|
|
||||||
base.SetUpSteps();
|
|
||||||
|
|
||||||
// check presence of a random legacy HUD component to ensure this is using legacy skin.
|
|
||||||
AddAssert("using legacy skin", () => this.ChildrenOfType<LegacyScoreCounter>().Any());
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SkinProvidingPlayer : TestPlayer
|
public class SkinProvidingPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
[Cached(typeof(ISkinSource))]
|
[Cached(typeof(ISkinSource))]
|
||||||
@ -52,15 +35,5 @@ namespace osu.Game.Tests.Visual
|
|||||||
this.skinSource = skinSource;
|
this.skinSource = skinSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LegacySkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
|
||||||
{
|
|
||||||
public LegacySkinWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock frameBasedClock, AudioManager audio)
|
|
||||||
: base(beatmap, storyboard, frameBasedClock, audio)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new LegacyBeatmapSkin(BeatmapInfo, null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user