mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Also add hotkey to export replays
This commit is contained in:
parent
7c5813c05a
commit
4bd121d3b8
@ -119,7 +119,8 @@ 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),
|
||||
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
|
||||
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> ReplayKeyBindings => new[]
|
||||
@ -370,5 +371,8 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SaveReplay))]
|
||||
SaveReplay,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ExportReplay))]
|
||||
ExportReplay,
|
||||
}
|
||||
}
|
||||
|
@ -329,6 +329,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString SaveReplay => new TranslatableString(getKey(@"save_replay"), @"Save replay");
|
||||
|
||||
/// <summary>
|
||||
/// "Export replay"
|
||||
/// </summary>
|
||||
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,12 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public partial class SaveFailedScoreButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; } = null!;
|
||||
|
||||
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
|
||||
|
||||
private readonly Func<Task<ScoreInfo>> importFailedScore;
|
||||
@ -37,7 +43,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGame? game, Player? player, RealmAccess realm)
|
||||
private void load(OsuGame? game, Player? player)
|
||||
{
|
||||
InternalChild = button = new DownloadButton
|
||||
{
|
||||
@ -98,6 +104,15 @@ namespace osu.Game.Screens.Play
|
||||
case GlobalAction.SaveReplay:
|
||||
button.TriggerClick();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ExportReplay:
|
||||
Task.Run(importFailedScore).ContinueWith(t =>
|
||||
{
|
||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
|
||||
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
|
||||
scoreManager.Export(importedScore);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -27,6 +27,9 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private ScoreDownloadTracker? downloadTracker;
|
||||
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; } = null!;
|
||||
|
||||
private ReplayAvailability replayAvailability
|
||||
{
|
||||
get
|
||||
@ -48,7 +51,7 @@ namespace osu.Game.Screens.Ranking
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGame? game, ScoreModelDownloader scores)
|
||||
private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
|
||||
{
|
||||
InternalChild = shakeContainer = new ShakeContainer
|
||||
{
|
||||
@ -68,7 +71,7 @@ namespace osu.Game.Screens.Ranking
|
||||
break;
|
||||
|
||||
case DownloadState.NotDownloaded:
|
||||
scores.Download(Score.Value);
|
||||
scoreDownloader.Download(Score.Value);
|
||||
break;
|
||||
|
||||
case DownloadState.Importing:
|
||||
@ -107,6 +110,22 @@ namespace osu.Game.Screens.Ranking
|
||||
case GlobalAction.SaveReplay:
|
||||
button.TriggerClick();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ExportReplay:
|
||||
if (State.Value == DownloadState.NotDownloaded)
|
||||
{
|
||||
button.TriggerClick();
|
||||
}
|
||||
|
||||
State.ValueChanged += importAfterDownload;
|
||||
|
||||
void importAfterDownload(ValueChangedEvent<DownloadState> valueChangedEvent)
|
||||
{
|
||||
scoreManager.Export(Score.Value);
|
||||
State.ValueChanged -= importAfterDownload;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user