1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 19:07:45 +08:00

Enable nullable and switch classes to structs

This commit is contained in:
Dean Herbert 2021-10-21 18:53:49 +09:00
parent 12620fcf78
commit 69e7810dad
10 changed files with 17 additions and 15 deletions

View File

@ -5,7 +5,7 @@ using Newtonsoft.Json;
namespace osu.Game.Beatmaps
{
public class BeatmapSetOnlineAvailability
public struct BeatmapSetOnlineAvailability
{
[JsonProperty(@"download_disabled")]
public bool DownloadDisabled { get; set; }

View File

@ -3,7 +3,7 @@
namespace osu.Game.Beatmaps
{
public class BeatmapSetOnlineGenre
public struct BeatmapSetOnlineGenre
{
public int Id { get; set; }
public string Name { get; set; }

View File

@ -3,7 +3,7 @@
namespace osu.Game.Beatmaps
{
public class BeatmapSetOnlineLanguage
public struct BeatmapSetOnlineLanguage
{
public int Id { get; set; }
public string Name { get; set; }

View File

@ -3,6 +3,8 @@
using System;
#nullable enable
namespace osu.Game.Beatmaps
{
/// <summary>
@ -48,7 +50,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// The different sizes of cover art for this beatmap set.
/// </summary>
BeatmapSetOnlineCovers Covers { get; set; }
BeatmapSetOnlineCovers? Covers { get; set; }
/// <summary>
/// A small sample clip of this beatmap set's song.

View File

@ -92,7 +92,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
break;
default:
if (BeatmapSet.Value?.OnlineInfo?.Availability?.DownloadDisabled ?? false)
if (BeatmapSet.Value?.OnlineInfo?.Availability.DownloadDisabled ?? false)
{
button.Enabled.Value = false;
button.TooltipText = "this beatmap is currently not available for download.";

View File

@ -16,8 +16,8 @@ namespace osu.Game.Overlays.BeatmapSet
{
private BeatmapSetInfo beatmapSet;
private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false;
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability?.ExternalLink);
private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability.DownloadDisabled ?? false;
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability.ExternalLink);
private readonly LinkFlowContainer textContainer;

View File

@ -266,7 +266,7 @@ namespace osu.Game.Overlays.BeatmapSet
{
if (BeatmapSet.Value == null) return;
if ((BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) && State.Value != DownloadState.LocallyAvailable)
if (BeatmapSet.Value.OnlineInfo.Availability.DownloadDisabled && State.Value != DownloadState.LocallyAvailable)
{
downloadButtonsContainer.Clear();
return;

View File

@ -117,8 +117,8 @@ namespace osu.Game.Overlays.BeatmapSet
{
source.Text = b.NewValue?.Metadata.Source ?? string.Empty;
tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty;
genre.Text = b.NewValue?.OnlineInfo?.Genre?.Name ?? string.Empty;
language.Text = b.NewValue?.OnlineInfo?.Language?.Name ?? string.Empty;
genre.Text = b.NewValue?.OnlineInfo?.Genre.Name ?? string.Empty;
language.Text = b.NewValue?.OnlineInfo?.Language.Name ?? string.Empty;
var setHasLeaderboard = b.NewValue?.OnlineInfo?.Status > 0;
successRate.Alpha = setHasLeaderboard ? 1 : 0;
notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1;

View File

@ -60,12 +60,12 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => !model.OnlineBeatmapSetID.HasValue
? null
: new GridBeatmapPanel(model.ToBeatmapSet(Rulesets))
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0
? new GridBeatmapPanel(model.ToBeatmapSet(Rulesets))
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
};
}
: null;
}
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
Texture? texture = null;
// prefer online cover where available.
if (BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers.Cover != null)
if (BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers?.Cover != null)
texture = textures.Get(BeatmapInfo.BeatmapSet.OnlineInfo.Covers.Cover);
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;