1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 14:22:54 +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> /// <summary>
/// Whether any cursors can be displayed. /// Whether any cursors can be displayed.
/// </summary> /// </summary>
public bool CanShowCursor = true; internal bool CanShowCursor = true;
internal readonly MenuCursor MenuCursor;
public bool ShowMenuCursor
{ public CursorContainer Cursor => MenuCursor;
get => cursor.ShowCursor;
set => cursor.ShowCursor = value;
}
private readonly MenuCursor cursor;
public CursorContainer Cursor => cursor;
public bool ProvidingUserCursor => true; public bool ProvidingUserCursor => true;
public CursorOverrideContainer() public CursorOverrideContainer()
{ {
AddRangeInternal(new Drawable[] AddRangeInternal(new Drawable[]
{ {
cursor = new MenuCursor { State = Visibility.Hidden }, MenuCursor = new MenuCursor { State = Visibility.Hidden },
content = new Container { RelativeSizeAxes = Axes.Both } content = new Container { RelativeSizeAxes = Axes.Both }
}); });
} }

View File

@ -33,15 +33,19 @@ namespace osu.Game.Graphics
private NotificationOverlay notificationOverlay; private NotificationOverlay notificationOverlay;
private SampleChannel shutter; private SampleChannel shutter;
private CursorOverrideContainer cursorOverrideContainer; private readonly MenuCursor menuCursor;
public ScreenshotManager(MenuCursor menuCursor)
{
this.menuCursor = menuCursor;
}
[BackgroundDependencyLoader] [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.host = host;
this.storage = storage.GetStorageForDirectory(@"screenshots"); this.storage = storage.GetStorageForDirectory(@"screenshots");
this.notificationOverlay = notificationOverlay; this.notificationOverlay = notificationOverlay;
this.cursorOverrideContainer = cursorOverrideContainer;
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat); screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor); captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
@ -72,7 +76,7 @@ namespace osu.Game.Graphics
if (!captureMenuCursor.Value) 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 // 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; const int frames_to_wait = 3;
@ -123,7 +127,7 @@ namespace osu.Game.Graphics
base.Update(); base.Update();
if (Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0) if (Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
cursorOverrideContainer.ShowMenuCursor = true; menuCursor.ShowCursor = true;
} }
private string getFileName() private string getFileName()

View File

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

View File

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