2023-04-29 15:05:45 +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;
|
2023-04-29 15:06:08 +08:00
|
|
|
using osu.Framework.Graphics;
|
2023-04-29 15:05:45 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-04-29 15:06:08 +08:00
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Input.Events;
|
2023-04-29 15:05:45 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Configuration;
|
2023-04-29 15:06:08 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
2023-04-29 15:05:45 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|
|
|
{
|
2023-04-29 15:06:08 +08:00
|
|
|
public partial class CursorRippleVisualiser : CompositeDrawable, IKeyBindingHandler<OsuAction>
|
2023-04-29 15:05:45 +08:00
|
|
|
{
|
|
|
|
private readonly Bindable<bool> showRipples = new Bindable<bool>(true);
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2023-04-29 15:06:08 +08:00
|
|
|
private void load(OsuRulesetConfigManager? rulesetConfig)
|
2023-04-29 15:05:45 +08:00
|
|
|
{
|
2023-04-29 15:06:08 +08:00
|
|
|
rulesetConfig?.BindWith(OsuRulesetSetting.ShowCursorRipples, showRipples);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
|
|
|
{
|
|
|
|
if (showRipples.Value)
|
|
|
|
{
|
|
|
|
var ripple = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.CursorRipple), _ => new DefaultCursorRipple())
|
|
|
|
{
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Position = e.MousePosition
|
|
|
|
};
|
|
|
|
|
|
|
|
AddInternal(ripple);
|
|
|
|
|
|
|
|
ripple.ScaleTo(0.05f)
|
|
|
|
.ScaleTo(0.5f, 700, Easing.Out)
|
|
|
|
.FadeTo(0.2f)
|
|
|
|
.FadeOut(700)
|
|
|
|
.Expire();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public partial class DefaultCursorRipple : CompositeDrawable
|
|
|
|
{
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new RingPiece(3)
|
|
|
|
{
|
|
|
|
Size = new Vector2(512),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-04-29 15:05:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|