Skip to content

Commit

Permalink
Merge pull request #24990 from peppy/argon-better-reverse
Browse files Browse the repository at this point in the history
Add edge highlight to "argon" slider repeat arrow (and improve all skins' reverse arrow animations)
  • Loading branch information
bdach authored Oct 3, 2023
2 parents 5338ba9 + 2cbec6d commit 9c1f5c3
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 78 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class DrawableSliderRepeat : DrawableOsuHitObject, ITrackSnaking

public SkinnableDrawable CirclePiece { get; private set; }

public ReverseArrowPiece Arrow { get; private set; }
public SkinnableDrawable Arrow { get; private set; }

private Drawable scaleContainer;

Expand Down Expand Up @@ -65,7 +65,11 @@ private void load()
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Arrow = new ReverseArrowPiece(),
Arrow = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new DefaultReverseArrow())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
});

Expand Down
74 changes: 65 additions & 9 deletions osu.Game.Rulesets.Osu/Skinning/Argon/ArgonReverseArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;
Expand All @@ -17,12 +19,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonReverseArrow : CompositeDrawable
{
[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;

private Bindable<Color4> accentColour = null!;

private SpriteIcon icon = null!;
private Container main = null!;
private Sprite side = null!;

[BackgroundDependencyLoader]
private void load(DrawableHitObject hitObject)
private void load(TextureStore textures)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand All @@ -31,24 +38,73 @@ private void load(DrawableHitObject hitObject)

InternalChildren = new Drawable[]
{
new Circle
main = new Container
{
Size = new Vector2(40, 20),
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Circle
{
Size = new Vector2(40, 20),
Colour = Color4.White,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
icon = new SpriteIcon
{
Icon = FontAwesome.Solid.AngleDoubleRight,
Size = new Vector2(16),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
},
icon = new SpriteIcon
side = new Sprite
{
Icon = FontAwesome.Solid.AngleDoubleRight,
Size = new Vector2(16),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Texture = textures.Get("Gameplay/osu/repeat-edge-piece"),
Size = new Vector2(ArgonMainCirclePiece.OUTER_GRADIENT_SIZE),
}
};

accentColour = hitObject.AccentColour.GetBoundCopy();
accentColour = drawableObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(accent => icon.Colour = accent.NewValue.Darken(4), true);

drawableObject.ApplyCustomUpdateState += updateStateTransforms;
}

private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const float move_distance = -12;
const double move_out_duration = 35;
const double move_in_duration = 250;
const double total = 300;

switch (state)
{
case ArmedState.Idle:
main.ScaleTo(1.3f, move_out_duration, Easing.Out)
.Then()
.ScaleTo(1f, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
side
.MoveToX(move_distance, move_out_duration, Easing.Out)
.Then()
.MoveToX(0, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
break;
}
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

if (drawableObject.IsNotNull())
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
}
}
}
69 changes: 69 additions & 0 deletions osu.Game.Rulesets.Osu/Skinning/Default/DefaultReverseArrow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public partial class DefaultReverseArrow : CompositeDrawable
{
[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;

public DefaultReverseArrow()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

Size = OsuHitObject.OBJECT_DIMENSIONS;

InternalChild = new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Icon = FontAwesome.Solid.ChevronRight,
Size = new Vector2(0.35f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}

[BackgroundDependencyLoader]
private void load()
{
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
}

private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const double move_out_duration = 35;
const double move_in_duration = 250;
const double total = 300;

switch (state)
{
case ArmedState.Idle:
InternalChild.ScaleTo(1.3f, move_out_duration, Easing.Out)
.Then()
.ScaleTo(1f, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
break;
}
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

if (drawableObject.IsNotNull())
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
}
}
}
51 changes: 0 additions & 51 deletions osu.Game.Rulesets.Osu/Skinning/Default/ReverseArrowPiece.cs

This file was deleted.

71 changes: 56 additions & 15 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyReverseArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
Expand All @@ -16,8 +17,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public partial class LegacyReverseArrow : CompositeDrawable
{
[Resolved(canBeNull: true)]
private DrawableHitObject? drawableHitObject { get; set; }
[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;

private Drawable proxy = null!;

Expand All @@ -27,6 +28,8 @@ public partial class LegacyReverseArrow : CompositeDrawable

private Drawable arrow = null!;

private bool shouldRotate;

[BackgroundDependencyLoader]
private void load(ISkinSource skinSource)
{
Expand All @@ -36,8 +39,17 @@ private void load(ISkinSource skinSource)

var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null);

InternalChild = arrow = (skin?.GetAnimation(lookupName, true, true, maxSize: OsuHitObject.OBJECT_DIMENSIONS) ?? Empty());
InternalChild = arrow = (skin?.GetAnimation(lookupName, true, true, maxSize: OsuHitObject.OBJECT_DIMENSIONS) ?? Empty()).With(d =>
{
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
});

textureIsDefaultSkin = skin is ISkinTransformer transformer && transformer.Skin is DefaultLegacySkin;

drawableObject.ApplyCustomUpdateState += updateStateTransforms;

shouldRotate = skinSource.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value <= 1;
}

protected override void LoadComplete()
Expand All @@ -46,17 +58,14 @@ protected override void LoadComplete()

proxy = CreateProxy();

if (drawableHitObject != null)
drawableObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableObject);

accentColour = drawableObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(c =>
{
drawableHitObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableHitObject);

accentColour = drawableHitObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(c =>
{
arrow.Colour = textureIsDefaultSkin && c.NewValue.R + c.NewValue.G + c.NewValue.B > (600 / 255f) ? Color4.Black : Color4.White;
}, true);
}
arrow.Colour = textureIsDefaultSkin && c.NewValue.R + c.NewValue.G + c.NewValue.B > (600 / 255f) ? Color4.Black : Color4.White;
}, true);
}

private void onHitObjectApplied(DrawableHitObject drawableObject)
Expand All @@ -68,11 +77,43 @@ private void onHitObjectApplied(DrawableHitObject drawableObject)
.OverlayElementContainer.Add(proxy);
}

private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const double duration = 300;
const float rotation = 5.625f;

switch (state)
{
case ArmedState.Idle:
if (shouldRotate)
{
InternalChild.ScaleTo(1.3f)
.RotateTo(rotation)
.Then()
.ScaleTo(1f, duration)
.RotateTo(-rotation, duration)
.Loop();
}
else
{
InternalChild.ScaleTo(1.3f).Then()
.ScaleTo(1f, duration, Easing.Out)
.Loop();
}

break;
}
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (drawableHitObject != null)
drawableHitObject.HitObjectApplied -= onHitObjectApplied;

if (drawableObject.IsNotNull())
{
drawableObject.HitObjectApplied -= onHitObjectApplied;
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
}
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="11.5.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.922.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.928.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1003.0" />
<PackageReference Include="Sentry" Version="3.39.1" />
<PackageReference Include="SharpCompress" Version="0.33.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
Expand Down

0 comments on commit 9c1f5c3

Please sign in to comment.