1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:35:35 +08:00

Merge branch 'master' into skin-editor-beatmap-skin-disable

This commit is contained in:
Bartłomiej Dach 2023-06-22 20:30:51 +02:00
commit a11b3a67fb
No known key found for this signature in database
7 changed files with 126 additions and 14 deletions

View File

@ -111,6 +111,10 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
// Handle case where a click is triggered via TriggerClick().
if (!IsHovered)
hover.FadeOutFromOne(1600);
hover.FlashColour(FlashColour, 800, Easing.OutQuint); hover.FlashColour(FlashColour, 800, Easing.OutQuint);
return base.OnClick(e); return base.OnClick(e);
} }

View File

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

View File

@ -324,6 +324,16 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString ToggleChatFocus => new TranslatableString(getKey(@"toggle_chat_focus"), @"Toggle chat focus"); 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");
/// <summary>
/// "Export replay"
/// </summary>
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
private static string getKey(string key) => $@"{prefix}:{key}"; private static string getKey(string key) => $@"{prefix}:{key}";
} }
} }

View File

@ -118,7 +118,7 @@ namespace osu.Game.Overlays
private void updateProcessingMode() private void updateProcessingMode()
{ {
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible; bool enabled = OverlayActivationMode.Value != OverlayActivation.Disabled || State.Value == Visibility.Visible;
notificationsEnabler?.Cancel(); notificationsEnabler?.Cancel();

View File

@ -8,16 +8,26 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.Multiplayer;
using osuTK; using osuTK;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public partial class SaveFailedScoreButton : CompositeDrawable 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 Bindable<DownloadState> state = new Bindable<DownloadState>();
private readonly Func<Task<ScoreInfo>> importFailedScore; private readonly Func<Task<ScoreInfo>> importFailedScore;
@ -34,7 +44,7 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGame? game, Player? player, RealmAccess realm) private void load(OsuGame? game, Player? player)
{ {
InternalChild = button = new DownloadButton InternalChild = button = new DownloadButton
{ {
@ -54,7 +64,7 @@ namespace osu.Game.Screens.Play
{ {
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach()); importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded); Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
}); }).FireAndForget();
break; break;
} }
} }
@ -87,5 +97,43 @@ namespace osu.Game.Screens.Play
} }
}, true); }, true);
} }
#region Export via hotkey logic (also in ReplayDownloadButton)
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SaveReplay:
button.TriggerClick();
return true;
case GlobalAction.ExportReplay:
state.BindValueChanged(exportWhenReady, true);
// start the import via button
if (state.Value != DownloadState.LocallyAvailable)
button.TriggerClick();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
private void exportWhenReady(ValueChangedEvent<DownloadState> state)
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
scoreManager.Export(importedScore);
this.state.ValueChanged -= exportWhenReady;
}
#endregion
} }
} }

View File

@ -1,30 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
public partial class ReplayDownloadButton : CompositeDrawable public partial class ReplayDownloadButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{ {
public readonly Bindable<ScoreInfo> Score = new Bindable<ScoreInfo>(); public readonly Bindable<ScoreInfo> Score = new Bindable<ScoreInfo>();
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>(); protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
private DownloadButton button; private DownloadButton button = null!;
private ShakeContainer shakeContainer; private ShakeContainer shakeContainer = null!;
private ScoreDownloadTracker downloadTracker; private ScoreDownloadTracker? downloadTracker;
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;
private ReplayAvailability replayAvailability private ReplayAvailability replayAvailability
{ {
@ -46,8 +50,8 @@ namespace osu.Game.Screens.Ranking
Size = new Vector2(50, 30); Size = new Vector2(50, 30);
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader]
private void load(OsuGame game, ScoreModelDownloader scores) private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
{ {
InternalChild = shakeContainer = new ShakeContainer InternalChild = shakeContainer = new ShakeContainer
{ {
@ -67,7 +71,7 @@ namespace osu.Game.Screens.Ranking
break; break;
case DownloadState.NotDownloaded: case DownloadState.NotDownloaded:
scores.Download(Score.Value); scoreDownloader.Download(Score.Value);
break; break;
case DownloadState.Importing: case DownloadState.Importing:
@ -99,6 +103,44 @@ namespace osu.Game.Screens.Ranking
}, true); }, true);
} }
#region Export via hotkey logic (also in SaveFailedScoreButton)
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.SaveReplay:
button.TriggerClick();
return true;
case GlobalAction.ExportReplay:
State.BindValueChanged(exportWhenReady, true);
// start the import via button
if (State.Value != DownloadState.LocallyAvailable)
button.TriggerClick();
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
private void exportWhenReady(ValueChangedEvent<DownloadState> state)
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
scoreManager.Export(Score.Value);
State.ValueChanged -= exportWhenReady;
}
#endregion
private void updateState() private void updateState()
{ {
switch (replayAvailability) switch (replayAvailability)

View File

@ -160,7 +160,7 @@ namespace osu.Game.Screens.Ranking
if (allowWatchingReplay) if (allowWatchingReplay)
{ {
buttons.Add(new ReplayDownloadButton(null) buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{ {
Score = { BindTarget = SelectedScore }, Score = { BindTarget = SelectedScore },
Width = 300 Width = 300