1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

add MatchScoreDiffCounter

Intuitively show the score difference between the two teams
This commit is contained in:
cdwcgt 2023-07-23 15:32:12 +09:00
parent c7d0279a44
commit 1a76f6441a
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2

View File

@ -28,6 +28,8 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
private readonly MatchScoreCounter score1Text;
private readonly MatchScoreCounter score2Text;
private readonly MatchScoreDiffCounter scoreDiffText;
private readonly Drawable score1Bar;
private readonly Drawable score2Bar;
@ -88,6 +90,11 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
},
scoreDiffText = new MatchScoreDiffCounter
{
Anchor = Anchor.TopCentre,
Alpha = 0
}
};
}
@ -119,6 +126,16 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
losingBar.ResizeWidthTo(0, 400, Easing.OutQuint);
winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint);
if (diff == 0)
{
scoreDiffText.Hide();
return;
}
scoreDiffText.Show();
scoreDiffText.Current.Value = -diff;
scoreDiffText.Origin = score1.Value > score2.Value ? Anchor.TopLeft : Anchor.TopRight;
}
protected override void UpdateAfterChildren()
@ -154,5 +171,19 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
? OsuFont.Torus.With(weight: FontWeight.Bold, size: 50, fixedWidth: true)
: OsuFont.Torus.With(weight: FontWeight.Regular, size: 40, fixedWidth: true);
}
private partial class MatchScoreDiffCounter : CommaSeparatedScoreCounter
{
public MatchScoreDiffCounter()
{
Margin = new MarginPadding { Top = bar_height / 4, Horizontal = 10 };
}
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
{
s.Spacing = new Vector2(-1);
s.Font = OsuFont.Torus.With(weight: FontWeight.Regular, size: bar_height, fixedWidth: true);
});
}
}
}