Use OnlineViewContainer

This commit is contained in:
PercyDan54 2021-04-02 20:14:31 +08:00
parent dac8e5fdf4
commit 1ff77754fd
No known key found for this signature in database
GPG Key ID: 6AEA7C525131BAF3
2 changed files with 12 additions and 7 deletions

View File

@ -5,6 +5,7 @@ using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
namespace osu.Game.Tests.Visual.SongSelect namespace osu.Game.Tests.Visual.SongSelect
@ -14,6 +15,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
private BeatmapDetails details; private BeatmapDetails details;
private DummyAPIAccess api => (DummyAPIAccess)API;
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(() =>
{ {
@ -173,6 +176,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
OnlineBeatmapID = 162, OnlineBeatmapID = 162,
}); });
AddStep("set online", () => api.SetState(APIState.Online));
AddStep("set offline", () => api.SetState(APIState.Offline));
} }
} }
} }

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Online;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -136,7 +137,7 @@ namespace osu.Game.Screens.Select
}, },
}, },
}, },
failRetryContainer = new Container failRetryContainer = new OnlineViewContainer("Sign in to view more details")
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
@ -153,11 +154,11 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 14 + spacing / 2 }, Padding = new MarginPadding { Top = 14 + spacing / 2 },
}, },
loading = new LoadingLayer(true)
}, },
}, },
}, },
}, },
loading = new LoadingLayer(true),
}; };
} }
@ -222,11 +223,9 @@ namespace osu.Game.Screens.Select
if (beatmap != requestedBeatmap) if (beatmap != requestedBeatmap)
// the beatmap has been changed since we started the lookup. // the beatmap has been changed since we started the lookup.
return; return;
updateMetrics(); updateMetrics();
}); });
}; };
api.Queue(lookup); api.Queue(lookup);
loading.Show(); loading.Show();
} }
@ -236,7 +235,9 @@ namespace osu.Game.Screens.Select
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false; var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) || (beatmap?.Metrics?.Fails?.Any() ?? false); var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) || (beatmap?.Metrics?.Fails?.Any() ?? false);
if (hasRatings) bool isOnline = api.State.Value == APIState.Online;
if (hasRatings && isOnline)
{ {
ratings.Metrics = beatmap.BeatmapSet.Metrics; ratings.Metrics = beatmap.BeatmapSet.Metrics;
ratingsContainer.FadeIn(transition_duration); ratingsContainer.FadeIn(transition_duration);
@ -244,7 +245,7 @@ namespace osu.Game.Screens.Select
else else
{ {
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] }; ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] };
ratingsContainer.FadeTo(0.25f, transition_duration); ratingsContainer.FadeTo(isOnline ? 0.25f : 0, transition_duration);
} }
if (hasRetriesFails) if (hasRetriesFails)
@ -259,7 +260,6 @@ namespace osu.Game.Screens.Select
Fails = new int[100], Fails = new int[100],
Retries = new int[100], Retries = new int[100],
}; };
failRetryContainer.FadeOut(transition_duration);
} }
loading.Hide(); loading.Hide();