2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-11 01:44:22 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
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 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Mods
|
|
|
|
|
{
|
|
|
|
|
public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset<CatchHitObject>
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public override string Description => @"Use the mouse to control the catcher.";
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset) =>
|
|
|
|
|
(drawableRuleset.Playfield.Parent as Container).Add(new CatchModRelaxHelper(drawableRuleset.Playfield as CatchPlayfield));
|
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
private class CatchModRelaxHelper : Drawable, IKeyBindingHandler<CatchAction>, IRequireHighFrequencyMousePosition
|
|
|
|
|
{
|
2019-05-11 16:26:24 +08:00
|
|
|
|
private readonly CatcherArea.Catcher catcher;
|
2019-05-11 01:44:22 +08:00
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
public CatchModRelaxHelper(CatchPlayfield catchPlayfield)
|
|
|
|
|
{
|
2019-05-11 01:44:22 +08:00
|
|
|
|
catcher = catchPlayfield.CatcherArea.MovableCatcher;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//disable keyboard controls
|
|
|
|
|
public bool OnPressed(CatchAction action) => true;
|
|
|
|
|
public bool OnReleased(CatchAction action) => true;
|
|
|
|
|
|
2019-05-11 16:03:59 +08:00
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
|
|
|
{
|
2019-05-11 01:44:22 +08:00
|
|
|
|
//lock catcher to mouse position horizontally
|
|
|
|
|
catcher.X = e.MousePosition.X / DrawSize.X;
|
|
|
|
|
|
|
|
|
|
//make Yuzu face the direction he's moving
|
|
|
|
|
var direction = Math.Sign(e.Delta.X);
|
|
|
|
|
if (direction != 0)
|
|
|
|
|
catcher.Scale = new Vector2(Math.Abs(catcher.Scale.X) * direction, catcher.Scale.Y);
|
|
|
|
|
|
|
|
|
|
return base.OnMouseMove(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|