Move judgement text creation to base class and tidy things up

This commit is contained in:
Dean Herbert 2022-12-24 12:22:36 +08:00
parent 03603f8b54
commit 5e9fb1063a
5 changed files with 61 additions and 66 deletions

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -26,6 +27,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
public ArgonJudgementPiece(HitResult result) public ArgonJudgementPiece(HitResult result)
: base(result) : base(result)
{ {
AutoSizeAxes = Axes.Both;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Y = 160; Y = 160;
} }
@ -33,21 +36,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
JudgementText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colours.ForHitResult(Result),
Blending = BlendingParameters.Additive,
Spacing = new Vector2(10, 0),
Font = OsuFont.Default.With(size: 28, weight: FontWeight.Regular),
},
};
if (Result.IsHit()) if (Result.IsHit())
{ {
AddInternal(ringExplosion = new RingExplosion(Result) AddInternal(ringExplosion = new RingExplosion(Result)
@ -57,6 +45,16 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
} }
} }
protected override SpriteText CreateJudgementText() =>
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Blending = BlendingParameters.Additive,
Spacing = new Vector2(10, 0),
Font = OsuFont.Default.With(size: 28, weight: FontWeight.Regular),
};
/// <summary> /// <summary>
/// Plays the default animation for this judgement piece. /// Plays the default animation for this judgement piece.
/// </summary> /// </summary>

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -25,27 +26,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
public ArgonJudgementPiece(HitResult result) public ArgonJudgementPiece(HitResult result)
: base(result) : base(result)
{ {
AutoSizeAxes = Axes.Both;
Origin = Anchor.Centre; Origin = Anchor.Centre;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
JudgementText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colours.ForHitResult(Result),
Blending = BlendingParameters.Additive,
Spacing = new Vector2(5, 0),
Font = OsuFont.Default.With(size: 20, weight: FontWeight.Bold),
},
};
if (Result.IsHit()) if (Result.IsHit())
{ {
AddInternal(ringExplosion = new RingExplosion(Result) AddInternal(ringExplosion = new RingExplosion(Result)
@ -55,6 +43,16 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
} }
} }
protected override SpriteText CreateJudgementText() =>
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Blending = BlendingParameters.Additive,
Spacing = new Vector2(5, 0),
Font = OsuFont.Default.With(size: 20, weight: FontWeight.Bold),
};
/// <summary> /// <summary>
/// Plays the default animation for this judgement piece. /// Plays the default animation for this judgement piece.
/// </summary> /// </summary>

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -33,20 +34,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChildren = new Drawable[]
{
JudgementText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colours.ForHitResult(Result),
Blending = BlendingParameters.Additive,
Spacing = new Vector2(10, 0),
RelativePositionAxes = Axes.Both,
Font = OsuFont.Default.With(size: 20, weight: FontWeight.Regular),
},
};
if (Result.IsHit()) if (Result.IsHit())
{ {
AddInternal(ringExplosion = new RingExplosion(Result) AddInternal(ringExplosion = new RingExplosion(Result)
@ -57,6 +44,17 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
} }
} }
protected override SpriteText CreateJudgementText() =>
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Blending = BlendingParameters.Additive,
Spacing = new Vector2(10, 0),
RelativePositionAxes = Axes.Both,
Font = OsuFont.Default.With(size: 20, weight: FontWeight.Regular),
};
/// <summary> /// <summary>
/// Plays the default animation for this judgement piece. /// Plays the default animation for this judgement piece.
/// </summary> /// </summary>

View File

@ -1,10 +1,9 @@
// 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.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -15,31 +14,24 @@ namespace osu.Game.Rulesets.Judgements
public partial class DefaultJudgementPiece : JudgementPiece, IAnimatableJudgement public partial class DefaultJudgementPiece : JudgementPiece, IAnimatableJudgement
{ {
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
public DefaultJudgementPiece(HitResult result) public DefaultJudgementPiece(HitResult result)
: base(result) : base(result)
{ {
AutoSizeAxes = Axes.Both;
Origin = Anchor.Centre; Origin = Anchor.Centre;
} }
[BackgroundDependencyLoader] protected override SpriteText CreateJudgementText() =>
private void load() new OsuSpriteText
{
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{ {
JudgementText = new OsuSpriteText Anchor = Anchor.Centre,
{ Origin = Anchor.Centre,
Anchor = Anchor.Centre, Font = OsuFont.Numeric.With(size: 20),
Origin = Anchor.Centre, Scale = new Vector2(0.85f, 1),
Colour = colours.ForHitResult(Result),
Font = OsuFont.Numeric.With(size: 20),
Scale = new Vector2(0.85f, 1),
}
}; };
}
/// <summary> /// <summary>
/// Plays the default animation for this judgement piece. /// Plays the default animation for this judgement piece.
@ -67,6 +59,6 @@ namespace osu.Game.Rulesets.Judgements
this.FadeOutFromOne(800); this.FadeOutFromOne(800);
} }
public Drawable GetAboveHitObjectsProxiedContent() => null; public Drawable? GetAboveHitObjectsProxiedContent() => null;
} }
} }

View File

@ -1,9 +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 osu.Framework.Allocation;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Judgements namespace osu.Game.Rulesets.Judgements
@ -12,18 +14,25 @@ namespace osu.Game.Rulesets.Judgements
{ {
protected readonly HitResult Result; protected readonly HitResult Result;
protected SpriteText JudgementText { get; set; } = null!; protected SpriteText JudgementText { get; private set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
protected JudgementPiece(HitResult result) protected JudgementPiece(HitResult result)
{ {
Result = result; Result = result;
} }
protected override void LoadComplete() [BackgroundDependencyLoader]
private void load()
{ {
base.LoadComplete(); JudgementText = CreateJudgementText();
JudgementText.Colour = colours.ForHitResult(Result);
JudgementText.Text = Result.GetDescription().ToUpperInvariant(); JudgementText.Text = Result.GetDescription().ToUpperInvariant();
} }
protected abstract SpriteText CreateJudgementText();
} }
} }