mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:18:22 +08:00
Move result type to ctor
This commit is contained in:
parent
e4f1e52422
commit
8247e6ce91
@ -30,14 +30,19 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
this.Delay(FadeInDuration).FadeOut(200);
|
||||
}
|
||||
|
||||
protected override Drawable CreateDefaultJudgement(HitResult type)
|
||||
=> new ManiaJudgementPiece();
|
||||
protected override Drawable CreateDefaultJudgement(HitResult result) => new ManiaJudgementPiece(result);
|
||||
|
||||
private class ManiaJudgementPiece : DefaultJudgementPiece
|
||||
{
|
||||
public ManiaJudgementPiece(HitResult result)
|
||||
: base(result)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
JudgementText.Font = JudgementText.Font.With(size: 25);
|
||||
}
|
||||
}
|
||||
|
@ -68,15 +68,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
base.ApplyHitAnimations();
|
||||
}
|
||||
|
||||
protected override Drawable CreateDefaultJudgement(HitResult type) => new OsuJudgementPiece();
|
||||
protected override Drawable CreateDefaultJudgement(HitResult result) => new OsuJudgementPiece(result);
|
||||
|
||||
private class OsuJudgementPiece : DefaultJudgementPiece
|
||||
{
|
||||
public override void PlayAnimation(HitResult resultType)
|
||||
public OsuJudgementPiece(HitResult result)
|
||||
: base(result)
|
||||
{
|
||||
base.PlayAnimation(resultType);
|
||||
}
|
||||
|
||||
if (resultType != HitResult.Miss)
|
||||
public override void PlayAnimation()
|
||||
{
|
||||
base.PlayAnimation();
|
||||
|
||||
if (Result != HitResult.Miss)
|
||||
JudgementText.TransformSpacingTo(Vector2.Zero).Then().TransformSpacingTo(new Vector2(14, 0), 1800, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
@ -15,36 +15,42 @@ namespace osu.Game.Rulesets.Judgements
|
||||
{
|
||||
public class DefaultJudgementPiece : CompositeDrawable, IAnimatableJudgement
|
||||
{
|
||||
protected SpriteText JudgementText { get; }
|
||||
protected readonly HitResult Result;
|
||||
|
||||
protected SpriteText JudgementText { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public DefaultJudgementPiece()
|
||||
public DefaultJudgementPiece(HitResult result)
|
||||
{
|
||||
this.Result = result;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
JudgementText = new OsuSpriteText
|
||||
{
|
||||
Text = Result.GetDescription().ToUpperInvariant(),
|
||||
Colour = colours.ForHitResult(Result),
|
||||
Font = OsuFont.Numeric.With(size: 20),
|
||||
Scale = new Vector2(0.85f, 1),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public virtual void PlayAnimation(HitResult result)
|
||||
public virtual void PlayAnimation()
|
||||
{
|
||||
JudgementText.Text = result.GetDescription().ToUpperInvariant();
|
||||
JudgementText.Colour = colours.ForHitResult(result);
|
||||
|
||||
this.RotateTo(0);
|
||||
this.MoveTo(Vector2.Zero);
|
||||
|
||||
switch (result)
|
||||
switch (Result)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
this.ScaleTo(1.6f);
|
||||
|
@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Judgements
|
||||
if (skinnableJudgement.Drawable is IAnimatableJudgement animatable)
|
||||
{
|
||||
using (BeginAbsoluteSequence(Result.TimeAbsolute))
|
||||
animatable.PlayAnimation(Result.Type);
|
||||
animatable.PlayAnimation();
|
||||
}
|
||||
|
||||
Expire(true);
|
||||
@ -143,6 +143,7 @@ namespace osu.Game.Rulesets.Judgements
|
||||
{
|
||||
var type = Result?.Type ?? HitResult.Perfect; //TODO: better default type from ruleset
|
||||
|
||||
// todo: this should be removed once judgements are always pooled.
|
||||
if (type == currentDrawableType)
|
||||
return;
|
||||
|
||||
@ -162,6 +163,6 @@ namespace osu.Game.Rulesets.Judgements
|
||||
currentDrawableType = type;
|
||||
}
|
||||
|
||||
protected virtual Drawable CreateDefaultJudgement(HitResult type) => new DefaultJudgementPiece();
|
||||
protected virtual Drawable CreateDefaultJudgement(HitResult result) => new DefaultJudgementPiece(result);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Judgements
|
||||
{
|
||||
/// <summary>
|
||||
@ -10,6 +8,6 @@ namespace osu.Game.Rulesets.Judgements
|
||||
/// </summary>
|
||||
public interface IAnimatableJudgement
|
||||
{
|
||||
void PlayAnimation(HitResult result);
|
||||
void PlayAnimation();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user