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

Don't expose CursorOverrideContainer via DI + internalise access

This commit is contained in:
smoogipoo 2018-04-13 17:36:38 +09:00
parent 826a8552e5
commit 2e5bbe7074
4 changed files with 16 additions and 18 deletions

View File

@ -20,23 +20,17 @@ namespace osu.Game.Graphics.Cursor
/// <summary>
/// Whether any cursors can be displayed.
/// </summary>
public bool CanShowCursor = true;
public bool ShowMenuCursor
{
get => cursor.ShowCursor;
set => cursor.ShowCursor = value;
}
private readonly MenuCursor cursor;
public CursorContainer Cursor => cursor;
internal bool CanShowCursor = true;
internal readonly MenuCursor MenuCursor;
public CursorContainer Cursor => MenuCursor;
public bool ProvidingUserCursor => true;
public CursorOverrideContainer()
{
AddRangeInternal(new Drawable[]
{
cursor = new MenuCursor { State = Visibility.Hidden },
MenuCursor = new MenuCursor { State = Visibility.Hidden },
content = new Container { RelativeSizeAxes = Axes.Both }
});
}

View File

@ -33,15 +33,19 @@ namespace osu.Game.Graphics
private NotificationOverlay notificationOverlay;
private SampleChannel shutter;
private CursorOverrideContainer cursorOverrideContainer;
private readonly MenuCursor menuCursor;
public ScreenshotManager(MenuCursor menuCursor)
{
this.menuCursor = menuCursor;
}
[BackgroundDependencyLoader]
private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio, CursorOverrideContainer cursorOverrideContainer)
private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio)
{
this.host = host;
this.storage = storage.GetStorageForDirectory(@"screenshots");
this.notificationOverlay = notificationOverlay;
this.cursorOverrideContainer = cursorOverrideContainer;
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
@ -72,7 +76,7 @@ namespace osu.Game.Graphics
if (!captureMenuCursor.Value)
{
cursorOverrideContainer.ShowMenuCursor = false;
menuCursor.ShowCursor = false;
// We need to wait for at most 3 draw nodes to be drawn, following which we can be assured at least one DrawNode has been generated/drawn with the set value
const int frames_to_wait = 3;
@ -123,7 +127,7 @@ namespace osu.Game.Graphics
base.Update();
if (Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
cursorOverrideContainer.ShowMenuCursor = true;
menuCursor.ShowCursor = true;
}
private string getFileName()

View File

@ -239,7 +239,7 @@ namespace osu.Game
loadComponentSingleFile(volume = new VolumeOverlay(), overlayContent.Add);
loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add);
loadComponentSingleFile(new ScreenshotManager(), Add);
loadComponentSingleFile(new ScreenshotManager(CursorOverrideContainer.MenuCursor), Add);
//overlay elements
loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);

View File

@ -214,7 +214,7 @@ namespace osu.Game
GlobalActionContainer globalBinding;
dependencies.Cache(CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both });
CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both };
CursorOverrideContainer.Child = globalBinding = new GlobalActionContainer(this)
{
RelativeSizeAxes = Axes.Both,