mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 05:32:54 +08:00
Merge branch 'master' into skin-editor-beatmap-skin-disable
This commit is contained in:
commit
a11b3a67fb
@ -111,6 +111,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
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);
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
@ -119,6 +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.F1, GlobalAction.SaveReplay),
|
||||
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> ReplayKeyBindings => new[]
|
||||
@ -366,5 +368,11 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorCycleNextBeatSnapDivisor))]
|
||||
EditorCycleNextBeatSnapDivisor,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SaveReplay))]
|
||||
SaveReplay,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ExportReplay))]
|
||||
ExportReplay,
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,16 @@ 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");
|
||||
|
||||
/// <summary>
|
||||
/// "Export replay"
|
||||
/// </summary>
|
||||
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
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();
|
||||
|
||||
|
@ -8,16 +8,26 @@ 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 osu.Game.Online.Multiplayer;
|
||||
using osuTK;
|
||||
|
||||
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 Func<Task<ScoreInfo>> importFailedScore;
|
||||
@ -34,7 +44,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
|
||||
{
|
||||
@ -54,7 +64,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
|
||||
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
|
||||
});
|
||||
}).FireAndForget();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -87,5 +97,43 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}, 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
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,34 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
|
||||
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>();
|
||||
|
||||
protected readonly Bindable<DownloadState> State = new Bindable<DownloadState>();
|
||||
|
||||
private DownloadButton button;
|
||||
private ShakeContainer shakeContainer;
|
||||
private DownloadButton button = null!;
|
||||
private ShakeContainer shakeContainer = null!;
|
||||
|
||||
private ScoreDownloadTracker downloadTracker;
|
||||
private ScoreDownloadTracker? downloadTracker;
|
||||
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; } = null!;
|
||||
|
||||
private ReplayAvailability replayAvailability
|
||||
{
|
||||
@ -46,8 +50,8 @@ namespace osu.Game.Screens.Ranking
|
||||
Size = new Vector2(50, 30);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, ScoreModelDownloader scores)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGame? game, ScoreModelDownloader scoreDownloader)
|
||||
{
|
||||
InternalChild = shakeContainer = new ShakeContainer
|
||||
{
|
||||
@ -67,7 +71,7 @@ namespace osu.Game.Screens.Ranking
|
||||
break;
|
||||
|
||||
case DownloadState.NotDownloaded:
|
||||
scores.Download(Score.Value);
|
||||
scoreDownloader.Download(Score.Value);
|
||||
break;
|
||||
|
||||
case DownloadState.Importing:
|
||||
@ -99,6 +103,44 @@ namespace osu.Game.Screens.Ranking
|
||||
}, 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()
|
||||
{
|
||||
switch (replayAvailability)
|
||||
|
@ -160,7 +160,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
if (allowWatchingReplay)
|
||||
{
|
||||
buttons.Add(new ReplayDownloadButton(null)
|
||||
buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
|
||||
{
|
||||
Score = { BindTarget = SelectedScore },
|
||||
Width = 300
|
||||
|
Loading…
Reference in New Issue
Block a user