2019-11-29 18:25:24 +09:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 17:43:03 +09:00
|
|
|
|
// 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;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-05-10 19:44:22 +02:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
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>
|
|
|
|
|
{
|
2018-04-13 18:19:50 +09:00
|
|
|
|
public override string Description => @"Use the mouse to control the catcher.";
|
2019-05-10 19:44:22 +02:00
|
|
|
|
|
2019-11-29 18:25:24 +09:00
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
|
|
|
|
|
{
|
|
|
|
|
drawableRuleset.Cursor.Add(new MouseInputHelper((CatchPlayfield)drawableRuleset.Playfield));
|
|
|
|
|
}
|
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
|
|
|
|
{
|
2020-03-13 12:59:30 +09:00
|
|
|
|
private readonly Catcher catcher;
|
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
|
|
|
|
{
|
2019-11-29 18:25:24 +09:00
|
|
|
|
catcher = playfield.CatcherArea.MovableCatcher;
|
2019-05-10 19:44:22 +02:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//disable keyboard controls
|
|
|
|
|
public bool OnPressed(CatchAction action) => true;
|
2020-01-22 13:22:34 +09:00
|
|
|
|
|
|
|
|
|
public void OnReleased(CatchAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-05-10 19:44:22 +02:00
|
|
|
|
|
2019-05-11 10:03:59 +02:00
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
|
|
|
{
|
2019-11-29 18:24:46 +09:00
|
|
|
|
catcher.UpdatePosition(e.MousePosition.X / DrawSize.X);
|
2019-05-10 19:44:22 +02:00
|
|
|
|
return base.OnMouseMove(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|