1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 00:17:21 +08:00

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

61 lines
2.1 KiB
C#
Raw Normal View History

2019-11-29 18:25:24 +09: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.
2018-04-13 18:19:50 +09:00
2019-05-10 19:44:22 +02: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;
using osu.Game.Rulesets.Mods;
2019-05-10 19:44:22 +02:00
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
2019-05-10 19:44:22 +02:00
using osuTK;
2018-04-13 18:19:50 +09:00
2019-05-11 10:03:59 +02:00
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset<CatchHitObject>, IApplicableToPlayer
2019-05-11 10:03:59 +02:00
{
public override string Description => @"Use the mouse to control the catcher.";
2019-05-10 19:44:22 +02:00
private DrawableRuleset<CatchHitObject> drawableRuleset;
2019-11-29 18:25:24 +09:00
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
{
this.drawableRuleset = drawableRuleset;
}
public void ApplyToPlayer(Player player)
{
if (!drawableRuleset.HasReplayLoaded.Value)
drawableRuleset.Cursor.Add(new MouseInputHelper((CatchPlayfield)drawableRuleset.Playfield));
2019-11-29 18:25:24 +09:00
}
2019-05-10 19:44:22 +02:00
2019-11-29 18:25:24 +09:00
private class MouseInputHelper : Drawable, IKeyBindingHandler<CatchAction>, IRequireHighFrequencyMousePosition
2019-05-11 10:03:59 +02:00
{
private readonly CatcherArea catcherArea;
2019-05-10 19:44:22 +02:00
2019-11-29 18:25:24 +09:00
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public MouseInputHelper(CatchPlayfield playfield)
2019-05-11 10:03:59 +02:00
{
catcherArea = playfield.CatcherArea;
2019-05-10 19:44:22 +02:00
RelativeSizeAxes = Axes.Both;
}
2020-05-04 18:31:11 -07:00
// disable keyboard controls
2021-09-16 18:26:12 +09:00
public bool OnPressed(KeyBindingPressEvent<CatchAction> e) => true;
2021-09-16 18:26:12 +09:00
public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
{
}
2019-05-10 19:44:22 +02:00
2019-05-11 10:03:59 +02:00
protected override bool OnMouseMove(MouseMoveEvent e)
{
catcherArea.SetCatcherPosition(e.MousePosition.X / DrawSize.X * CatchPlayfield.WIDTH);
2019-05-10 19:44:22 +02:00
return base.OnMouseMove(e);
}
}
}
}