mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 20:53:00 +08:00
Merge pull request #10691 from smoogipoo/osu-lighting-colour-reuse
Remove AccentColour binding from judgement lighting
This commit is contained in:
commit
c26fd4dc3d
@ -2,22 +2,17 @@
|
|||||||
// 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.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableOsuJudgement : DrawableJudgement
|
public class DrawableOsuJudgement : DrawableJudgement
|
||||||
{
|
{
|
||||||
protected SkinnableSprite Lighting;
|
protected SkinnableLighting Lighting { get; private set; }
|
||||||
|
|
||||||
private Bindable<Color4> lightingColour;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
@ -34,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
AddInternal(Lighting = new SkinnableSprite("lighting")
|
AddInternal(Lighting = new SkinnableLighting
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -59,19 +54,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.PrepareForUse();
|
base.PrepareForUse();
|
||||||
|
|
||||||
lightingColour?.UnbindAll();
|
|
||||||
|
|
||||||
Lighting.ResetAnimation();
|
Lighting.ResetAnimation();
|
||||||
|
Lighting.SetColourFrom(JudgedObject, Result);
|
||||||
if (JudgedObject != null)
|
|
||||||
{
|
|
||||||
lightingColour = JudgedObject.AccentColour.GetBoundCopy();
|
|
||||||
lightingColour.BindValueChanged(colour => Lighting.Colour = Result.IsHit ? colour.NewValue : Color4.Transparent, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Lighting.Colour = Color4.White;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double fadeOutDelay;
|
private double fadeOutDelay;
|
||||||
|
48
osu.Game.Rulesets.Osu/Objects/Drawables/SkinnableLighting.cs
Normal file
48
osu.Game.Rulesets.Osu/Objects/Drawables/SkinnableLighting.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
|
{
|
||||||
|
public class SkinnableLighting : SkinnableSprite
|
||||||
|
{
|
||||||
|
private DrawableHitObject targetObject;
|
||||||
|
private JudgementResult targetResult;
|
||||||
|
|
||||||
|
public SkinnableLighting()
|
||||||
|
: base("lighting")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
|
{
|
||||||
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
updateColour();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the lighting colour from a given hitobject and result.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetObject">The <see cref="DrawableHitObject"/> that's been judged.</param>
|
||||||
|
/// <param name="targetResult">The <see cref="JudgementResult"/> that <paramref name="targetObject"/> was judged with.</param>
|
||||||
|
public void SetColourFrom(DrawableHitObject targetObject, JudgementResult targetResult)
|
||||||
|
{
|
||||||
|
this.targetObject = targetObject;
|
||||||
|
this.targetResult = targetResult;
|
||||||
|
|
||||||
|
updateColour();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateColour()
|
||||||
|
{
|
||||||
|
if (targetObject == null || targetResult == null)
|
||||||
|
Colour = Color4.White;
|
||||||
|
else
|
||||||
|
Colour = targetResult.IsHit ? targetObject.AccentColour.Value : Color4.Transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user