1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:53:20 +08:00

IProvideLocalCursor -> IProvideCursor

This commit is contained in:
smoogipoo 2018-01-12 19:36:35 +09:00
parent 620e125fad
commit 16d739580b
5 changed files with 14 additions and 14 deletions

View File

@ -6,12 +6,12 @@ using osu.Framework.Graphics.Cursor;
namespace osu.Game.Graphics.Cursor
{
public interface IProvideLocalCursor : IDrawable
public interface IProvideCursor : IDrawable
{
/// <summary>
/// The cursor provided by this <see cref="Drawable"/>.
/// </summary>
CursorContainer LocalCursor { get; }
CursorContainer Cursor { get; }
/// <summary>
/// Whether the cursor provided by this <see cref="Drawable"/> should be displayed.

View File

@ -9,7 +9,7 @@ using osu.Framework.Input;
namespace osu.Game.Graphics.Cursor
{
public class OsuCursorContainer : Container, IProvideLocalCursor
public class OsuCursorContainer : Container, IProvideCursor
{
protected override Container<Drawable> Content => content;
private readonly Container content;
@ -19,14 +19,14 @@ namespace osu.Game.Graphics.Cursor
/// </summary>
public bool CanShowCursor;
public CursorContainer LocalCursor { get; }
public CursorContainer Cursor { get; }
public bool ProvidesUserCursor => true;
public OsuCursorContainer()
{
AddRangeInternal(new Drawable[]
{
LocalCursor = new MenuCursor { State = Visibility.Hidden },
Cursor = new MenuCursor { State = Visibility.Hidden },
content = new Container { RelativeSizeAxes = Axes.Both }
});
}
@ -39,24 +39,24 @@ namespace osu.Game.Graphics.Cursor
inputManager = GetContainingInputManager();
}
private IProvideLocalCursor currentTarget;
private IProvideCursor currentTarget;
protected override void Update()
{
base.Update();
if (!CanShowCursor)
{
currentTarget?.LocalCursor?.Hide();
currentTarget?.Cursor?.Hide();
return;
}
var newTarget = inputManager.HoveredDrawables.OfType<IProvideLocalCursor>().FirstOrDefault(t => t.ProvidesUserCursor) ?? this;
var newTarget = inputManager.HoveredDrawables.OfType<IProvideCursor>().FirstOrDefault(t => t.ProvidesUserCursor) ?? this;
if (currentTarget == newTarget)
return;
currentTarget?.LocalCursor?.Hide();
newTarget.LocalCursor?.Show();
currentTarget?.Cursor?.Hide();
newTarget.Cursor?.Show();
currentTarget = newTarget;
}

View File

@ -215,7 +215,7 @@ namespace osu.Game
CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this)
{
RelativeSizeAxes = Axes.Both,
Child = content = new OsuTooltipContainer(CursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both }
Child = content = new OsuTooltipContainer(CursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }
};
base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer });

View File

@ -33,7 +33,7 @@ using osu.Game.Storyboards.Drawables;
namespace osu.Game.Screens.Play
{
public class Player : OsuScreen, IProvideLocalCursor
public class Player : OsuScreen, IProvideCursor
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
public int RestartCount;
public CursorContainer LocalCursor => RulesetContainer.Cursor;
public CursorContainer Cursor => RulesetContainer.Cursor;
public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded;
private IAdjustableClock adjustableSourceClock;

View File

@ -374,7 +374,7 @@
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
<Compile Include="Graphics\Containers\ReverseChildIDFillFlowContainer.cs" />
<Compile Include="Graphics\Containers\SectionsContainer.cs" />
<Compile Include="Graphics\Cursor\IProvideLocalCursor.cs" />
<Compile Include="Graphics\Cursor\IProvideCursor.cs" />
<Compile Include="Graphics\Cursor\MenuCursor.cs" />
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />