1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 16:02:58 +08:00

Merge branch 'master' into no-confirmation-on-update-restart

This commit is contained in:
Dean Herbert 2023-06-23 15:33:01 +09:00 committed by GitHub
commit 1dc7c05c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 302 additions and 65 deletions

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Skinning;
using osuTK;
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
/// <summary>
/// A combo counter implementation that visually behaves almost similar to stable's osu!catch combo counter.
/// </summary>
public partial class LegacyCatchComboCounter : CompositeDrawable, ICatchComboCounter
public partial class LegacyCatchComboCounter : UprightAspectMaintainingContainer, ICatchComboCounter
{
private readonly LegacyRollingCounter counter;

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Comments;
using osuTK;
@ -25,6 +26,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private TestCommentEditor commentEditor = null!;
private TestCancellableCommentEditor cancellableCommentEditor = null!;
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
[SetUp]
public void SetUp() => Schedule(() =>
@ -96,12 +98,43 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("button is not loading", () => !commentEditor.IsSpinnerShown);
}
[Test]
public void TestLoggingInAndOut()
{
void assertLoggedInState()
{
AddAssert("commit button visible", () => commentEditor.ButtonsContainer[0].Alpha == 1);
AddAssert("login button hidden", () => commentEditor.ButtonsContainer[1].Alpha == 0);
AddAssert("text box editable", () => !commentEditor.TextBox.ReadOnly);
}
void assertLoggedOutState()
{
AddAssert("commit button hidden", () => commentEditor.ButtonsContainer[0].Alpha == 0);
AddAssert("login button visible", () => commentEditor.ButtonsContainer[1].Alpha == 1);
AddAssert("text box readonly", () => commentEditor.TextBox.ReadOnly);
}
// there's also the case of starting logged out, but more annoying to test.
// starting logged in
assertLoggedInState();
// moving from logged in -> logged out
AddStep("log out", () => dummyAPI.Logout());
assertLoggedOutState();
// moving from logged out -> logged in
AddStep("log back in", () => dummyAPI.Login("username", "password"));
assertLoggedInState();
}
[Test]
public void TestCancelAction()
{
AddStep("click cancel button", () =>
{
InputManager.MoveMouseTo(cancellableCommentEditor.ButtonsContainer[1]);
InputManager.MoveMouseTo(cancellableCommentEditor.ButtonsContainer[2]);
InputManager.Click(MouseButton.Left);
});
@ -112,6 +145,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
public new Bindable<string> Current => base.Current;
public new FillFlowContainer ButtonsContainer => base.ButtonsContainer;
public new TextBox TextBox => base.TextBox;
public string CommittedText { get; private set; } = string.Empty;
@ -125,8 +159,12 @@ namespace osu.Game.Tests.Visual.UserInterface
}
protected override LocalisableString FooterText => @"Footer text. And it is pretty long. Cool.";
protected override LocalisableString CommitButtonText => @"Commit";
protected override LocalisableString TextBoxPlaceholder => @"This text box is empty";
protected override LocalisableString GetButtonText(bool isLoggedIn) =>
isLoggedIn ? @"Commit" : "You're logged out!";
protected override LocalisableString GetPlaceholderText(bool isLoggedIn) =>
isLoggedIn ? @"This text box is empty" : "Still empty, but now you can't type in it.";
}
private partial class TestCancellableCommentEditor : CancellableCommentEditor
@ -146,8 +184,8 @@ namespace osu.Game.Tests.Visual.UserInterface
{
}
protected override LocalisableString CommitButtonText => @"Save";
protected override LocalisableString TextBoxPlaceholder => @"Multiline textboxes soon";
protected override LocalisableString GetButtonText(bool isLoggedIn) => @"Save";
protected override LocalisableString GetPlaceholderText(bool isLoggedIn) => @"Multiline textboxes soon";
}
}
}

View File

@ -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);
}

View File

@ -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,
}
}

View File

@ -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}";
}
}

View File

@ -34,7 +34,8 @@ namespace osu.Game.Online.API
public string AccessToken => "token";
public bool IsLoggedIn => State.Value == APIState.Online;
/// <seealso cref="APIAccess.IsLoggedIn"/>
public bool IsLoggedIn => State.Value > APIState.Offline;
public string ProvidedUsername => LocalUser.Value.Username;
@ -114,8 +115,10 @@ namespace osu.Game.Online.API
public void Logout()
{
LocalUser.Value = new GuestUser();
state.Value = APIState.Offline;
// must happen after `state.Value` is changed such that subscribers to that bindable's value changes see the correct user.
// compare: `APIAccess.Logout()`.
LocalUser.Value = new GuestUser();
}
public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => null;

View File

@ -13,6 +13,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API;
using osuTK;
using osuTK.Graphics;
@ -24,19 +25,37 @@ namespace osu.Game.Overlays.Comments
protected abstract LocalisableString FooterText { get; }
protected abstract LocalisableString CommitButtonText { get; }
protected abstract LocalisableString TextBoxPlaceholder { get; }
protected FillFlowContainer ButtonsContainer { get; private set; } = null!;
protected readonly Bindable<string> Current = new Bindable<string>(string.Empty);
private RoundedButton commitButton = null!;
private RoundedButton logInButton = null!;
private LoadingSpinner loadingSpinner = null!;
protected TextBox TextBox { get; private set; } = null!;
[Resolved]
protected IAPIProvider API { get; private set; } = null!;
[Resolved]
private LoginOverlay? loginOverlay { get; set; }
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
/// <summary>
/// Returns the text content of the main action button.
/// When <paramref name="isLoggedIn"/> is <see langword="true"/>, the text will apply to a button that posts a comment.
/// When <paramref name="isLoggedIn"/> is <see langword="false"/>, the text will apply to a button that directs the user to the login overlay.
/// </summary>
protected abstract LocalisableString GetButtonText(bool isLoggedIn);
/// <summary>
/// Returns the placeholder text for the comment box.
/// </summary>
/// <param name="isLoggedIn">Whether the current user is logged in.</param>
protected abstract LocalisableString GetPlaceholderText(bool isLoggedIn);
protected bool ShowLoadingSpinner
{
set
@ -78,7 +97,6 @@ namespace osu.Game.Overlays.Comments
{
Height = 40,
RelativeSizeAxes = Axes.X,
PlaceholderText = TextBoxPlaceholder,
Current = Current
},
new Container
@ -113,10 +131,19 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Child = commitButton = new EditorButton
Children = new Drawable[]
{
Text = CommitButtonText,
Action = () => OnCommit(Current.Value)
commitButton = new EditorButton
{
Action = () => OnCommit(Current.Value),
Text = GetButtonText(true)
},
logInButton = new EditorButton
{
Width = 100,
Action = () => loginOverlay?.Show(),
Text = GetButtonText(false)
}
}
},
loadingSpinner = new LoadingSpinner
@ -134,12 +161,14 @@ namespace osu.Game.Overlays.Comments
});
TextBox.OnCommit += (_, _) => commitButton.TriggerClick();
apiState.BindTo(API.State);
}
protected override void LoadComplete()
{
base.LoadComplete();
Current.BindValueChanged(_ => updateCommitButtonState(), true);
apiState.BindValueChanged(updateStateForLoggedIn, true);
}
protected abstract void OnCommit(string text);
@ -147,6 +176,25 @@ namespace osu.Game.Overlays.Comments
private void updateCommitButtonState() =>
commitButton.Enabled.Value = loadingSpinner.State.Value == Visibility.Hidden && !string.IsNullOrEmpty(Current.Value);
private void updateStateForLoggedIn(ValueChangedEvent<APIState> state) => Schedule(() =>
{
bool isAvailable = state.NewValue > APIState.Offline;
TextBox.PlaceholderText = GetPlaceholderText(isAvailable);
TextBox.ReadOnly = !isAvailable;
if (isAvailable)
{
commitButton.Show();
logInButton.Hide();
}
else
{
commitButton.Hide();
logInButton.Show();
}
});
private partial class EditorTextBox : OsuTextBox
{
protected override float LeftRightPadding => side_padding;

View File

@ -405,17 +405,16 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private CommentsContainer commentsContainer { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
public Action<CommentBundle> OnPost;
//TODO should match web, left empty due to no multiline support
protected override LocalisableString FooterText => default;
protected override LocalisableString CommitButtonText => CommonStrings.ButtonsPost;
protected override LocalisableString GetButtonText(bool isLoggedIn) =>
isLoggedIn ? CommonStrings.ButtonsPost : CommentsStrings.GuestButtonNew;
protected override LocalisableString TextBoxPlaceholder => CommentsStrings.PlaceholderNew;
protected override LocalisableString GetPlaceholderText(bool isLoggedIn) =>
isLoggedIn ? CommentsStrings.PlaceholderNew : AuthorizationStrings.RequireLogin;
protected override void OnCommit(string text)
{
@ -432,7 +431,7 @@ namespace osu.Game.Overlays.Comments
Current.Value = string.Empty;
OnPost?.Invoke(cb);
});
api.Queue(req);
API.Queue(req);
}
}
}

View File

@ -6,7 +6,6 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
@ -18,16 +17,17 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private CommentsContainer commentsContainer { get; set; } = null!;
[Resolved]
private IAPIProvider api { get; set; } = null!;
private readonly Comment parentComment;
public Action<DrawableComment[]>? OnPost;
protected override LocalisableString FooterText => default;
protected override LocalisableString CommitButtonText => CommonStrings.ButtonsReply;
protected override LocalisableString TextBoxPlaceholder => CommentsStrings.PlaceholderReply;
protected override LocalisableString GetButtonText(bool isLoggedIn) =>
isLoggedIn ? CommonStrings.ButtonsReply : CommentsStrings.GuestButtonReply;
protected override LocalisableString GetPlaceholderText(bool isLoggedIn) =>
isLoggedIn ? CommentsStrings.PlaceholderReply : AuthorizationStrings.RequireLogin;
public ReplyCommentEditor(Comment parent)
{
@ -38,7 +38,8 @@ namespace osu.Game.Overlays.Comments
{
base.LoadComplete();
GetContainingInputManager().ChangeFocus(TextBox);
if (!TextBox.ReadOnly)
GetContainingInputManager().ChangeFocus(TextBox);
}
protected override void OnCommit(string text)
@ -51,7 +52,7 @@ namespace osu.Game.Overlays.Comments
Logger.Error(e, "Posting reply comment failed.");
});
req.Success += cb => Schedule(processPostedComments, cb);
api.Queue(req);
API.Queue(req);
}
private void processPostedComments(CommentBundle cb)

View File

@ -316,6 +316,8 @@ namespace osu.Game.Overlays
var queuedTrack = getQueuedTrack();
var lastTrack = CurrentTrack;
lastTrack.Completed -= onTrackCompleted;
CurrentTrack = queuedTrack;
// At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
@ -344,16 +346,12 @@ namespace osu.Game.Overlays
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
// Can lead to leaks.
var queuedTrack = new DrawableTrack(current.LoadTrack());
queuedTrack.Completed += () => onTrackCompleted(current);
queuedTrack.Completed += onTrackCompleted;
return queuedTrack;
}
private void onTrackCompleted(WorkingBeatmap workingBeatmap)
private void onTrackCompleted()
{
// the source of track completion is the audio thread, so the beatmap may have changed before firing.
if (current != workingBeatmap)
return;
if (!CurrentTrack.Looping && !beatmap.Disabled)
NextTrack();
}

View File

@ -122,7 +122,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();

View File

@ -3,11 +3,13 @@
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Screens;
@ -45,6 +47,12 @@ namespace osu.Game.Overlays.SkinEditor
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.BeatmapSkins, beatmapSkins);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
@ -62,6 +70,8 @@ namespace osu.Game.Overlays.SkinEditor
protected override void PopIn()
{
globallyDisableBeatmapSkinSetting();
if (skinEditor != null)
{
skinEditor.Show();
@ -87,7 +97,13 @@ namespace osu.Game.Overlays.SkinEditor
});
}
protected override void PopOut() => skinEditor?.Hide();
protected override void PopOut()
{
skinEditor?.Save(false);
skinEditor?.Hide();
globallyReenableBeatmapSkinSetting();
}
protected override void Update()
{
@ -151,8 +167,6 @@ namespace osu.Game.Overlays.SkinEditor
if (skinEditor == null) return;
skinEditor.Save(userTriggered: false);
// ensure the toolbar is re-hidden even if a new screen decides to try and show it.
updateComponentVisibility();
@ -182,5 +196,25 @@ namespace osu.Game.Overlays.SkinEditor
skinEditor = null;
}
}
private readonly Bindable<bool> beatmapSkins = new Bindable<bool>();
private LeasedBindable<bool>? leasedBeatmapSkins;
private void globallyDisableBeatmapSkinSetting()
{
if (beatmapSkins.Disabled)
return;
// The skin editor doesn't work well if beatmap skins are being applied to the player screen.
// To keep things simple, disable the setting game-wide while using the skin editor.
leasedBeatmapSkins = beatmapSkins.BeginLease(true);
leasedBeatmapSkins.Value = false;
}
private void globallyReenableBeatmapSkinSetting()
{
leasedBeatmapSkins?.Return();
leasedBeatmapSkins = null;
}
}
}

View File

@ -86,7 +86,7 @@ namespace osu.Game.Screens.Backgrounds
if (nextBackground == background)
return false;
Logger.Log("🌅 Background change queued");
Logger.Log(@"🌅 Global background change queued");
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
@ -94,6 +94,7 @@ namespace osu.Game.Screens.Backgrounds
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
Logger.Log(@"🌅 Global background loading");
LoadComponentAsync(nextBackground, displayNext, cancellationTokenSource.Token);
}, 500);

View File

@ -49,6 +49,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[Resolved]
private MultiplayerClient client { get; set; }
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
private AddItemButton addItemButton;
public MultiplayerMatchSubScreen(Room room)
@ -334,11 +337,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
updateCurrentItem();
addItemButton.Alpha = client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly ? 1 : 0;
addItemButton.Alpha = localUserCanAddItem ? 1 : 0;
Scheduler.AddOnce(UpdateMods);
}
private bool localUserCanAddItem => client.IsHost || Room.QueueMode.Value != QueueMode.HostOnly;
private void updateCurrentItem()
{
Debug.Assert(client.Room != null);
@ -403,18 +408,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
if (!this.IsCurrentScreen())
return;
if (client.Room == null)
if (!localUserCanAddItem)
return;
if (!client.IsHost)
{
// todo: should handle this when the request queue is implemented.
// if we decide that the presentation should exit the user from the multiplayer game, the PresentBeatmap
// flow may need to change to support an "unable to present" return value.
return;
}
// If there's only one playlist item and we are the host, assume we want to change it. Else add a new one.
PlaylistItem itemToEdit = client.IsHost && Room.Playlist.Count == 1 ? Room.Playlist.Single() : null;
this.Push(new MultiplayerMatchSongSelect(Room, Room.Playlist.Single(item => item.ID == client.Room.Settings.PlaylistItemId)));
OpenSongSelection(itemToEdit);
// Re-run PresentBeatmap now that we've pushed a song select that can handle it.
game?.PresentBeatmap(beatmap.BeatmapSetInfo, b => b.ID == beatmap.BeatmapInfo.ID);
}
protected override void Dispose(bool isDisposing)

View File

@ -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
}
}

View File

@ -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)

View File

@ -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