Make Column.AccentColour bindable

This commit is contained in:
Dean Herbert 2022-10-05 20:02:02 +09:00
parent 532d101080
commit 6b79f16461
10 changed files with 101 additions and 64 deletions

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
AccentColour = Color4.OrangeRed, AccentColour = { Value = Color4.OrangeRed },
Clock = new FramedClock(new StopwatchClock()), // No scroll Clock = new FramedClock(new StopwatchClock()), // No scroll
}); });
} }

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
this.column = new Column(column, false) this.column = new Column(column, false)
{ {
Action = { Value = action }, Action = { Value = action },
AccentColour = Color4.Orange, AccentColour = { Value = Color4.Orange },
Alpha = showColumn ? 1 : 0 Alpha = showColumn ? 1 : 0
}, },
content = new ManiaInputManager(new ManiaRuleset().RulesetInfo, 4) content = new ManiaInputManager(new ManiaRuleset().RulesetInfo, 4)

View File

@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.Tests
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Height = 0.85f, Height = 0.85f,
AccentColour = Color4.OrangeRed, AccentColour = { Value = Color4.OrangeRed },
Action = { Value = action }, Action = { Value = action },
}; };

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{ {
Action = { Value = ManiaAction.Key1 }, Action = { Value = ManiaAction.Key1 },
Height = 0.85f, Height = 0.85f,
AccentColour = Color4.Gray AccentColour = { Value = Color4.Gray },
}, },
}; };
}); });

View File

@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
private Container<Circle> bottomIcon = null!; private Container<Circle> bottomIcon = null!;
private CircularContainer topIcon = null!; private CircularContainer topIcon = null!;
private Bindable<Color4> accentColour = null!;
[Resolved] [Resolved]
private Column column { get; set; } = null!; private Column column { get; set; } = null!;
@ -55,7 +57,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
{ {
Name = "Key gradient", Name = "Key gradient",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = column.AccentColour.Darken(0.6f),
}, },
hitTargetLine = new Circle hitTargetLine = new Circle
{ {
@ -80,7 +81,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
Colour = column.AccentColour,
Y = icon_vertical_offset, Y = icon_vertical_offset,
Children = new[] Children = new[]
{ {
@ -134,6 +134,13 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);
accentColour = column.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(colour =>
{
background.Colour = colour.NewValue.Darken(0.6f);
bottomIcon.Colour = colour.NewValue;
}, true);
} }
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction) private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
@ -159,11 +166,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
if (e.Action != column.Action.Value) return false; if (e.Action != column.Action.Value) return false;
const double lighting_fade_in_duration = 50; const double lighting_fade_in_duration = 50;
Color4 lightingColour = column.AccentColour.Lighten(0.9f); Color4 lightingColour = accentColour.Value.Lighten(0.9f);
background background
.FadeColour(column.AccentColour.Lighten(0.4f), 40).Then() .FadeColour(accentColour.Value.Lighten(0.4f), 40).Then()
.FadeColour(column.AccentColour, 150, Easing.OutQuint); .FadeColour(accentColour.Value, 150, Easing.OutQuint);
hitTargetLine.FadeColour(Color4.White, lighting_fade_in_duration, Easing.OutQuint); hitTargetLine.FadeColour(Color4.White, lighting_fade_in_duration, Easing.OutQuint);
hitTargetLine.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters hitTargetLine.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
@ -201,9 +208,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
if (e.Action != column.Action.Value) return; if (e.Action != column.Action.Value) return;
const double lighting_fade_out_duration = 300; const double lighting_fade_out_duration = 300;
Color4 lightingColour = column.AccentColour.Lighten(0.9f).Opacity(0); Color4 lightingColour = accentColour.Value.Lighten(0.9f).Opacity(0);
background.FadeColour(column.AccentColour.Darken(0.6f), lighting_fade_out_duration, Easing.OutQuint); background.FadeColour(accentColour.Value.Darken(0.6f), lighting_fade_out_duration, Easing.OutQuint);
topIcon.ScaleTo(1f, 200, Easing.OutQuint); topIcon.ScaleTo(1f, 200, Easing.OutQuint);
topIcon.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters topIcon.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
@ -221,7 +228,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
Radius = 30, Radius = 30,
}, lighting_fade_out_duration, Easing.OutQuint); }, lighting_fade_out_duration, Easing.OutQuint);
bottomIcon.FadeColour(column.AccentColour, lighting_fade_out_duration, Easing.OutQuint); bottomIcon.FadeColour(accentColour.Value, lighting_fade_out_duration, Easing.OutQuint);
foreach (var circle in bottomIcon) foreach (var circle in bottomIcon)
{ {

View File

@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.UI
/// </summary> /// </summary>
public readonly bool IsSpecial; public readonly bool IsSpecial;
public Color4 AccentColour { get; set; } public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Black);
public Column(int index, bool isSpecial) public Column(int index, bool isSpecial)
{ {
@ -77,6 +77,13 @@ namespace osu.Game.Rulesets.Mania.UI
skin.SourceChanged += onSourceChanged; skin.SourceChanged += onSourceChanged;
onSourceChanged(); onSourceChanged();
AccentColour.BindValueChanged(colour =>
{
// Manual transfer as hit objects may be moved between column and unbinding is non-trivial.
foreach (var obj in HitObjectContainer.Objects)
obj.AccentColour.Value = colour.NewValue;
}, true);
Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground()) Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
@ -109,9 +116,7 @@ namespace osu.Game.Rulesets.Mania.UI
private void onSourceChanged() private void onSourceChanged()
{ {
AccentColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour, stageDefinition, Index)?.Value ?? Color4.Black; AccentColour.Value = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour, stageDefinition, Index)?.Value ?? Color4.Black;
foreach (var obj in HitObjectContainer.Objects)
obj.AccentColour.Value = AccentColour;
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -139,7 +144,7 @@ namespace osu.Game.Rulesets.Mania.UI
DrawableManiaHitObject maniaObject = (DrawableManiaHitObject)drawableHitObject; DrawableManiaHitObject maniaObject = (DrawableManiaHitObject)drawableHitObject;
maniaObject.AccentColour.Value = AccentColour; maniaObject.AccentColour.Value = AccentColour.Value;
maniaObject.CheckHittable = hitPolicy.IsHittable; maniaObject.CheckHittable = hitPolicy.IsHittable;
} }

View File

@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
[Resolved] [Resolved]
private Column column { get; set; } private Column column { get; set; }
private Bindable<Color4> accentColour;
public DefaultColumnBackground() public DefaultColumnBackground()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -55,9 +57,13 @@ namespace osu.Game.Rulesets.Mania.UI.Components
} }
}; };
background.Colour = column.AccentColour.Darken(5); accentColour = column.AccentColour.GetBoundCopy();
brightColour = column.AccentColour.Opacity(0.6f); accentColour.BindValueChanged(colour =>
dimColour = column.AccentColour.Opacity(0); {
background.Colour = colour.NewValue.Darken(5);
brightColour = colour.NewValue.Opacity(0.6f);
dimColour = colour.NewValue.Opacity(0);
}, true);
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);

View File

@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
private Container hitTargetLine; private Container hitTargetLine;
private Drawable hitTargetBar; private Drawable hitTargetBar;
private Bindable<Color4> accentColour;
[Resolved] [Resolved]
private Column column { get; set; } private Column column { get; set; }
@ -54,12 +56,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
}, },
}; };
hitTargetLine.EdgeEffect = new EdgeEffectParameters accentColour = column.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(colour =>
{ {
Type = EdgeEffectType.Glow, hitTargetLine.EdgeEffect = new EdgeEffectParameters
Radius = 5, {
Colour = column.AccentColour.Opacity(0.5f), Type = EdgeEffectType.Glow,
}; Radius = 5,
Colour = colour.NewValue.Opacity(0.5f),
};
}, true);
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);

View File

@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components
private Container keyIcon; private Container keyIcon;
private Drawable gradient; private Drawable gradient;
private Bindable<Color4> accentColour;
[Resolved] [Resolved]
private Column column { get; set; } private Column column { get; set; }
@ -75,15 +77,19 @@ namespace osu.Game.Rulesets.Mania.UI.Components
} }
}; };
keyIcon.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Radius = 5,
Colour = column.AccentColour.Opacity(0.5f),
};
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);
accentColour = column.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(colour =>
{
keyIcon.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Radius = 5,
Colour = colour.NewValue.Opacity(0.5f),
};
});
} }
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction) private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)

View File

@ -32,6 +32,10 @@ namespace osu.Game.Rulesets.Mania.UI
private CircularContainer largeFaint; private CircularContainer largeFaint;
private CircularContainer mainGlow1; private CircularContainer mainGlow1;
private CircularContainer mainGlow2;
private CircularContainer mainGlow3;
private Bindable<Color4> accentColour;
public DefaultHitExplosion() public DefaultHitExplosion()
{ {
@ -48,8 +52,6 @@ namespace osu.Game.Rulesets.Mania.UI
const float roundness = 80; const float roundness = 80;
const float initial_height = 10; const float initial_height = 10;
var colour = Interpolation.ValueAt(0.4f, column.AccentColour, Color4.White, 0, 1);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
largeFaint = new CircularContainer largeFaint = new CircularContainer
@ -61,13 +63,6 @@ namespace osu.Game.Rulesets.Mania.UI
// we want our size to be very small so the glow dominates it. // we want our size to be very small so the glow dominates it.
Size = new Vector2(default_large_faint_size), Size = new Vector2(default_large_faint_size),
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.1f, column.AccentColour, Color4.White, 0, 1).Opacity(0.3f),
Roundness = 160,
Radius = 200,
},
}, },
mainGlow1 = new CircularContainer mainGlow1 = new CircularContainer
{ {
@ -76,15 +71,8 @@ namespace osu.Game.Rulesets.Mania.UI
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.6f, column.AccentColour, Color4.White, 0, 1),
Roundness = 20,
Radius = 50,
},
}, },
new CircularContainer mainGlow2 = new CircularContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -93,15 +81,8 @@ namespace osu.Game.Rulesets.Mania.UI
Size = new Vector2(0.01f, initial_height), Size = new Vector2(0.01f, initial_height),
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
Rotation = RNG.NextSingle(-angle_variance, angle_variance), Rotation = RNG.NextSingle(-angle_variance, angle_variance),
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = colour,
Roundness = roundness,
Radius = 40,
},
}, },
new CircularContainer mainGlow3 = new CircularContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -110,18 +91,44 @@ namespace osu.Game.Rulesets.Mania.UI
Size = new Vector2(0.01f, initial_height), Size = new Vector2(0.01f, initial_height),
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
Rotation = RNG.NextSingle(-angle_variance, angle_variance), Rotation = RNG.NextSingle(-angle_variance, angle_variance),
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = colour,
Roundness = roundness,
Radius = 40,
},
} }
}; };
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);
accentColour = column.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(colour =>
{
largeFaint.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.1f, colour.NewValue, Color4.White, 0, 1).Opacity(0.3f),
Roundness = 160,
Radius = 200,
};
mainGlow1.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.6f, colour.NewValue, Color4.White, 0, 1),
Roundness = 20,
Radius = 50,
};
mainGlow2.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.4f, colour.NewValue, Color4.White, 0, 1),
Roundness = roundness,
Radius = 40,
};
mainGlow3.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Colour = Interpolation.ValueAt(0.4f, colour.NewValue, Color4.White, 0, 1),
Roundness = roundness,
Radius = 40,
};
}, true);
} }
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction) private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)