1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:17:51 +08:00

Apply code review suggestions

This commit is contained in:
wooster0 2024-01-03 00:17:23 +09:00
parent 580f2200a9
commit a42a1eeca2
2 changed files with 12 additions and 17 deletions

View File

@ -60,7 +60,7 @@ namespace osu.Game.Online.Leaderboards
private APIRequest? fetchScoresRequest;
private LeaderboardState state;
public LeaderboardState State { get; private set; }
[Resolved(CanBeNull = true)]
private IAPIProvider? api { get; set; }
@ -298,7 +298,7 @@ namespace osu.Game.Online.Leaderboards
private void setState(LeaderboardState state)
{
if (state == this.state)
if (state == State)
return;
if (state == LeaderboardState.Retrieving)
@ -306,7 +306,7 @@ namespace osu.Game.Online.Leaderboards
else
loading.Hide();
this.state = state;
State = state;
placeholder?.FadeOut(150, Easing.OutQuint).Expire();
@ -360,14 +360,6 @@ namespace osu.Game.Online.Leaderboards
}
}
/// <summary>
/// Whether the leaderboard is displaying scores (at least one).
/// </summary>
public bool HasScores()
{
return state == LeaderboardState.Success;
}
#endregion
#region Fade handling

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
@ -23,6 +24,7 @@ using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Users;
using osu.Game.Utils;
using osu.Game.Online.Leaderboards;
using osuTK.Input;
namespace osu.Game.Screens.Select
@ -47,11 +49,13 @@ namespace osu.Game.Screens.Select
private PlayBeatmapDetailArea playBeatmapDetailArea = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, OsuConfigManager config)
{
BeatmapOptions.AddButton(ButtonSystemStrings.Edit.ToSentence(), @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit());
AddInternal(new SongSelectTouchInputDetector());
beatmapDetailTab = config.GetBindable<PlayBeatmapDetailArea.TabType>(OsuSetting.BeatmapDetailTab);
}
protected void PresentScore(ScoreInfo score) =>
@ -89,8 +93,7 @@ namespace osu.Game.Screens.Select
private ModAutoplay? getAutoplayMod() => Ruleset.Value.CreateInstance().GetAutoplayMod();
[Resolved]
private OsuConfigManager config { get; set; } = null!;
private Bindable<PlayBeatmapDetailArea.TabType> beatmapDetailTab = null!;
protected override bool OnStart()
{
@ -122,9 +125,9 @@ namespace osu.Game.Screens.Select
// Default to local leaderboard if the currently selected leaderboard doesn't have scores or is unavailable
// perhaps because it requires sign in, requires the beatmap to be ranked, etc.
bool isLeaderboardSelected = config.Get<PlayBeatmapDetailArea.TabType>(OsuSetting.BeatmapDetailTab) != PlayBeatmapDetailArea.TabType.Details;
if (isLeaderboardSelected && !playBeatmapDetailArea.Leaderboard.HasScores())
config.SetValue(OsuSetting.BeatmapDetailTab, PlayBeatmapDetailArea.TabType.Local);
bool isLeaderboardSelected = beatmapDetailTab.Value != PlayBeatmapDetailArea.TabType.Details;
if (isLeaderboardSelected && !(playBeatmapDetailArea.Leaderboard.State == LeaderboardState.Success))
beatmapDetailTab.Value = PlayBeatmapDetailArea.TabType.Local;
SampleConfirm?.Play();