1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00

Merge pull request #7011 from peppy/hide-mouse-in-playfield

Hide the menu cursor while inside the playfield by default
This commit is contained in:
Dan Balasescu 2019-12-02 14:00:42 +09:00 committed by GitHub
commit 427122bdd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Rulesets.Osu.UI
{
@ -30,6 +31,8 @@ namespace osu.Game.Rulesets.Osu.UI
{
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // always show the gameplay cursor
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this);
protected override Playfield CreatePlayfield() => new OsuPlayfield();

View File

@ -34,6 +34,7 @@ using osu.Game.Rulesets.Configuration;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Rulesets.UI
{
@ -331,6 +332,9 @@ namespace osu.Game.Rulesets.UI
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
// only show the cursor when within the playfield, by default.
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Playfield.ReceivePositionalInputAt(screenSpacePos);
CursorContainer IProvideCursor.Cursor => Playfield.Cursor;
public override GameplayCursorContainer Cursor => Playfield.Cursor;

View File

@ -100,10 +100,13 @@ namespace osu.Game.Rulesets.UI
public GameplayCursorContainer Cursor { get; private set; }
/// <summary>
/// Provide an optional cursor which is to be used for gameplay.
/// Provide a cursor which is to be used for gameplay.
/// </summary>
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
protected virtual GameplayCursorContainer CreateCursor() => null;
/// <remarks>
/// The default provided cursor is invisible when inside the bounds of the <see cref="Playfield"/>.
/// </remarks>
/// <returns>The cursor, or null to show the menu cursor.</returns>
protected virtual GameplayCursorContainer CreateCursor() => new InvisibleCursorContainer();
/// <summary>
/// Registers a <see cref="Playfield"/> as a nested <see cref="Playfield"/>.
@ -143,5 +146,14 @@ namespace osu.Game.Rulesets.UI
/// Creates the container that will be used to contain the <see cref="DrawableHitObject"/>s.
/// </summary>
protected virtual HitObjectContainer CreateHitObjectContainer() => new HitObjectContainer();
public class InvisibleCursorContainer : GameplayCursorContainer
{
protected override Drawable CreateCursor() => new InvisibleCursor();
private class InvisibleCursor : Drawable
{
}
}
}
}