Merge pull request #19293 from peppy/skin-editor-save-hotkey

Add the ability to save in the skin editor using system save hotkey
This commit is contained in:
Dan Balasescu 2022-07-22 14:43:34 +09:00 committed by GitHub
commit f87efae115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -13,6 +13,8 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Testing;
@ -30,7 +32,7 @@
namespace osu.Game.Skinning.Editor
{
[Cached(typeof(SkinEditor))]
public class SkinEditor : VisibilityContainer, ICanAcceptFiles
public class SkinEditor : VisibilityContainer, ICanAcceptFiles, IKeyBindingHandler<PlatformAction>
{
public const double TRANSITION_DURATION = 500;
@ -205,6 +207,25 @@ protected override void LoadComplete()
SelectedComponents.BindCollectionChanged((_, _) => Scheduler.AddOnce(populateSettings), true);
}
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
{
switch (e.Action)
{
case PlatformAction.Save:
if (e.Repeat)
return false;
Save();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
{
}
public void UpdateTargetScreen(Drawable targetScreen)
{
this.targetScreen = targetScreen;