mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 15:42:11 +08:00
Improve star rating colour animations to match
This commit is contained in:
@@ -57,6 +57,22 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRulesetChange()
|
||||
{
|
||||
selectBeatmap(Beatmap.Value.Beatmap);
|
||||
|
||||
AddWaitStep("wait for select", 3);
|
||||
|
||||
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
||||
{
|
||||
var testBeatmap = TestSceneBeatmapInfoWedge.CreateTestBeatmap(rulesetInfo);
|
||||
|
||||
setRuleset(rulesetInfo);
|
||||
selectBeatmap(testBeatmap);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullBeatmap()
|
||||
{
|
||||
@@ -90,22 +106,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
checkDisplayedBPM($"{bpm * 0.75f}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRulesetChange()
|
||||
{
|
||||
selectBeatmap(Beatmap.Value.Beatmap);
|
||||
|
||||
AddWaitStep("wait for select", 3);
|
||||
|
||||
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
||||
{
|
||||
var testBeatmap = TestSceneBeatmapInfoWedge.CreateTestBeatmap(rulesetInfo);
|
||||
|
||||
setRuleset(rulesetInfo);
|
||||
selectBeatmap(testBeatmap);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWedgeVisibility()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
/// </summary>
|
||||
public partial class StarRatingDisplay : CompositeDrawable, IHasCurrentValue<StarDifficulty>
|
||||
{
|
||||
public const double TRANSFORM_DURATION = 750;
|
||||
|
||||
private readonly bool animated;
|
||||
private readonly Box background;
|
||||
private readonly SpriteIcon starIcon;
|
||||
@@ -36,6 +38,12 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The difficulty colour currently displayed.
|
||||
/// Can be used to have other components match the spectrum animation.
|
||||
/// </summary>
|
||||
public Color4 DisplayedDifficultyColour => background.Colour;
|
||||
|
||||
private readonly Bindable<double> displayedStars = new BindableDouble();
|
||||
|
||||
/// <summary>
|
||||
@@ -139,7 +147,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Current.BindValueChanged(c =>
|
||||
{
|
||||
if (animated)
|
||||
this.TransformBindableTo(displayedStars, c.NewValue.Stars, 750, Easing.OutQuint);
|
||||
this.TransformBindableTo(displayedStars, c.NewValue.Stars, TRANSFORM_DURATION, Easing.OutQuint);
|
||||
else
|
||||
displayedStars.Value = c.NewValue.Stars;
|
||||
});
|
||||
|
||||
@@ -236,7 +236,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
updateDisplay();
|
||||
|
||||
displayedStars.BindValueChanged(_ => updateStars(), true);
|
||||
displayedStars.BindValueChanged(_ =>
|
||||
{
|
||||
starRatingDisplay.Current.Value = new StarDifficulty(displayedStars.Value, 0);
|
||||
}, true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
@@ -330,17 +333,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
};
|
||||
});
|
||||
|
||||
private void updateStars()
|
||||
{
|
||||
starRatingDisplay.Current.Value = new StarDifficulty(displayedStars.Value, 0);
|
||||
|
||||
Color4 colour = displayedStars.Value >= 6.5f ? colours.Orange1 : colours.ForStarDifficulty(displayedStars.Value);
|
||||
difficultyText.FadeColour(colour, 300, Easing.OutQuint);
|
||||
mappedByText.FadeColour(colour, 300, Easing.OutQuint);
|
||||
countStatisticsDisplay.TransformTo(nameof(countStatisticsDisplay.AccentColour), colour, 300, Easing.OutQuint);
|
||||
difficultyStatisticsDisplay.TransformTo(nameof(difficultyStatisticsDisplay.AccentColour), colour, 300, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void computeStarDifficulty(CancellationToken cancellationToken)
|
||||
{
|
||||
difficultyCache.GetDifficultyAsync(beatmap.Value.BeatmapInfo, ruleset.Value, mods.Value, cancellationToken)
|
||||
@@ -360,7 +352,16 @@ namespace osu.Game.Screens.SelectV2
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
difficultyText.MaxWidth = Math.Max(nameLine.DrawWidth - mappedByText.DrawWidth - mapperText.DrawWidth - 20, 0);
|
||||
|
||||
// Use difficulty colour until it gets too dark to be visible against dark backgrounds.
|
||||
Color4 col = starRatingDisplay.DisplayedStars.Value >= OsuColour.STAR_DIFFICULTY_DEFINED_COLOUR_CUTOFF ? colours.Orange1 : starRatingDisplay.DisplayedDifficultyColour;
|
||||
|
||||
difficultyText.Colour = col;
|
||||
mappedByText.Colour = col;
|
||||
countStatisticsDisplay.AccentColour = col;
|
||||
difficultyStatisticsDisplay.AccentColour = col;
|
||||
}
|
||||
|
||||
private partial class MapperLinkContainer : OsuHoverContainer
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
{
|
||||
public partial class BeatmapTitleWedge
|
||||
{
|
||||
public partial class DifficultyStatisticsDisplay : CompositeDrawable, IHasAccentColour
|
||||
public partial class DifficultyStatisticsDisplay : CompositeDrawable
|
||||
{
|
||||
private readonly bool autoSize;
|
||||
private readonly FillFlowContainer<StatisticDifficulty> statisticsFlow;
|
||||
@@ -51,6 +51,9 @@ namespace osu.Game.Screens.SelectV2
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
if (accentColour == value)
|
||||
return;
|
||||
|
||||
accentColour = value;
|
||||
|
||||
foreach (var statistic in statisticsFlow)
|
||||
|
||||
Reference in New Issue
Block a user