1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 11:07:32 +08:00

Merge pull request #4535 from peppy/gameplay-cursor-last-state

Add base gameplay cursor class to retrieve true visibility state
This commit is contained in:
Dan Balasescu 2019-03-29 11:15:21 +09:00 committed by GitHub
commit 724675dd49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 13 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Cursor;
using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Game.Rulesets.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
@ -27,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Tests
[BackgroundDependencyLoader]
private void load()
{
Add(cursorContainer = new GameplayCursorContainer { RelativeSizeAxes = Axes.Both });
Add(cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both });
}
}
}

View File

@ -1,7 +1,6 @@
// 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.
using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI;
@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Edit
private class OsuPlayfieldNoCursor : OsuPlayfield
{
protected override CursorContainer CreateCursor() => null;
protected override GameplayCursorContainer CreateCursor() => null;
}
}
}

View File

@ -6,7 +6,6 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps;
@ -14,10 +13,11 @@ using osu.Game.Configuration;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Osu.UI.Cursor
{
public class GameplayCursorContainer : CursorContainer, IKeyBindingHandler<OsuAction>
public class OsuCursorContainer : GameplayCursorContainer, IKeyBindingHandler<OsuAction>
{
protected override Drawable CreateCursor() => new OsuCursor();
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private readonly Container<Drawable> fadeContainer;
public GameplayCursorContainer()
public OsuCursorContainer()
{
InternalChild = fadeContainer = new Container
{

View File

@ -10,7 +10,6 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
using osu.Game.Rulesets.UI;
using System.Linq;
using osu.Framework.Graphics.Cursor;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.UI.Cursor;
@ -28,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.UI
protected override Container CursorTargetContainer => adjustmentContainer;
protected override CursorContainer CreateCursor() => new GameplayCursorContainer();
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
public OsuPlayfield()
{

View File

@ -263,7 +263,9 @@ namespace osu.Game.Rulesets.UI
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
public override CursorContainer Cursor => Playfield.Cursor;
CursorContainer IProvideCursor.Cursor => Playfield.Cursor;
public override GameplayCursorContainer Cursor => Playfield.Cursor;
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
@ -333,7 +335,7 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The cursor being displayed by the <see cref="Playfield"/>. May be null if no cursor is provided.
/// </summary>
public abstract CursorContainer Cursor { get; }
public abstract GameplayCursorContainer Cursor { get; }
/// <summary>
/// Sets a replay to be used, overriding local input.

View File

@ -0,0 +1,25 @@
// 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.
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Rulesets.UI
{
public class GameplayCursorContainer : CursorContainer
{
/// <summary>
/// Because Show/Hide are executed by a parent, <see cref="State"/> is updated immediately even if the cursor
/// is in a non-updating state (via <see cref="FrameStabilityContainer"/> limitations).
///
/// This holds the true visibility value.
/// </summary>
public Visibility LastFrameState;
protected override void Update()
{
base.Update();
LastFrameState = State;
}
}
}

View File

@ -10,7 +10,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osuTK;
@ -90,14 +89,14 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
/// </summary>
public CursorContainer Cursor { get; private set; }
public GameplayCursorContainer Cursor { get; private set; }
/// <summary>
/// Provide an optional cursor which is to be used for gameplay.
/// If providing a cursor, <see cref="CursorTargetContainer"/> must also point to a valid target container.
/// </summary>
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
protected virtual CursorContainer CreateCursor() => null;
protected virtual GameplayCursorContainer CreateCursor() => null;
/// <summary>
/// The target container to add the cursor after it is created.