mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Add base cursor class to retrieve true visibility state
This commit is contained in:
parent
b4d785c76c
commit
fbc97edc55
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
@ -27,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Add(cursorContainer = new GameplayCursorContainer { RelativeSizeAxes = Axes.Both });
|
Add(cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
private class OsuPlayfieldNoCursor : OsuPlayfield
|
private class OsuPlayfieldNoCursor : OsuPlayfield
|
||||||
{
|
{
|
||||||
protected override CursorContainer CreateCursor() => null;
|
protected override GameplayCursorContainer CreateCursor() => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -14,10 +13,11 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
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();
|
protected override Drawable CreateCursor() => new OsuCursor();
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
private readonly Container<Drawable> fadeContainer;
|
private readonly Container<Drawable> fadeContainer;
|
||||||
|
|
||||||
public GameplayCursorContainer()
|
public OsuCursorContainer()
|
||||||
{
|
{
|
||||||
InternalChild = fadeContainer = new Container
|
InternalChild = fadeContainer = new Container
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
|
|
||||||
@ -24,11 +23,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||||
|
|
||||||
private readonly PlayfieldAdjustmentContainer adjustmentContainer;
|
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
|
||||||
|
|
||||||
protected override Container CursorTargetContainer => adjustmentContainer;
|
|
||||||
|
|
||||||
protected override CursorContainer CreateCursor() => new GameplayCursorContainer();
|
|
||||||
|
|
||||||
public OsuPlayfield()
|
public OsuPlayfield()
|
||||||
{
|
{
|
||||||
@ -37,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
Size = new Vector2(0.75f);
|
Size = new Vector2(0.75f);
|
||||||
|
|
||||||
InternalChild = adjustmentContainer = new PlayfieldAdjustmentContainer
|
InternalChild = new PlayfieldAdjustmentContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
|
@ -263,7 +263,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
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;
|
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
||||||
|
|
||||||
@ -333,7 +335,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cursor being displayed by the <see cref="Playfield"/>. May be null if no cursor is provided.
|
/// The cursor being displayed by the <see cref="Playfield"/>. May be null if no cursor is provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract CursorContainer Cursor { get; }
|
public abstract GameplayCursorContainer Cursor { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets a replay to be used, overriding local input.
|
/// Sets a replay to be used, overriding local input.
|
||||||
|
25
osu.Game/Rulesets/UI/GameplayCursorContainer.cs
Normal file
25
osu.Game/Rulesets/UI/GameplayCursorContainer.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -90,14 +89,14 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
|
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CursorContainer Cursor { get; private set; }
|
public GameplayCursorContainer Cursor { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provide an optional cursor which is to be used for gameplay.
|
/// 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.
|
/// If providing a cursor, <see cref="CursorTargetContainer"/> must also point to a valid target container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
|
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
|
||||||
protected virtual CursorContainer CreateCursor() => null;
|
protected virtual GameplayCursorContainer CreateCursor() => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target container to add the cursor after it is created.
|
/// The target container to add the cursor after it is created.
|
||||||
|
Loading…
Reference in New Issue
Block a user