mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 17:47:18 +08:00
Fix handling of bindable changes in accent colour
This commit is contained in:
parent
f245fe5934
commit
0f85e81240
@ -10,8 +10,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
public class DrawableDroplet : PalpableCatchHitObject<Droplet>
|
||||
{
|
||||
private Pulp pulp;
|
||||
|
||||
public override bool StaysOnPlate => false;
|
||||
|
||||
public DrawableDroplet(Droplet h)
|
||||
@ -25,9 +23,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(pulp = new Pulp { Size = Size });
|
||||
|
||||
AccentColour.BindValueChanged(colour => { pulp.AccentColour = colour.NewValue; }, true);
|
||||
AddInternal(new Pulp
|
||||
{
|
||||
Size = Size,
|
||||
AccentColour = { BindTarget = AccentColour }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
switch (hitObject)
|
||||
{
|
||||
case CatchHitObject catchObject:
|
||||
return createDrawableRepresentation?.Invoke(catchObject)?.With(o => ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
|
||||
return createDrawableRepresentation?.Invoke(catchObject)?.With(o =>
|
||||
((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
|
||||
}
|
||||
|
||||
return base.CreateNestedHitObject(hitObject);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
new Box
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Colour = drawableCatchObject.AccentColour.Value,
|
||||
Alpha = 0,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
@ -71,7 +70,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AccentColour = Color4.Red,
|
||||
AccentColour = { Value = Color4.Red },
|
||||
Blending = BlendingParameters.Additive,
|
||||
Alpha = 0.5f,
|
||||
Scale = new Vector2(1.333f)
|
||||
@ -113,32 +112,32 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(small_pulp),
|
||||
Y = -0.34f,
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(0, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(90, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(180, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
Size = new Vector2(large_pulp_4),
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Position = positionAt(270, distance_from_centre_4),
|
||||
},
|
||||
}
|
||||
@ -152,32 +151,32 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(small_pulp),
|
||||
Y = -0.3f,
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(45, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(135, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_4),
|
||||
Position = positionAt(225, distance_from_centre_4),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
Size = new Vector2(large_pulp_4),
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Position = positionAt(315, distance_from_centre_4),
|
||||
},
|
||||
}
|
||||
@ -191,26 +190,26 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(small_pulp),
|
||||
Y = -0.33f,
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_3),
|
||||
Position = positionAt(60, distance_from_centre_3),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_3),
|
||||
Position = positionAt(180, distance_from_centre_3),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
Size = new Vector2(large_pulp_3),
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Position = positionAt(300, distance_from_centre_3),
|
||||
},
|
||||
}
|
||||
@ -224,26 +223,26 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(small_pulp),
|
||||
Y = -0.25f,
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_3),
|
||||
Position = positionAt(0, distance_from_centre_3),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Size = new Vector2(large_pulp_3),
|
||||
Position = positionAt(120, distance_from_centre_3),
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
Size = new Vector2(large_pulp_3),
|
||||
AccentColour = accentColour.Value,
|
||||
AccentColour = { BindTarget = accentColour },
|
||||
Position = positionAt(240, distance_from_centre_3),
|
||||
},
|
||||
}
|
||||
@ -260,13 +259,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
{
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = bananaColour,
|
||||
AccentColour = { Value = bananaColour },
|
||||
Size = new Vector2(small_pulp),
|
||||
Y = -0.3f
|
||||
},
|
||||
new Pulp
|
||||
{
|
||||
AccentColour = bananaColour,
|
||||
AccentColour = { Value = bananaColour },
|
||||
Size = new Vector2(large_pulp_4 * 0.8f, large_pulp_4 * 2.5f),
|
||||
Y = 0.05f,
|
||||
},
|
||||
|
@ -1,16 +1,16 @@
|
||||
// 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.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces
|
||||
{
|
||||
public class Pulp : Circle, IHasAccentColour
|
||||
public class Pulp : Circle
|
||||
{
|
||||
public Pulp()
|
||||
{
|
||||
@ -22,32 +22,23 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces
|
||||
Colour = Color4.White.Opacity(0.9f);
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
||||
|
||||
public Color4 AccentColour
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (IsLoaded) updateAccentColour();
|
||||
}
|
||||
base.LoadComplete();
|
||||
|
||||
AccentColour.BindValueChanged(updateAccentColour, true);
|
||||
}
|
||||
|
||||
private void updateAccentColour()
|
||||
private void updateAccentColour(ValueChangedEvent<Color4> colour)
|
||||
{
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Radius = Size.X / 2,
|
||||
Colour = accentColour.Darken(0.2f).Opacity(0.75f)
|
||||
Colour = colour.NewValue.Darken(0.2f).Opacity(0.75f)
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateAccentColour();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
||||
private readonly string lookupName;
|
||||
|
||||
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
||||
private Sprite colouredSprite;
|
||||
|
||||
public LegacyFruitPiece(string lookupName)
|
||||
{
|
||||
@ -34,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
colouredSprite = new Sprite
|
||||
{
|
||||
Texture = skin.GetTexture(lookupName),
|
||||
Colour = drawableObject.AccentColour.Value,
|
||||
@ -49,5 +50,12 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
accentColour.BindValueChanged(colour => colouredSprite.Colour = colour.NewValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user