mirror of
https://github.com/ppy/osu.git
synced 2025-02-10 07:33:02 +08:00
IProvideLocalCursor -> IProvideCursor
This commit is contained in:
parent
620e125fad
commit
16d739580b
@ -6,12 +6,12 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.Cursor
|
namespace osu.Game.Graphics.Cursor
|
||||||
{
|
{
|
||||||
public interface IProvideLocalCursor : IDrawable
|
public interface IProvideCursor : IDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cursor provided by this <see cref="Drawable"/>.
|
/// The cursor provided by this <see cref="Drawable"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CursorContainer LocalCursor { get; }
|
CursorContainer Cursor { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the cursor provided by this <see cref="Drawable"/> should be displayed.
|
/// Whether the cursor provided by this <see cref="Drawable"/> should be displayed.
|
@ -9,7 +9,7 @@ using osu.Framework.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.Cursor
|
namespace osu.Game.Graphics.Cursor
|
||||||
{
|
{
|
||||||
public class OsuCursorContainer : Container, IProvideLocalCursor
|
public class OsuCursorContainer : Container, IProvideCursor
|
||||||
{
|
{
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
@ -19,14 +19,14 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool CanShowCursor;
|
public bool CanShowCursor;
|
||||||
|
|
||||||
public CursorContainer LocalCursor { get; }
|
public CursorContainer Cursor { get; }
|
||||||
public bool ProvidesUserCursor => true;
|
public bool ProvidesUserCursor => true;
|
||||||
|
|
||||||
public OsuCursorContainer()
|
public OsuCursorContainer()
|
||||||
{
|
{
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
LocalCursor = new MenuCursor { State = Visibility.Hidden },
|
Cursor = new MenuCursor { State = Visibility.Hidden },
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
content = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -39,24 +39,24 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProvideLocalCursor currentTarget;
|
private IProvideCursor currentTarget;
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (!CanShowCursor)
|
if (!CanShowCursor)
|
||||||
{
|
{
|
||||||
currentTarget?.LocalCursor?.Hide();
|
currentTarget?.Cursor?.Hide();
|
||||||
return;
|
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)
|
if (currentTarget == newTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentTarget?.LocalCursor?.Hide();
|
currentTarget?.Cursor?.Hide();
|
||||||
newTarget.LocalCursor?.Show();
|
newTarget.Cursor?.Show();
|
||||||
|
|
||||||
currentTarget = newTarget;
|
currentTarget = newTarget;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ namespace osu.Game
|
|||||||
CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this)
|
CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
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 });
|
base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer });
|
||||||
|
@ -33,7 +33,7 @@ using osu.Game.Storyboards.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class Player : OsuScreen, IProvideLocalCursor
|
public class Player : OsuScreen, IProvideCursor
|
||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public int RestartCount;
|
public int RestartCount;
|
||||||
|
|
||||||
public CursorContainer LocalCursor => RulesetContainer.Cursor;
|
public CursorContainer Cursor => RulesetContainer.Cursor;
|
||||||
public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded;
|
public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded;
|
||||||
|
|
||||||
private IAdjustableClock adjustableSourceClock;
|
private IAdjustableClock adjustableSourceClock;
|
||||||
|
@ -374,7 +374,7 @@
|
|||||||
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
||||||
<Compile Include="Graphics\Containers\ReverseChildIDFillFlowContainer.cs" />
|
<Compile Include="Graphics\Containers\ReverseChildIDFillFlowContainer.cs" />
|
||||||
<Compile Include="Graphics\Containers\SectionsContainer.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\MenuCursor.cs" />
|
||||||
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
|
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
|
||||||
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
|
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user