1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

Add hotkey to save replay

Defaults to `F2` aka stable.
This commit is contained in:
Dean Herbert 2023-06-19 20:43:33 +09:00
parent f8b94ed033
commit 69526f25bb
3 changed files with 29 additions and 1 deletions

View File

@ -119,6 +119,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
new KeyBinding(InputKey.Tab, GlobalAction.ToggleChatFocus),
new KeyBinding(InputKey.F2, GlobalAction.SaveReplay),
};
public IEnumerable<KeyBinding> ReplayKeyBindings => new[]
@ -366,5 +367,8 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorCycleNextBeatSnapDivisor))]
EditorCycleNextBeatSnapDivisor,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SaveReplay))]
SaveReplay,
}
}

View File

@ -324,6 +324,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString ToggleChatFocus => new TranslatableString(getKey(@"toggle_chat_focus"), @"Toggle chat focus");
/// <summary>
/// "Save replay"
/// </summary>
public static LocalisableString SaveReplay => new TranslatableString(getKey(@"save_replay"), @"Save replay");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -8,15 +8,18 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Database;
using osu.Game.Scoring;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online;
using osuTK;
namespace osu.Game.Screens.Play
{
public partial class SaveFailedScoreButton : CompositeDrawable
public partial class SaveFailedScoreButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
@ -87,5 +90,21 @@ namespace osu.Game.Screens.Play
}
}, true);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SaveReplay:
button.TriggerClick();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
}
}