2019-08-30 12:42:29 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-08-30 12:42:29 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2019-12-09 17:53:16 +08:00
|
|
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
2020-12-04 19:21:53 +08:00
|
|
|
using osu.Game.Skinning;
|
2019-08-30 12:42:29 +08:00
|
|
|
using osuTK;
|
|
|
|
|
2020-12-04 19:21:53 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2019-12-09 17:53:16 +08:00
|
|
|
public class LegacyCursor : OsuCursorSprite
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2021-06-06 21:26:27 +08:00
|
|
|
private readonly ISkin skin;
|
2019-12-09 13:43:23 +08:00
|
|
|
private bool spin;
|
|
|
|
|
2021-06-06 21:26:27 +08:00
|
|
|
public LegacyCursor(ISkin skin)
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2021-06-06 21:26:27 +08:00
|
|
|
this.skin = skin;
|
2019-08-30 12:42:29 +08:00
|
|
|
Size = new Vector2(50);
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-06-06 21:26:27 +08:00
|
|
|
private void load()
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2021-04-14 13:16:45 +08:00
|
|
|
bool centre = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorCentre)?.Value ?? true;
|
2019-12-09 13:43:23 +08:00
|
|
|
spin = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorRotate)?.Value ?? true;
|
|
|
|
|
2019-12-10 20:40:10 +08:00
|
|
|
InternalChildren = new[]
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2019-12-14 18:33:56 +08:00
|
|
|
ExpandTarget = new NonPlayfieldSprite
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2019-12-14 18:33:56 +08:00
|
|
|
Texture = skin.GetTexture("cursor"),
|
2019-08-30 12:42:29 +08:00
|
|
|
Anchor = Anchor.Centre,
|
2021-04-14 11:33:53 +08:00
|
|
|
Origin = centre ? Anchor.Centre : Anchor.TopLeft,
|
2019-08-30 12:42:29 +08:00
|
|
|
},
|
2019-12-14 18:33:56 +08:00
|
|
|
new NonPlayfieldSprite
|
2019-08-30 12:42:29 +08:00
|
|
|
{
|
2019-12-14 18:33:56 +08:00
|
|
|
Texture = skin.GetTexture("cursormiddle"),
|
2019-08-30 12:42:29 +08:00
|
|
|
Anchor = Anchor.Centre,
|
2021-04-14 11:33:53 +08:00
|
|
|
Origin = centre ? Anchor.Centre : Anchor.TopLeft,
|
2019-12-14 18:33:56 +08:00
|
|
|
},
|
2019-08-30 12:42:29 +08:00
|
|
|
};
|
2019-12-08 20:47:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
2019-12-09 12:11:04 +08:00
|
|
|
if (spin)
|
2019-12-09 17:53:16 +08:00
|
|
|
ExpandTarget.Spin(10000, RotationDirection.Clockwise);
|
2019-08-30 12:42:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|