1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 14:47:18 +08:00

Merge branch 'master' into restore-default-button-hit-area

This commit is contained in:
Salman Ahmed 2022-12-22 13:32:57 +03:00 committed by GitHub
commit 28fc2f34b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 13 deletions

View File

@ -134,6 +134,9 @@ namespace osu.Game.Rulesets.Mania.UI
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
// must happen before children are disposed in base call to prevent illegal accesses to the hit explosion pool.
NewResult -= OnNewResult;
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (skin != null) if (skin != null)

View File

@ -156,6 +156,9 @@ namespace osu.Game.Rulesets.Mania.UI
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
// must happen before children are disposed in base call to prevent illegal accesses to the judgement pool.
NewResult -= OnNewResult;
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (currentSkin != null) if (currentSkin != null)

View File

@ -32,5 +32,12 @@ namespace osu.Game.Online.Spectator
/// <param name="userId">The user.</param> /// <param name="userId">The user.</param>
/// <param name="data">The frame data.</param> /// <param name="data">The frame data.</param>
Task UserSentFrames(int userId, FrameDataBundle data); Task UserSentFrames(int userId, FrameDataBundle data);
/// <summary>
/// Signals that a user's submitted score was fully processed.
/// </summary>
/// <param name="userId">The ID of the user who achieved the score.</param>
/// <param name="scoreId">The ID of the score.</param>
Task UserScoreProcessed(int userId, long scoreId);
} }
} }

View File

@ -41,6 +41,7 @@ namespace osu.Game.Online.Spectator
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying); connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames); connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserFinishedPlaying), ((ISpectatorClient)this).UserFinishedPlaying); connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserFinishedPlaying), ((ISpectatorClient)this).UserFinishedPlaying);
connection.On<int, long>(nameof(ISpectatorClient.UserScoreProcessed), ((ISpectatorClient)this).UserScoreProcessed);
}; };
IsConnected.BindTo(connector.IsConnected); IsConnected.BindTo(connector.IsConnected);

View File

@ -64,6 +64,11 @@ namespace osu.Game.Online.Spectator
/// </summary> /// </summary>
public virtual event Action<int, SpectatorState>? OnUserFinishedPlaying; public virtual event Action<int, SpectatorState>? OnUserFinishedPlaying;
/// <summary>
/// Called whenever a user-submitted score has been fully processed.
/// </summary>
public virtual event Action<int, long>? OnUserScoreProcessed;
/// <summary> /// <summary>
/// A dictionary containing all users currently being watched, with the number of watching components for each user. /// A dictionary containing all users currently being watched, with the number of watching components for each user.
/// </summary> /// </summary>
@ -160,6 +165,13 @@ namespace osu.Game.Online.Spectator
return Task.CompletedTask; return Task.CompletedTask;
} }
Task ISpectatorClient.UserScoreProcessed(int userId, long scoreId)
{
Schedule(() => OnUserScoreProcessed?.Invoke(userId, scoreId));
return Task.CompletedTask;
}
public void BeginPlaying(long? scoreToken, GameplayState state, Score score) public void BeginPlaying(long? scoreToken, GameplayState state, Score score)
{ {
// This schedule is only here to match the one below in `EndPlaying`. // This schedule is only here to match the one below in `EndPlaying`.

View File

@ -87,18 +87,21 @@ namespace osu.Game.Overlays.FirstRunSetup
}); });
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale); frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
frameworkLocale.BindValueChanged(_ => onLanguageChange());
localisationParameters = localisation.CurrentParameters.GetBoundCopy(); localisationParameters = localisation.CurrentParameters.GetBoundCopy();
localisationParameters.BindValueChanged(p => localisationParameters.BindValueChanged(_ => onLanguageChange(), true);
{ }
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue);
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded. private void onLanguageChange()
// Scheduling ensures the button animation plays smoothly after any blocking operation completes. {
// Note that a delay is required (the alternative would be a double-schedule; delay feels better). var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50); // Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
}, true); // Scheduling ensures the button animation plays smoothly after any blocking operation completes.
// Note that a delay is required (the alternative would be a double-schedule; delay feels better).
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50);
} }
private void updateSelectedStates(Language language) private void updateSelectedStates(Language language)

View File

@ -44,10 +44,13 @@ namespace osu.Game.Overlays.Settings.Sections.General
}, },
}; };
localisationParameters.BindValueChanged(p frameworkLocale.BindValueChanged(_ => updateSelection());
=> languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue), true); localisationParameters.BindValueChanged(_ => updateSelection(), true);
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode()); languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
} }
private void updateSelection() =>
languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
} }
} }

View File

@ -13,6 +13,7 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -158,8 +159,11 @@ namespace osu.Game.Screens.Play
if (LoadedBeatmapSuccessfully) if (LoadedBeatmapSuccessfully)
{ {
submitScore(Score.DeepClone()); Task.Run(async () =>
spectatorClient.EndPlaying(GameplayState); {
await submitScore(Score.DeepClone()).ConfigureAwait(false);
spectatorClient.EndPlaying(GameplayState);
}).FireAndForget();
} }
return exiting; return exiting;