mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Fix playlist items showing download button briefly during initial local presence checks
This commit is contained in:
parent
85ce1bcea9
commit
ed81297611
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
@ -58,6 +59,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
State = { Value = DownloadState.NotDownloaded },
|
||||
Scale = new Vector2(2)
|
||||
};
|
||||
});
|
||||
|
@ -81,9 +81,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
CreateTest();
|
||||
|
||||
AddUntilStep("fail screen displayed", () => Player.ChildrenOfType<FailOverlay>().First().State.Value == Visibility.Visible);
|
||||
AddUntilStep("wait for button clickable", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().Enabled.Value);
|
||||
|
||||
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) == null));
|
||||
AddStep("click save button", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().TriggerClick());
|
||||
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -202,7 +202,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddUntilStep("wait for load", () => downloadButton.IsLoaded);
|
||||
|
||||
AddAssert("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
||||
AddAssert("state is unknown", () => downloadButton.State.Value == DownloadState.Unknown);
|
||||
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
public class DownloadButton : BeatmapCardIconButton
|
||||
{
|
||||
public IBindable<DownloadState> State => state;
|
||||
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
|
||||
public Bindable<DownloadState> State { get; } = new Bindable<DownloadState>();
|
||||
|
||||
private readonly APIBeatmapSet beatmapSet;
|
||||
|
||||
@ -48,14 +47,19 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
base.LoadComplete();
|
||||
preferNoVideo.BindValueChanged(_ => updateState());
|
||||
state.BindValueChanged(_ => updateState(), true);
|
||||
State.BindValueChanged(_ => updateState(), true);
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
switch (state.Value)
|
||||
switch (State.Value)
|
||||
{
|
||||
case DownloadState.Unknown:
|
||||
Action = null;
|
||||
TooltipText = string.Empty;
|
||||
break;
|
||||
|
||||
case DownloadState.Downloading:
|
||||
case DownloadState.Importing:
|
||||
Action = null;
|
||||
|
@ -5,6 +5,7 @@ namespace osu.Game.Online
|
||||
{
|
||||
public enum DownloadState
|
||||
{
|
||||
Unknown,
|
||||
NotDownloaded,
|
||||
Downloading,
|
||||
Importing,
|
||||
|
@ -114,6 +114,7 @@ namespace osu.Game.Online.Rooms
|
||||
|
||||
switch (downloadTracker.State.Value)
|
||||
{
|
||||
case DownloadState.Unknown:
|
||||
case DownloadState.NotDownloaded:
|
||||
availability.Value = BeatmapAvailability.NotDownloaded();
|
||||
break;
|
||||
|
@ -561,6 +561,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case DownloadState.Unknown:
|
||||
// Ignore initial state to ensure the button doesn't briefly appear.
|
||||
break;
|
||||
|
||||
case DownloadState.LocallyAvailable:
|
||||
// Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
|
||||
if (beatmapManager.QueryBeatmap(b => b.MD5Hash == beatmap.MD5Hash) == null)
|
||||
|
@ -63,8 +63,7 @@ namespace osu.Game.Screens.Play
|
||||
if (player != null)
|
||||
{
|
||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
|
||||
if (importedScore != null)
|
||||
state.Value = DownloadState.LocallyAvailable;
|
||||
state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded;
|
||||
}
|
||||
|
||||
state.BindValueChanged(state =>
|
||||
|
Loading…
Reference in New Issue
Block a user