mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 12:03:21 +08:00
A lot more protection from outsiders
This commit is contained in:
parent
cd594ce12b
commit
34adb2527c
@ -21,16 +21,15 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
/// Whether any cursors can be displayed.
|
/// Whether any cursors can be displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool CanShowCursor = true;
|
internal bool CanShowCursor = true;
|
||||||
internal readonly MenuCursor MenuCursor;
|
|
||||||
|
|
||||||
public CursorContainer Cursor => MenuCursor;
|
public CursorContainer Cursor { get; }
|
||||||
public bool ProvidingUserCursor => true;
|
public bool ProvidingUserCursor => true;
|
||||||
|
|
||||||
public CursorOverrideContainer()
|
public CursorOverrideContainer()
|
||||||
{
|
{
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
MenuCursor = new MenuCursor { State = Visibility.Hidden },
|
Cursor = new MenuCursor { State = Visibility.Hidden },
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
content = new Container { RelativeSizeAxes = Axes.Both }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,15 @@ using osu.Framework.Input;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Cursor
|
namespace osu.Game.Graphics.Cursor
|
||||||
{
|
{
|
||||||
public class MenuCursor : CursorContainer
|
public class MenuCursor : CursorContainer
|
||||||
{
|
{
|
||||||
public bool ShowCursor = true;
|
private readonly IBindable<bool> screenshotCursorVisibility = new Bindable<bool>(true);
|
||||||
public override bool IsPresent => ShowCursor && base.IsPresent;
|
public override bool IsPresent => screenshotCursorVisibility.Value && base.IsPresent;
|
||||||
|
|
||||||
protected override Drawable CreateCursor() => new Cursor();
|
protected override Drawable CreateCursor() => new Cursor();
|
||||||
|
|
||||||
@ -28,6 +29,17 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
|
|
||||||
private bool startRotation;
|
private bool startRotation;
|
||||||
|
|
||||||
|
private ScreenshotManager screenshotManager;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load([NotNull] OsuConfigManager config, [CanBeNull] ScreenshotManager screenshotManager)
|
||||||
|
{
|
||||||
|
cursorRotate = config.GetBindable<bool>(OsuSetting.CursorRotation);
|
||||||
|
|
||||||
|
if (screenshotManager != null)
|
||||||
|
screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility);
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(InputState state)
|
protected override bool OnMouseMove(InputState state)
|
||||||
{
|
{
|
||||||
if (cursorRotate && dragging)
|
if (cursorRotate && dragging)
|
||||||
@ -107,12 +119,6 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
ActiveCursor.ScaleTo(0.6f, 250, Easing.In);
|
ActiveCursor.ScaleTo(0.6f, 250, Easing.In);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
cursorRotate = config.GetBindable<bool>(OsuSetting.CursorRotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Cursor : Container
|
public class Cursor : Container
|
||||||
{
|
{
|
||||||
private Container cursorContainer;
|
private Container cursorContainer;
|
||||||
|
@ -16,7 +16,6 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.Cursor;
|
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
@ -25,6 +24,14 @@ namespace osu.Game.Graphics
|
|||||||
{
|
{
|
||||||
public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
|
public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
|
||||||
{
|
{
|
||||||
|
private readonly BindableBool cursorVisibility = new BindableBool(true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when screenshots are or have finished being taken, to control whether cursors should be visible.
|
||||||
|
/// If cursors should not be visible, cursors have 3 frames to hide themselves.
|
||||||
|
/// </summary>
|
||||||
|
public IBindable<bool> CursorVisibility => cursorVisibility;
|
||||||
|
|
||||||
private Bindable<ScreenshotFormat> screenshotFormat;
|
private Bindable<ScreenshotFormat> screenshotFormat;
|
||||||
private Bindable<bool> captureMenuCursor;
|
private Bindable<bool> captureMenuCursor;
|
||||||
|
|
||||||
@ -33,12 +40,6 @@ namespace osu.Game.Graphics
|
|||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notificationOverlay;
|
||||||
|
|
||||||
private SampleChannel shutter;
|
private SampleChannel shutter;
|
||||||
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)
|
private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio)
|
||||||
@ -76,7 +77,7 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
if (!captureMenuCursor.Value)
|
if (!captureMenuCursor.Value)
|
||||||
{
|
{
|
||||||
menuCursor.ShowCursor = false;
|
cursorVisibility.Value = 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;
|
||||||
@ -126,8 +127,8 @@ namespace osu.Game.Graphics
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
|
if (cursorVisibility == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
|
||||||
menuCursor.ShowCursor = true;
|
cursorVisibility.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getFileName()
|
private string getFileName()
|
||||||
|
Loading…
Reference in New Issue
Block a user