1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

refactor(osu.Game): separate OsuColour.ForHitResult by usage

This commit is contained in:
Acid Chicken (硫酸鶏) 2022-09-05 01:58:57 +09:00
parent cbc3627189
commit 5f0832ead7
No known key found for this signature in database
GPG Key ID: 3E87B98A3F6BAB99
5 changed files with 33 additions and 28 deletions

View File

@ -102,7 +102,7 @@ namespace osu.Game.Graphics
/// <summary>
/// Retrieves the colour for a <see cref="HitResult"/>.
/// </summary>
public Color4 ForHitResult(HitResult judgement)
public Color4 TextForHitResult(HitResult judgement)
{
switch (judgement)
{
@ -125,6 +125,34 @@ namespace osu.Game.Graphics
}
}
public Color4 DrawForHitResult(HitResult result)
{
switch (result)
{
case HitResult.SmallTickMiss:
case HitResult.LargeTickMiss:
case HitResult.Miss:
return Red;
case HitResult.Meh:
return Yellow;
case HitResult.Ok:
return Green;
case HitResult.Good:
return GreenLight;
case HitResult.SmallTickHit:
case HitResult.LargeTickHit:
case HitResult.Great:
return Blue;
default:
return BlueLight;
}
}
/// <summary>
/// Retrieves a colour for the given <see cref="BeatmapOnlineStatus"/>.
/// A <see langword="null"/> value indicates that a "background" shade from the local <see cref="OverlayColourProvider"/>

View File

@ -156,7 +156,7 @@ namespace osu.Game.Online.Leaderboards
{
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold),
Text = displayName.ToUpper(),
Colour = colours.ForHitResult(result),
Colour = colours.TextForHitResult(result),
},
new OsuSpriteText
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Judgements
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = Result.GetDescription().ToUpperInvariant(),
Colour = colours.ForHitResult(Result),
Colour = colours.TextForHitResult(Result),
Font = OsuFont.Numeric.With(size: 20),
Scale = new Vector2(0.85f, 1),
}

View File

@ -59,30 +59,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
protected Color4 GetColourForHitResult(HitResult result)
{
switch (result)
{
case HitResult.SmallTickMiss:
case HitResult.LargeTickMiss:
case HitResult.Miss:
return colours.Red;
case HitResult.Meh:
return colours.Yellow;
case HitResult.Ok:
return colours.Green;
case HitResult.Good:
return colours.GreenLight;
case HitResult.SmallTickHit:
case HitResult.LargeTickHit:
case HitResult.Great:
return colours.Blue;
default:
return colours.BlueLight;
}
return colours.DrawForHitResult(result);
}
/// <summary>

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
HeaderText.Colour = colours.ForHitResult(Result);
HeaderText.Colour = colours.TextForHitResult(Result);
}
}
}