1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 22:34:09 +08:00

Update mod filter visibility on user change

This commit is contained in:
Andrei Zavatski 2019-11-11 18:40:57 +03:00
parent 31191dadf1
commit 5f5d130d1a

View File

@ -16,6 +16,7 @@ using osu.Game.Online.API.Requests;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users;
namespace osu.Game.Overlays.BeatmapSet.Scores namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
@ -145,7 +146,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
modSelector.SelectedMods.ItemsAdded += _ => getScores(); modSelector.SelectedMods.ItemsAdded += _ => getScores();
modSelector.SelectedMods.ItemsRemoved += _ => getScores(); modSelector.SelectedMods.ItemsRemoved += _ => getScores();
Beatmap.BindValueChanged(onBeatmapChanged, true); Beatmap.BindValueChanged(onBeatmapChanged);
api.LocalUser.BindValueChanged(onUserChanged, true);
} }
private void onBeatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap) private void onBeatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
@ -160,6 +162,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
getScores(); getScores();
} }
private void onUserChanged(ValueChangedEvent<User> user)
{
scope.Value = BeatmapLeaderboardScope.Global;
modSelector.DeselectAll();
updateModFilterVisibility();
}
private void updateModFilterVisibility()
{
modFilter.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter && !hasNoLeaderboard ? 1 : 0);
}
private void getScores() private void getScores()
{ {
getScoresRequest?.Cancel(); getScoresRequest?.Cancel();
@ -167,7 +181,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Scores = null; Scores = null;
if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) updateModFilterVisibility();
if (hasNoLeaderboard)
return; return;
loadingAnimation.Show(); loadingAnimation.Show();
@ -179,5 +195,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
api.Queue(getScoresRequest); api.Queue(getScoresRequest);
} }
private bool hasNoLeaderboard => Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending;
} }
} }