mirror of
https://github.com/osukey/osukey.git
synced 2025-06-10 05:48:05 +09:00
Handle GlobalAction.TakeScreenshot in ScreenshotManager
This commit is contained in:
parent
25f738c4ae
commit
5a1af062d3
@ -3,13 +3,16 @@ using System.Drawing.Imaging;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
|
||||||
namespace osu.Game.Graphics
|
namespace osu.Game.Graphics
|
||||||
{
|
{
|
||||||
public class ScreenshotManager : Drawable
|
public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
|
||||||
{
|
{
|
||||||
private Bindable<ScreenshotFormat> screenshotFormat;
|
private Bindable<ScreenshotFormat> screenshotFormat;
|
||||||
private GameHost host;
|
private GameHost host;
|
||||||
@ -24,6 +27,20 @@ namespace osu.Game.Graphics
|
|||||||
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.TakeScreenshot:
|
||||||
|
TakeScreenshot();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(GlobalAction action) => false;
|
||||||
|
|
||||||
public void TakeScreenshot()
|
public void TakeScreenshot()
|
||||||
{
|
{
|
||||||
host.TakeScreenshot(screenshotBitmap =>
|
host.TakeScreenshot(screenshotBitmap =>
|
||||||
|
@ -211,9 +211,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
||||||
|
|
||||||
screenshotManager = new ScreenshotManager();
|
|
||||||
Add(screenshotManager);
|
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new VolumeControlReceptor
|
new VolumeControlReceptor
|
||||||
@ -223,6 +220,7 @@ namespace osu.Game
|
|||||||
},
|
},
|
||||||
mainContent = new Container { RelativeSizeAxes = Axes.Both },
|
mainContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
|
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
|
||||||
|
screenshotManager = new ScreenshotManager()
|
||||||
});
|
});
|
||||||
|
|
||||||
loadComponentSingleFile(screenStack = new Loader(), d =>
|
loadComponentSingleFile(screenStack = new Loader(), d =>
|
||||||
@ -436,9 +434,6 @@ namespace osu.Game
|
|||||||
case GlobalAction.ToggleDirect:
|
case GlobalAction.ToggleDirect:
|
||||||
direct.ToggleVisibility();
|
direct.ToggleVisibility();
|
||||||
return true;
|
return true;
|
||||||
case GlobalAction.TakeScreenshot:
|
|
||||||
screenshotManager.TakeScreenshot();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user