1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 15:13:22 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyHitTarget.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
2.9 KiB
C#
Raw Normal View History

2020-03-31 11:17:44 +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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2020-03-31 11:26:31 +08:00
using osu.Framework.Graphics.Shapes;
2020-03-31 11:17:44 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
using osuTK;
2020-04-07 15:50:08 +08:00
using osuTK.Graphics;
2020-03-31 11:17:44 +08:00
2020-12-07 11:32:52 +08:00
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
2020-03-31 11:17:44 +08:00
{
public partial class LegacyHitTarget : CompositeDrawable
2020-03-31 11:17:44 +08:00
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Container directionContainer = null!;
2020-03-31 11:17:44 +08:00
[BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{
string targetImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.HitTargetImage)?.Value
2020-03-31 11:17:44 +08:00
?? "mania-stage-hint";
bool showJudgementLine = skin.GetManiaSkinConfig<bool>(LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
2020-03-31 11:26:31 +08:00
?? true;
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
2020-04-07 15:50:08 +08:00
?? Color4.White;
2020-03-31 11:17:44 +08:00
InternalChild = directionContainer = new Container
{
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2020-03-31 11:26:31 +08:00
Children = new Drawable[]
2020-03-31 11:17:44 +08:00
{
2020-03-31 11:26:31 +08:00
new Sprite
{
Texture = skin.GetTexture(targetImage),
Scale = new Vector2(1, 0.9f * 1.6025f),
RelativeSizeAxes = Axes.X,
Width = 1
},
new Box
{
Anchor = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
2020-08-25 14:16:41 +08:00
Colour = LegacyColourCompatibility.DisallowZeroAlpha(lineColour),
2020-03-31 11:26:31 +08:00
Alpha = showJudgementLine ? 0.9f : 0
}
2020-03-31 11:17:44 +08:00
}
};
direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true);
}
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
if (direction.NewValue == ScrollingDirection.Up)
{
directionContainer.Anchor = Anchor.TopLeft;
directionContainer.Scale = new Vector2(1, -1);
}
else
{
directionContainer.Anchor = Anchor.BottomLeft;
directionContainer.Scale = Vector2.One;
}
}
}
}