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