2019-11-29 17:25:24 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-05-11 01:44:22 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2018-01-09 12:41:57 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2020-04-21 14:28:25 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Mods
|
|
|
|
|
{
|
2020-04-21 14:28:25 +08:00
|
|
|
|
public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset<CatchHitObject>, IApplicableToPlayer
|
2019-05-11 16:03:59 +08:00
|
|
|
|
{
|
2018-01-09 12:41:57 +08:00
|
|
|
|
public override string Description => @"Use the mouse to control the catcher.";
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
2020-04-21 14:28:25 +08:00
|
|
|
|
private DrawableRuleset<CatchHitObject> drawableRuleset;
|
|
|
|
|
|
2019-11-29 17:25:24 +08:00
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
|
|
|
|
|
{
|
2020-04-21 14:28:25 +08:00
|
|
|
|
this.drawableRuleset = drawableRuleset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ApplyToPlayer(Player player)
|
|
|
|
|
{
|
|
|
|
|
if (!drawableRuleset.HasReplayLoaded.Value)
|
|
|
|
|
drawableRuleset.Cursor.Add(new MouseInputHelper((CatchPlayfield)drawableRuleset.Playfield));
|
2019-11-29 17:25:24 +08:00
|
|
|
|
}
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
2019-11-29 17:25:24 +08:00
|
|
|
|
private class MouseInputHelper : Drawable, IKeyBindingHandler<CatchAction>, IRequireHighFrequencyMousePosition
|
2019-05-11 16:03:59 +08:00
|
|
|
|
{
|
2021-06-11 14:39:06 +08:00
|
|
|
|
private readonly CatcherArea catcherArea;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
2019-11-29 17:25:24 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
|
|
|
|
|
|
|
|
|
public MouseInputHelper(CatchPlayfield playfield)
|
2019-05-11 16:03:59 +08:00
|
|
|
|
{
|
2021-06-11 14:39:06 +08:00
|
|
|
|
catcherArea = playfield.CatcherArea;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 09:31:11 +08:00
|
|
|
|
// disable keyboard controls
|
2021-09-16 17:26:12 +08:00
|
|
|
|
public bool OnPressed(KeyBindingPressEvent<CatchAction> e) => true;
|
2020-01-22 12:22:34 +08:00
|
|
|
|
|
2021-09-16 17:26:12 +08:00
|
|
|
|
public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
|
2020-01-22 12:22:34 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
|
|
|
{
|
2021-06-11 14:39:06 +08:00
|
|
|
|
catcherArea.SetCatcherPosition(e.MousePosition.X / DrawSize.X * CatchPlayfield.WIDTH);
|
2019-05-11 01:44:22 +08:00
|
|
|
|
return base.OnMouseMove(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-09 12:41:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|