mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into allow-back-in-player
This commit is contained in:
@ -80,22 +80,24 @@ namespace osu.Game.Screens
|
||||
private SampleChannel sampleExit;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BindableBeatmap beatmap, OsuGame osuGame, AudioManager audio)
|
||||
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
|
||||
{
|
||||
if (beatmap != null)
|
||||
Beatmap.BindTo(beatmap);
|
||||
|
||||
if (osuGame != null)
|
||||
if (ruleset != null)
|
||||
Ruleset.BindTo(ruleset);
|
||||
|
||||
if (osu != null)
|
||||
{
|
||||
Ruleset.BindTo(osuGame.Ruleset);
|
||||
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
||||
OverlayActivationMode.BindTo(osu.OverlayActivationMode);
|
||||
|
||||
updateOverlayStates = () =>
|
||||
{
|
||||
if (HideOverlaysOnEnter)
|
||||
osuGame.CloseAllOverlays();
|
||||
osu.CloseAllOverlays();
|
||||
else
|
||||
osuGame.Toolbar.State = Visibility.Visible;
|
||||
osu.Toolbar.State = Visibility.Visible;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,10 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] OsuGame osuGame)
|
||||
private void load([CanBeNull] Bindable<RulesetInfo> parentRuleset)
|
||||
{
|
||||
if (osuGame != null)
|
||||
ruleset.BindTo(osuGame.Ruleset);
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.ValueChanged += _ => updateDisplay();
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select
|
||||
Sort = sort,
|
||||
SearchText = searchTextBox.Text,
|
||||
AllowConvertedBeatmaps = showConverted,
|
||||
Ruleset = ruleset
|
||||
Ruleset = ruleset.Value
|
||||
};
|
||||
|
||||
public Action Exit;
|
||||
@ -163,24 +163,23 @@ namespace osu.Game.Screens.Select
|
||||
searchTextBox.HoldFocus = true;
|
||||
}
|
||||
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private Bindable<bool> showConverted;
|
||||
|
||||
public readonly Box Background;
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colours, OsuGame osu, OsuConfigManager config)
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> parentRuleset, OsuConfigManager config)
|
||||
{
|
||||
sortTabs.AccentColour = colours.GreenLight;
|
||||
|
||||
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
|
||||
showConverted.ValueChanged += val => updateCriteria();
|
||||
|
||||
if (osu != null)
|
||||
ruleset.BindTo(osu.Ruleset);
|
||||
ruleset.ValueChanged += val => updateCriteria();
|
||||
ruleset.TriggerChange();
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.BindValueChanged(val => updateCriteria(), true);
|
||||
}
|
||||
|
||||
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());
|
||||
|
@ -19,7 +19,6 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
@ -33,7 +32,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private FillFlowContainer<LeaderboardScore> scrollFlow;
|
||||
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
public Action<Score> ScoreSelected;
|
||||
|
||||
@ -174,9 +173,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private APIAccess api;
|
||||
private BeatmapInfo beatmap;
|
||||
private OsuGame osuGame;
|
||||
|
||||
private ScheduledDelegate pendingBeatmapSwitch;
|
||||
private ScheduledDelegate pendingUpdateScores;
|
||||
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
@ -189,21 +187,19 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
beatmap = value;
|
||||
Scores = null;
|
||||
|
||||
pendingBeatmapSwitch?.Cancel();
|
||||
pendingBeatmapSwitch = Schedule(updateScores);
|
||||
updateScores();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(APIAccess api, OsuGame osuGame)
|
||||
private void load(APIAccess api, IBindable<RulesetInfo> parentRuleset)
|
||||
{
|
||||
this.api = api;
|
||||
this.osuGame = osuGame;
|
||||
|
||||
if (osuGame != null)
|
||||
ruleset.BindTo(osuGame.Ruleset);
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
|
||||
ruleset.ValueChanged += r => updateScores();
|
||||
ruleset.ValueChanged += _ => updateScores();
|
||||
|
||||
if (api != null)
|
||||
api.OnStateChange += handleApiStateChange;
|
||||
@ -231,51 +227,57 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private void updateScores()
|
||||
{
|
||||
if (Scope == LeaderboardScope.Local)
|
||||
{
|
||||
// TODO: get local scores from wherever here.
|
||||
PlaceholderState = PlaceholderState.NoScores;
|
||||
return;
|
||||
}
|
||||
getScoresRequest?.Cancel();
|
||||
getScoresRequest = null;
|
||||
|
||||
if (Beatmap?.OnlineBeatmapID == null)
|
||||
pendingUpdateScores?.Cancel();
|
||||
pendingUpdateScores = Schedule(() =>
|
||||
{
|
||||
PlaceholderState = PlaceholderState.Unavailable;
|
||||
return;
|
||||
}
|
||||
|
||||
if (api?.IsLoggedIn != true)
|
||||
{
|
||||
PlaceholderState = PlaceholderState.NotLoggedIn;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
|
||||
{
|
||||
PlaceholderState = PlaceholderState.NotSupporter;
|
||||
return;
|
||||
}
|
||||
|
||||
PlaceholderState = PlaceholderState.Retrieving;
|
||||
loading.Show();
|
||||
|
||||
getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope);
|
||||
getScoresRequest.Success += r => Schedule(() =>
|
||||
{
|
||||
Scores = r.Scores;
|
||||
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
|
||||
});
|
||||
|
||||
getScoresRequest.Failure += e => Schedule(() =>
|
||||
{
|
||||
if (e is OperationCanceledException)
|
||||
if (Scope == LeaderboardScope.Local)
|
||||
{
|
||||
// TODO: get local scores from wherever here.
|
||||
PlaceholderState = PlaceholderState.NoScores;
|
||||
return;
|
||||
}
|
||||
|
||||
PlaceholderState = PlaceholderState.NetworkFailure;
|
||||
Logger.Error(e, @"Couldn't fetch beatmap scores!");
|
||||
if (Beatmap?.OnlineBeatmapID == null)
|
||||
{
|
||||
PlaceholderState = PlaceholderState.Unavailable;
|
||||
return;
|
||||
}
|
||||
|
||||
if (api?.IsLoggedIn != true)
|
||||
{
|
||||
PlaceholderState = PlaceholderState.NotLoggedIn;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
|
||||
{
|
||||
PlaceholderState = PlaceholderState.NotSupporter;
|
||||
return;
|
||||
}
|
||||
|
||||
PlaceholderState = PlaceholderState.Retrieving;
|
||||
loading.Show();
|
||||
|
||||
getScoresRequest = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope);
|
||||
getScoresRequest.Success += r => Schedule(() =>
|
||||
{
|
||||
Scores = r.Scores;
|
||||
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
|
||||
});
|
||||
|
||||
getScoresRequest.Failure += e => Schedule(() =>
|
||||
{
|
||||
if (e is OperationCanceledException)
|
||||
return;
|
||||
|
||||
PlaceholderState = PlaceholderState.NetworkFailure;
|
||||
});
|
||||
|
||||
api.Queue(getScoresRequest);
|
||||
});
|
||||
|
||||
api.Queue(getScoresRequest);
|
||||
}
|
||||
|
||||
private Placeholder currentPlaceholder;
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
@ -17,6 +18,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Menu;
|
||||
@ -62,6 +64,8 @@ namespace osu.Game.Screens.Select
|
||||
private SampleChannel sampleChangeDifficulty;
|
||||
private SampleChannel sampleChangeBeatmap;
|
||||
|
||||
protected new readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||
@ -123,7 +127,7 @@ namespace osu.Game.Screens.Select
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
SelectionChanged = updateSelectedBeatmap,
|
||||
BeatmapSetsChanged = carouselBeatmapsLoaded,
|
||||
},
|
||||
FilterControl = new FilterControl
|
||||
@ -177,9 +181,13 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours)
|
||||
{
|
||||
dependencies.CacheAs(this);
|
||||
dependencies.CacheAs(Ruleset);
|
||||
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
|
||||
|
||||
base.Ruleset.ValueChanged += r => updateSelectedBeatmap(beatmapNoDebounce);
|
||||
|
||||
if (Footer != null)
|
||||
{
|
||||
@ -192,9 +200,6 @@ namespace osu.Game.Screens.Select
|
||||
if (this.beatmaps == null)
|
||||
this.beatmaps = beatmaps;
|
||||
|
||||
if (osu != null)
|
||||
Ruleset.BindTo(osu.Ruleset);
|
||||
|
||||
this.beatmaps.ItemAdded += onBeatmapSetAdded;
|
||||
this.beatmaps.ItemRemoved += onBeatmapSetRemoved;
|
||||
this.beatmaps.BeatmapHidden += onBeatmapHidden;
|
||||
@ -250,9 +255,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private ScheduledDelegate selectionChangedDebounce;
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
private BeatmapInfo beatmapNoDebounce;
|
||||
|
||||
private void workingBeatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (beatmap is DummyWorkingBeatmap) return;
|
||||
@ -266,11 +268,17 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
private BeatmapInfo beatmapNoDebounce;
|
||||
private RulesetInfo rulesetNoDebounce;
|
||||
|
||||
/// <summary>
|
||||
/// selection has been changed as the result of interaction with the carousel.
|
||||
/// selection has been changed as the result of a user interaction.
|
||||
/// </summary>
|
||||
private void carouselSelectionChanged(BeatmapInfo beatmap)
|
||||
private void updateSelectedBeatmap(BeatmapInfo beatmap)
|
||||
{
|
||||
var ruleset = base.Ruleset.Value;
|
||||
|
||||
void performLoad()
|
||||
{
|
||||
// We may be arriving here due to another component changing the bindable Beatmap.
|
||||
@ -283,15 +291,18 @@ namespace osu.Game.Screens.Select
|
||||
ensurePlayingSelected(preview);
|
||||
}
|
||||
|
||||
Ruleset.Value = ruleset;
|
||||
|
||||
UpdateBeatmap(Beatmap.Value);
|
||||
}
|
||||
|
||||
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||
if (beatmap?.Equals(beatmapNoDebounce) == true && ruleset?.Equals(rulesetNoDebounce) == true)
|
||||
return;
|
||||
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
rulesetNoDebounce = ruleset;
|
||||
|
||||
if (beatmap == null)
|
||||
performLoad();
|
||||
@ -460,7 +471,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
// in the case random selection failed, we want to trigger selectionChanged
|
||||
// to show the dummy beatmap (we have nothing else to display).
|
||||
carouselSelectionChanged(null);
|
||||
updateSelectedBeatmap(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user