1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Merge pull request #14450 from bdach/wedge-bpm-not-updating

Fix BPM display not updating if rate-changing mods were enabled after selecting beatmap
This commit is contained in:
Dan Balasescu 2021-08-23 12:22:59 +09:00 committed by GitHub
commit f2f3ba7bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework;
@ -11,6 +12,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
@ -19,6 +21,7 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Taiko;
using osu.Game.Screens.Select;
using osuTK;
@ -141,6 +144,29 @@ namespace osu.Game.Tests.Visual.SongSelect
selectBeatmap(createLongMetadata());
}
[Test]
public void TestBPMUpdates()
{
const float bpm = 120;
IBeatmap beatmap = createTestBeatmap(new OsuRuleset().RulesetInfo);
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 60 * 1000 / bpm });
OsuModDoubleTime doubleTime = null;
selectBeatmap(beatmap);
checkDisplayedBPM(bpm);
AddStep("select DT", () => SelectedMods.Value = new[] { doubleTime = new OsuModDoubleTime() });
checkDisplayedBPM(bpm * 1.5f);
AddStep("change DT rate", () => doubleTime.SpeedChange.Value = 2);
checkDisplayedBPM(bpm * 2);
void checkDisplayedBPM(float target) =>
AddUntilStep($"displayed bpm is {target}", () => this.ChildrenOfType<BeatmapInfoWedge.WedgeInfoText.InfoLabel>().Any(
label => label.Statistic.Name == "BPM" && label.Statistic.Content == target.ToString(CultureInfo.InvariantCulture)));
}
private void selectBeatmap([CanBeNull] IBeatmap b)
{
Container containerBefore = null;

View File

@ -71,6 +71,7 @@ namespace osu.Game.Screens.Select
private void load()
{
ruleset.BindValueChanged(_ => updateDisplay());
mods.BindValueChanged(_ => updateDisplay());
}
private const double animation_duration = 800;
@ -449,8 +450,11 @@ namespace osu.Game.Screens.Select
{
public LocalisableString TooltipText { get; }
internal BeatmapStatistic Statistic { get; }
public InfoLabel(BeatmapStatistic statistic)
{
Statistic = statistic;
TooltipText = statistic.Name;
AutoSizeAxes = Axes.Both;