1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:23:22 +08:00

Handle GlobalAction.TakeScreenshot in ScreenshotManager

This commit is contained in:
TocoToucan 2018-03-14 22:55:24 +03:00
parent 25f738c4ae
commit 5a1af062d3
2 changed files with 20 additions and 8 deletions

View File

@ -3,13 +3,16 @@ using System.Drawing.Imaging;
using System.IO;
using osu.Framework.Allocation;
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.Game.Configuration;
using osu.Game.Input.Bindings;
namespace osu.Game.Graphics
{
public class ScreenshotManager : Drawable
public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
{
private Bindable<ScreenshotFormat> screenshotFormat;
private GameHost host;
@ -24,6 +27,20 @@ namespace osu.Game.Graphics
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()
{
host.TakeScreenshot(screenshotBitmap =>

View File

@ -211,9 +211,6 @@ namespace osu.Game
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
screenshotManager = new ScreenshotManager();
Add(screenshotManager);
AddRange(new Drawable[]
{
new VolumeControlReceptor
@ -223,6 +220,7 @@ namespace osu.Game
},
mainContent = new Container { RelativeSizeAxes = Axes.Both },
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
screenshotManager = new ScreenshotManager()
});
loadComponentSingleFile(screenStack = new Loader(), d =>
@ -436,9 +434,6 @@ namespace osu.Game
case GlobalAction.ToggleDirect:
direct.ToggleVisibility();
return true;
case GlobalAction.TakeScreenshot:
screenshotManager.TakeScreenshot();
return true;
}
return false;