mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Update ScreenshotManager inline with framework changes
This commit is contained in:
@ -36,7 +36,7 @@ namespace osu.Game.Graphics
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GlobalAction.TakeScreenshot:
|
case GlobalAction.TakeScreenshot:
|
||||||
TakeScreenshot();
|
TakeScreenshotAsync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,9 +45,9 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public bool OnReleased(GlobalAction action) => false;
|
public bool OnReleased(GlobalAction action) => false;
|
||||||
|
|
||||||
public void TakeScreenshot()
|
public async void TakeScreenshotAsync()
|
||||||
{
|
{
|
||||||
host.TakeScreenshot(screenshotBitmap =>
|
using (var bitmap = await host.TakeScreenshotAsync())
|
||||||
{
|
{
|
||||||
var fileName = getFileName();
|
var fileName = getFileName();
|
||||||
var stream = storage.GetStream(fileName, FileAccess.Write);
|
var stream = storage.GetStream(fileName, FileAccess.Write);
|
||||||
@ -55,17 +55,17 @@ namespace osu.Game.Graphics
|
|||||||
switch (screenshotFormat.Value)
|
switch (screenshotFormat.Value)
|
||||||
{
|
{
|
||||||
case ScreenshotFormat.Png:
|
case ScreenshotFormat.Png:
|
||||||
screenshotBitmap.Save(stream, ImageFormat.Png);
|
bitmap.Save(stream, ImageFormat.Png);
|
||||||
break;
|
break;
|
||||||
case ScreenshotFormat.Jpg:
|
case ScreenshotFormat.Jpg:
|
||||||
screenshotBitmap.Save(stream, ImageFormat.Jpeg);
|
bitmap.Save(stream, ImageFormat.Jpeg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(screenshotFormat));
|
throw new ArgumentOutOfRangeException(nameof(screenshotFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationOverlay.Post(new SimpleNotification { Text = $"{fileName} saved" });
|
notificationOverlay.Post(new SimpleNotification { Text = $"{fileName} saved" });
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getFileName()
|
private string getFileName()
|
||||||
|
Reference in New Issue
Block a user