mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Use ScreenshotCaptureMenuCursor in ScreenshotManager
This commit is contained in:
parent
dd5cc59250
commit
e91d24f31a
@ -4,15 +4,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
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;
|
||||||
@ -29,13 +33,15 @@ namespace osu.Game.Graphics
|
|||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notificationOverlay;
|
||||||
|
|
||||||
private SampleChannel shutter;
|
private SampleChannel shutter;
|
||||||
|
private CursorContainer menuCursorContainer;
|
||||||
|
|
||||||
[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, CursorOverrideContainer cursorOverrideContainer)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.storage = storage.GetStorageForDirectory(@"screenshots");
|
this.storage = storage.GetStorageForDirectory(@"screenshots");
|
||||||
this.notificationOverlay = notificationOverlay;
|
this.notificationOverlay = notificationOverlay;
|
||||||
|
this.menuCursorContainer = cursorOverrideContainer.Cursor;
|
||||||
|
|
||||||
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
||||||
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
|
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
|
||||||
@ -60,6 +66,18 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public async void TakeScreenshotAsync()
|
public async void TakeScreenshotAsync()
|
||||||
{
|
{
|
||||||
|
var menuCursorWasHidden = false;
|
||||||
|
if (!captureMenuCursor.Value && menuCursorContainer.State == Visibility.Visible)
|
||||||
|
{
|
||||||
|
menuCursorContainer.ToggleVisibility();
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
while (menuCursorContainer.ActiveCursor.Alpha > 0)
|
||||||
|
Thread.Sleep(1);
|
||||||
|
});
|
||||||
|
menuCursorWasHidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
using (var bitmap = await host.TakeScreenshotAsync())
|
using (var bitmap = await host.TakeScreenshotAsync())
|
||||||
{
|
{
|
||||||
var fileName = getFileName();
|
var fileName = getFileName();
|
||||||
@ -89,6 +107,9 @@ namespace osu.Game.Graphics
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menuCursorWasHidden)
|
||||||
|
menuCursorContainer.ToggleVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getFileName()
|
private string getFileName()
|
||||||
|
@ -214,7 +214,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
GlobalActionContainer globalBinding;
|
GlobalActionContainer globalBinding;
|
||||||
|
|
||||||
CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both };
|
dependencies.Cache(CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both });
|
||||||
CursorOverrideContainer.Child = globalBinding = new GlobalActionContainer(this)
|
CursorOverrideContainer.Child = globalBinding = new GlobalActionContainer(this)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user