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

Determine whether to show lighting at prepare time

This commit is contained in:
Bartłomiej Dach 2020-07-26 23:20:38 +02:00
parent bbc7d69524
commit 21ae33e284

View File

@ -20,6 +20,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private Bindable<Color4> lightingColour; private Bindable<Color4> lightingColour;
[Resolved]
private OsuConfigManager config { get; set; }
public DrawableOsuJudgement(JudgementResult result, DrawableHitObject judgedObject) public DrawableOsuJudgement(JudgementResult result, DrawableHitObject judgedObject)
: base(result, judgedObject) : base(result, judgedObject)
{ {
@ -30,18 +33,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load()
{ {
if (config.Get<bool>(OsuSetting.HitLighting)) AddInternal(Lighting = new SkinnableSprite("lighting")
{ {
AddInternal(Lighting = new SkinnableSprite("lighting") Anchor = Anchor.Centre,
{ Origin = Anchor.Centre,
Anchor = Anchor.Centre, Blending = BlendingParameters.Additive,
Origin = Anchor.Centre, Depth = float.MaxValue,
Blending = BlendingParameters.Additive, Alpha = 0
Depth = float.MaxValue });
});
}
} }
public override void Apply(JudgementResult result, DrawableHitObject judgedObject) public override void Apply(JudgementResult result, DrawableHitObject judgedObject)
@ -61,19 +62,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
lightingColour?.UnbindAll(); lightingColour?.UnbindAll();
if (Lighting != null) Lighting.ResetAnimation();
{
Lighting.ResetAnimation();
if (JudgedObject != null) if (JudgedObject != null)
{ {
lightingColour = JudgedObject.AccentColour.GetBoundCopy(); lightingColour = JudgedObject.AccentColour.GetBoundCopy();
lightingColour.BindValueChanged(colour => Lighting.Colour = Result.Type == HitResult.Miss ? Color4.Transparent : colour.NewValue, true); lightingColour.BindValueChanged(colour => Lighting.Colour = Result.Type == HitResult.Miss ? Color4.Transparent : colour.NewValue, true);
} }
else else
{ {
Lighting.Colour = Color4.White; Lighting.Colour = Color4.White;
}
} }
} }
@ -81,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void ApplyHitAnimations() protected override void ApplyHitAnimations()
{ {
if (Lighting != null) if (config.Get<bool>(OsuSetting.HitLighting))
{ {
JudgementBody.FadeIn().Delay(FadeInDuration).FadeOut(400); JudgementBody.FadeIn().Delay(FadeInDuration).FadeOut(400);