mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix handling of bindable changes in accent colour
This commit is contained in:
@ -10,8 +10,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
public class DrawableDroplet : PalpableCatchHitObject<Droplet>
|
public class DrawableDroplet : PalpableCatchHitObject<Droplet>
|
||||||
{
|
{
|
||||||
private Pulp pulp;
|
|
||||||
|
|
||||||
public override bool StaysOnPlate => false;
|
public override bool StaysOnPlate => false;
|
||||||
|
|
||||||
public DrawableDroplet(Droplet h)
|
public DrawableDroplet(Droplet h)
|
||||||
@ -25,9 +23,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
AddInternal(pulp = new Pulp { Size = Size });
|
AddInternal(new Pulp
|
||||||
|
{
|
||||||
AccentColour.BindValueChanged(colour => { pulp.AccentColour = colour.NewValue; }, true);
|
Size = Size,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
switch (hitObject)
|
switch (hitObject)
|
||||||
{
|
{
|
||||||
case CatchHitObject catchObject:
|
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
|
new Box
|
||||||
{
|
{
|
||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
Colour = drawableCatchObject.AccentColour.Value,
|
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
}
|
}
|
||||||
@ -71,7 +70,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AccentColour = Color4.Red,
|
AccentColour = { Value = Color4.Red },
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
Alpha = 0.5f,
|
Alpha = 0.5f,
|
||||||
Scale = new Vector2(1.333f)
|
Scale = new Vector2(1.333f)
|
||||||
@ -113,32 +112,32 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(small_pulp),
|
Size = new Vector2(small_pulp),
|
||||||
Y = -0.34f,
|
Y = -0.34f,
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(0, distance_from_centre_4),
|
Position = positionAt(0, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(90, distance_from_centre_4),
|
Position = positionAt(90, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(180, distance_from_centre_4),
|
Position = positionAt(180, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Position = positionAt(270, distance_from_centre_4),
|
Position = positionAt(270, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -152,32 +151,32 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(small_pulp),
|
Size = new Vector2(small_pulp),
|
||||||
Y = -0.3f,
|
Y = -0.3f,
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(45, distance_from_centre_4),
|
Position = positionAt(45, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(135, distance_from_centre_4),
|
Position = positionAt(135, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
Position = positionAt(225, distance_from_centre_4),
|
Position = positionAt(225, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
Size = new Vector2(large_pulp_4),
|
Size = new Vector2(large_pulp_4),
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Position = positionAt(315, distance_from_centre_4),
|
Position = positionAt(315, distance_from_centre_4),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -191,26 +190,26 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(small_pulp),
|
Size = new Vector2(small_pulp),
|
||||||
Y = -0.33f,
|
Y = -0.33f,
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
Position = positionAt(60, distance_from_centre_3),
|
Position = positionAt(60, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
Position = positionAt(180, distance_from_centre_3),
|
Position = positionAt(180, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Position = positionAt(300, distance_from_centre_3),
|
Position = positionAt(300, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -224,26 +223,26 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(small_pulp),
|
Size = new Vector2(small_pulp),
|
||||||
Y = -0.25f,
|
Y = -0.25f,
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
Position = positionAt(0, distance_from_centre_3),
|
Position = positionAt(0, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
Position = positionAt(120, distance_from_centre_3),
|
Position = positionAt(120, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
Size = new Vector2(large_pulp_3),
|
Size = new Vector2(large_pulp_3),
|
||||||
AccentColour = accentColour.Value,
|
AccentColour = { BindTarget = accentColour },
|
||||||
Position = positionAt(240, distance_from_centre_3),
|
Position = positionAt(240, distance_from_centre_3),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -260,13 +259,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
{
|
{
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = bananaColour,
|
AccentColour = { Value = bananaColour },
|
||||||
Size = new Vector2(small_pulp),
|
Size = new Vector2(small_pulp),
|
||||||
Y = -0.3f
|
Y = -0.3f
|
||||||
},
|
},
|
||||||
new Pulp
|
new Pulp
|
||||||
{
|
{
|
||||||
AccentColour = bananaColour,
|
AccentColour = { Value = bananaColour },
|
||||||
Size = new Vector2(large_pulp_4 * 0.8f, large_pulp_4 * 2.5f),
|
Size = new Vector2(large_pulp_4 * 0.8f, large_pulp_4 * 2.5f),
|
||||||
Y = 0.05f,
|
Y = 0.05f,
|
||||||
},
|
},
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces
|
||||||
{
|
{
|
||||||
public class Pulp : Circle, IHasAccentColour
|
public class Pulp : Circle
|
||||||
{
|
{
|
||||||
public Pulp()
|
public Pulp()
|
||||||
{
|
{
|
||||||
@ -22,32 +22,23 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces
|
|||||||
Colour = Color4.White.Opacity(0.9f);
|
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;
|
base.LoadComplete();
|
||||||
set
|
|
||||||
{
|
AccentColour.BindValueChanged(updateAccentColour, true);
|
||||||
accentColour = value;
|
|
||||||
if (IsLoaded) updateAccentColour();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAccentColour()
|
private void updateAccentColour(ValueChangedEvent<Color4> colour)
|
||||||
{
|
{
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Glow,
|
Type = EdgeEffectType.Glow,
|
||||||
Radius = Size.X / 2,
|
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 string lookupName;
|
||||||
|
|
||||||
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
||||||
|
private Sprite colouredSprite;
|
||||||
|
|
||||||
public LegacyFruitPiece(string lookupName)
|
public LegacyFruitPiece(string lookupName)
|
||||||
{
|
{
|
||||||
@ -34,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Skinning
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Sprite
|
colouredSprite = new Sprite
|
||||||
{
|
{
|
||||||
Texture = skin.GetTexture(lookupName),
|
Texture = skin.GetTexture(lookupName),
|
||||||
Colour = drawableObject.AccentColour.Value,
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user