From 5a1af062d31c01dd9ac1830fa75c584e8f7f4b6e Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Wed, 14 Mar 2018 22:55:24 +0300 Subject: [PATCH] Handle GlobalAction.TakeScreenshot in ScreenshotManager --- osu.Game/Graphics/ScreenshotManager.cs | 21 +++++++++++++++++++-- osu.Game/OsuGame.cs | 7 +------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index e7f21d11fa..8e0c2cce50 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -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, IHandleGlobalInput { private Bindable screenshotFormat; private GameHost host; @@ -24,6 +27,20 @@ namespace osu.Game.Graphics screenshotFormat = config.GetBindable(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 => diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 18ea093e97..44946dd23d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -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;