1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

Merge pull request #24990 from peppy/argon-better-reverse

Add edge highlight to "argon" slider repeat arrow (and improve all skins' reverse arrow animations)
This commit is contained in:
Bartłomiej Dach 2023-10-03 10:55:11 +02:00 committed by GitHub
commit 9c1f5c35d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 197 additions and 78 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public SkinnableDrawable CirclePiece { get; private set; }
public ReverseArrowPiece Arrow { get; private set; }
public SkinnableDrawable Arrow { get; private set; }
private Drawable scaleContainer;
@ -65,7 +65,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
Arrow = new ReverseArrowPiece(),
Arrow = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new DefaultReverseArrow())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
});

View File

@ -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;
@ -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;
@ -31,24 +38,73 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
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;
}
}
}

View File

@ -0,0 +1,69 @@
// 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.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;
}
}
}

View File

@ -1,51 +0,0 @@
// 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.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public partial class ReverseArrowPiece : BeatSyncedContainer
{
[Resolved]
private DrawableHitObject drawableRepeat { get; set; } = null!;
public ReverseArrowPiece()
{
Divisor = 2;
MinimumBeatLength = 200;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Size = OsuHitObject.OBJECT_DIMENSIONS;
Child = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Icon = FontAwesome.Solid.ChevronRight,
Size = new Vector2(0.35f)
})
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
if (!drawableRepeat.IsHit)
Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out);
}
}
}

View File

@ -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;
@ -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!;
@ -27,6 +28,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private Drawable arrow = null!;
private bool shouldRotate;
[BackgroundDependencyLoader]
private void load(ISkinSource skinSource)
{
@ -36,8 +39,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
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()
@ -46,17 +58,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
proxy = CreateProxy();
if (drawableHitObject != null)
{
drawableHitObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableHitObject);
drawableObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableObject);
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);
}
accentColour = drawableObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(c =>
{
arrow.Colour = textureIsDefaultSkin && c.NewValue.R + c.NewValue.G + c.NewValue.B > (600 / 255f) ? Color4.Black : Color4.White;
}, true);
}
private void onHitObjectApplied(DrawableHitObject drawableObject)
@ -68,11 +77,43 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
.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;
}
}
}
}

View File

@ -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" />