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