mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Move application of judgements to Apply method
This commit is contained in:
parent
3138cc455c
commit
8aff828dfe
@ -111,7 +111,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
DrawableOsuJudgement explosion = poolDictionary[result.Type].Get(doj =>
|
DrawableOsuJudgement explosion = poolDictionary[result.Type].Get(doj =>
|
||||||
{
|
{
|
||||||
doj.JudgedObject = judgedObject;
|
doj.Apply(result, judgedObject);
|
||||||
|
|
||||||
// todo: move to JudgedObject property?
|
// todo: move to JudgedObject property?
|
||||||
doj.Position = osuObject.StackedEndPosition;
|
doj.Position = osuObject.StackedEndPosition;
|
||||||
@ -143,7 +143,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
var judgement = base.CreateNewDrawable();
|
var judgement = base.CreateNewDrawable();
|
||||||
|
|
||||||
// just a placeholder to initialise the correct drawable hierarchy for this pool.
|
// just a placeholder to initialise the correct drawable hierarchy for this pool.
|
||||||
judgement.Result = new JudgementResult(new HitObject(), new Judgement()) { Type = result };
|
judgement.Apply(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null);
|
||||||
|
|
||||||
return judgement;
|
return judgement;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// 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 System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Caching;
|
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -28,24 +28,8 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly Cached drawableCache = new Cached();
|
public JudgementResult Result { get; private set; }
|
||||||
|
public DrawableHitObject JudgedObject { get; private set; }
|
||||||
private JudgementResult result;
|
|
||||||
|
|
||||||
public JudgementResult Result
|
|
||||||
{
|
|
||||||
get => result;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (result?.Type == value.Type)
|
|
||||||
return;
|
|
||||||
|
|
||||||
result = value;
|
|
||||||
drawableCache.Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawableHitObject JudgedObject;
|
|
||||||
|
|
||||||
protected Container JudgementBody;
|
protected Container JudgementBody;
|
||||||
protected SpriteText JudgementText;
|
protected SpriteText JudgementText;
|
||||||
@ -68,8 +52,7 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
public DrawableJudgement(JudgementResult result, DrawableHitObject judgedObject)
|
public DrawableJudgement(JudgementResult result, DrawableHitObject judgedObject)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
Result = result;
|
Apply(result, judgedObject);
|
||||||
JudgedObject = judgedObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawableJudgement()
|
public DrawableJudgement()
|
||||||
@ -78,6 +61,12 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
prepareDrawables();
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void ApplyHitAnimations()
|
protected virtual void ApplyHitAnimations()
|
||||||
{
|
{
|
||||||
JudgementBody.ScaleTo(0.9f);
|
JudgementBody.ScaleTo(0.9f);
|
||||||
@ -86,10 +75,10 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
this.Delay(FadeOutDelay).FadeOut(400);
|
this.Delay(FadeOutDelay).FadeOut(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
public void Apply([NotNull] JudgementResult result, [CanBeNull] DrawableHitObject judgedObject)
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
prepareDrawables();
|
Result = result;
|
||||||
|
JudgedObject = judgedObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PrepareForUse()
|
protected override void PrepareForUse()
|
||||||
@ -98,8 +87,7 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
|
|
||||||
Debug.Assert(Result != null);
|
Debug.Assert(Result != null);
|
||||||
|
|
||||||
if (!drawableCache.IsValid)
|
prepareDrawables();
|
||||||
prepareDrawables();
|
|
||||||
|
|
||||||
this.FadeInFromZero(FadeInDuration, Easing.OutQuint);
|
this.FadeInFromZero(FadeInDuration, Easing.OutQuint);
|
||||||
JudgementBody.ScaleTo(1);
|
JudgementBody.ScaleTo(1);
|
||||||
@ -129,10 +117,15 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
Expire(true);
|
Expire(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HitResult? currentDrawableType;
|
||||||
|
|
||||||
private void prepareDrawables()
|
private void prepareDrawables()
|
||||||
{
|
{
|
||||||
var type = Result?.Type ?? HitResult.Perfect; //TODO: better default type from ruleset
|
var type = Result?.Type ?? HitResult.Perfect; //TODO: better default type from ruleset
|
||||||
|
|
||||||
|
if (type == currentDrawableType)
|
||||||
|
return;
|
||||||
|
|
||||||
InternalChild = JudgementBody = new Container
|
InternalChild = JudgementBody = new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -147,7 +140,7 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
}, confineMode: ConfineMode.NoScaling)
|
}, confineMode: ConfineMode.NoScaling)
|
||||||
};
|
};
|
||||||
|
|
||||||
drawableCache.Validate();
|
currentDrawableType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user