2021-09-01 18:34:57 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-09-18 22:27:30 +08:00
|
|
|
using System.Diagnostics;
|
2021-09-01 18:34:57 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-05-03 11:37:07 +08:00
|
|
|
using osu.Framework.Bindables;
|
2021-09-01 18:34:57 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2023-09-19 09:37:09 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2021-09-01 18:34:57 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
2023-05-03 11:37:07 +08:00
|
|
|
using osuTK.Graphics;
|
2021-09-01 18:34:57 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|
|
|
{
|
|
|
|
public partial class LegacyReverseArrow : CompositeDrawable
|
|
|
|
{
|
|
|
|
[Resolved(canBeNull: true)]
|
2022-11-09 12:36:52 +08:00
|
|
|
private DrawableHitObject? drawableHitObject { get; set; }
|
2021-09-01 18:34:57 +08:00
|
|
|
|
2022-11-09 12:36:52 +08:00
|
|
|
private Drawable proxy = null!;
|
2021-09-18 22:27:30 +08:00
|
|
|
|
2023-05-03 11:37:07 +08:00
|
|
|
private Bindable<Color4> accentColour = null!;
|
|
|
|
|
|
|
|
private bool textureIsDefaultSkin;
|
|
|
|
|
|
|
|
private Drawable arrow = null!;
|
|
|
|
|
2021-09-19 00:24:36 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2021-09-28 03:45:26 +08:00
|
|
|
private void load(ISkinSource skinSource)
|
2021-09-01 18:34:57 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
string lookupName = new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow).LookupName;
|
2021-09-01 18:34:57 +08:00
|
|
|
|
2021-09-28 04:21:14 +08:00
|
|
|
var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null);
|
2023-05-03 11:37:07 +08:00
|
|
|
|
2023-09-20 11:48:15 +08:00
|
|
|
InternalChild = arrow = (skin?.GetAnimation(lookupName, true, true, maxSize: OsuHitObject.OBJECT_DIMENSIONS) ?? Empty());
|
2023-05-03 11:37:07 +08:00
|
|
|
textureIsDefaultSkin = skin is ISkinTransformer transformer && transformer.Skin is DefaultLegacySkin;
|
2021-09-01 18:34:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-09-18 22:27:30 +08:00
|
|
|
proxy = CreateProxy();
|
|
|
|
|
|
|
|
if (drawableHitObject != null)
|
|
|
|
{
|
|
|
|
drawableHitObject.HitObjectApplied += onHitObjectApplied;
|
|
|
|
onHitObjectApplied(drawableHitObject);
|
2023-05-03 11:37:07 +08:00
|
|
|
|
|
|
|
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);
|
2021-09-18 22:27:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onHitObjectApplied(DrawableHitObject drawableObject)
|
|
|
|
{
|
|
|
|
Debug.Assert(proxy.Parent == null);
|
|
|
|
|
2021-09-01 18:34:57 +08:00
|
|
|
// see logic in LegacySliderHeadHitCircle.
|
2021-09-18 22:27:30 +08:00
|
|
|
(drawableObject as DrawableSliderRepeat)?.DrawableSlider
|
|
|
|
.OverlayElementContainer.Add(proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
if (drawableHitObject != null)
|
|
|
|
drawableHitObject.HitObjectApplied -= onHitObjectApplied;
|
2021-09-01 18:34:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|