1
0
mirror of https://github.com/ppy/osu.git synced 2024-05-14 08:21:16 +08:00

Manual fixes to reduce warnings to zero

This commit is contained in:
Dean Herbert 2023-06-24 00:59:36 +09:00
parent 0ab0c52ad5
commit df5b389629
61 changed files with 89 additions and 118 deletions

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
{
protected override Container<Drawable> Content => blueprints ?? base.Content;
private readonly Container blueprints;
private readonly Container? blueprints;
[Cached(typeof(Playfield))]
public Playfield Playfield { get; }

View File

@ -12,7 +12,8 @@ namespace osu.Game.Rulesets.Mania.Tests
{
public abstract partial class ManiaInputTestScene : OsuTestScene
{
private readonly Container<Drawable> content;
private readonly Container<Drawable>? content;
protected override Container<Drawable> Content => content ?? base.Content;
protected ManiaInputTestScene(int keys)

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
{
}
public override HitObjectSelectionBlueprint CreateHitObjectBlueprintFor(HitObject hitObject)
public override HitObjectSelectionBlueprint? CreateHitObjectBlueprintFor(HitObject hitObject)
{
switch (hitObject)
{

View File

@ -82,13 +82,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
/// </summary>
public double HitWindowGreat { get; private set; }
private readonly OsuHitObject lastLastObject;
private readonly OsuHitObject? lastLastObject;
private readonly OsuHitObject lastObject;
public OsuDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, List<DifficultyHitObject> objects, int index)
public OsuDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject? lastLastObject, double clockRate, List<DifficultyHitObject> objects, int index)
: base(hitObject, lastObject, clockRate, objects, index)
{
this.lastLastObject = (OsuHitObject)lastLastObject;
this.lastLastObject = lastLastObject as OsuHitObject;
this.lastObject = (OsuHitObject)lastObject;
// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Edit
protected override SelectionHandler<HitObject> CreateSelectionHandler() => new OsuSelectionHandler();
public override HitObjectSelectionBlueprint CreateHitObjectBlueprintFor(HitObject hitObject)
public override HitObjectSelectionBlueprint? CreateHitObjectBlueprintFor(HitObject hitObject)
{
switch (hitObject)
{

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@ -11,9 +10,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
public abstract partial class DrawableStrongNestedHit : DrawableTaikoHitObject
{
public new DrawableTaikoHitObject ParentHitObject => (DrawableTaikoHitObject)base.ParentHitObject;
public new DrawableTaikoHitObject? ParentHitObject => base.ParentHitObject as DrawableTaikoHitObject;
protected DrawableStrongNestedHit([CanBeNull] StrongNestedHitObject nestedHit)
protected DrawableStrongNestedHit(StrongNestedHitObject? nestedHit)
: base(nestedHit)
{
}

View File

@ -358,7 +358,7 @@ namespace osu.Game.Tests.Visual.Editing
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().SingleOrDefault();
var textBox = popover?.ChildrenOfType<OsuTextBox>().First();
return textBox?.Current.Value == bank && string.IsNullOrEmpty(textBox?.PlaceholderText.ToString());
return textBox?.Current.Value == bank && string.IsNullOrEmpty(textBox.PlaceholderText.ToString());
});
private void samplePopoverHasIndeterminateBank() => AddUntilStep("sample popover has indeterminate bank", () =>

View File

@ -15,7 +15,7 @@ namespace osu.Game.Tournament.Tests.Screens
{
AddStep("set up match", () =>
{
var match = Ladder.CurrentMatch.Value;
var match = Ladder.CurrentMatch.Value!;
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
match.Completed.Value = true;

View File

@ -10,7 +10,7 @@ namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamTitleWithHeader : CompositeDrawable
{
public DrawableTeamTitleWithHeader(TournamentTeam team, TeamColour colour)
public DrawableTeamTitleWithHeader(TournamentTeam? team, TeamColour colour)
{
AutoSizeAxes = Axes.Both;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamWithPlayers : CompositeDrawable
{
public DrawableTeamWithPlayers(TournamentTeam team, TeamColour colour)
public DrawableTeamWithPlayers(TournamentTeam? team, TeamColour colour)
{
AutoSizeAxes = Axes.Both;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Tournament.Models
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
[JsonIgnore] // updated manually in TournamentGameBase
public Bindable<TournamentMatch> CurrentMatch = new Bindable<TournamentMatch>();
public Bindable<TournamentMatch?> CurrentMatch = new Bindable<TournamentMatch?>();
public Bindable<int> ChromaKeyWidth = new BindableInt(1024)
{

View File

@ -10,7 +10,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
{
public partial class MatchRoundDisplay : TournamentSpriteTextWithBackground
{
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();
[BackgroundDependencyLoader]
private void load(LadderInfo ladder)
@ -19,7 +19,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
currentMatch.BindTo(ladder.CurrentMatch);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match) =>
private void matchChanged(ValueChangedEvent<TournamentMatch?> match) =>
Text.Text = match.NewValue?.Round.Value?.Name.Value ?? "Unknown Round";
}
}

View File

@ -15,12 +15,12 @@ namespace osu.Game.Beatmaps
/// Points of failure on a relative time scale (usually 0..100).
/// </summary>
[JsonProperty(@"fail")]
public int[] Fails { get; set; } = Array.Empty<int>();
public int[]? Fails { get; set; } = Array.Empty<int>();
/// <summary>
/// Points of retry on a relative time scale (usually 0..100).
/// </summary>
[JsonProperty(@"exit")]
public int[] Retries { get; set; } = Array.Empty<int>();
public int[]? Retries { get; set; } = Array.Empty<int>();
}
}

View File

@ -50,7 +50,7 @@ namespace osu.Game.Beatmaps.Drawables
return drawable;
}
private Drawable getDrawableForModel(IBeatmapInfo model)
private Drawable getDrawableForModel(IBeatmapInfo? model)
{
// prefer online cover where available.
if (model?.BeatmapSet is IBeatmapSetOnlineInfo online)

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Lists;
using osu.Game.Beatmaps.ControlPoints;
@ -24,7 +23,6 @@ namespace osu.Game.Beatmaps.Legacy
/// </summary>
/// <param name="time">The time to find the sound control point at.</param>
/// <returns>The sound control point.</returns>
[NotNull]
public SampleControlPoint SamplePointAt(double time) => BinarySearchWithFallback(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : SampleControlPoint.DEFAULT);
/// <summary>
@ -40,7 +38,6 @@ namespace osu.Game.Beatmaps.Legacy
/// </summary>
/// <param name="time">The time to find the difficulty control point at.</param>
/// <returns>The difficulty control point.</returns>
[NotNull]
public DifficultyControlPoint DifficultyPointAt(double time) => BinarySearchWithFallback(DifficultyPoints, time, DifficultyControlPoint.DEFAULT);
public override void Clear()

View File

@ -257,7 +257,7 @@ namespace osu.Game.Configuration
string skinName = string.Empty;
if (Guid.TryParse(skin, out var id))
skinName = LookupSkinName(id) ?? string.Empty;
skinName = LookupSkinName(id);
return new SettingDescription(
rawValue: skinName,

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using JetBrains.Annotations;
namespace osu.Game.Database
{
@ -13,7 +12,6 @@ namespace osu.Game.Database
public interface IHasFiles<TFile>
where TFile : INamedFileInfo
{
[NotNull]
List<TFile> Files { get; }
string Hash { get; set; }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Backgrounds
[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{
Sprite.Texture = Beatmap?.GetBackground() ?? textures.Get(fallbackTextureName);
Sprite.Texture = Beatmap.GetBackground() ?? textures.Get(fallbackTextureName);
}
public override bool Equals(Background other)

View File

@ -23,7 +23,7 @@ namespace osu.Game.Graphics
RemovePart(textPart);
}
public void AddErrors(string[] errors)
public void AddErrors(string[]? errors)
{
ClearErrors();

View File

@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface
private const float hover_duration = 500;
private const float click_duration = 200;
public event Action<SelectionState> StateChanged;
public event Action<SelectionState>? StateChanged;
private SelectionState state;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -24,7 +23,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
protected override SaturationValueSelector CreateSaturationValueSelector() => new OsuSaturationValueSelector();
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] OverlayColourProvider colourProvider, OsuColour osuColour)
private void load(OverlayColourProvider? colourProvider, OsuColour osuColour)
{
Background.Colour = colourProvider?.Dark5 ?? osuColour.GreySeaFoamDark;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -21,7 +20,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] OverlayColourProvider overlayColourProvider, OsuColour osuColour)
private void load(OverlayColourProvider? overlayColourProvider, OsuColour osuColour)
{
Background.Colour = overlayColourProvider?.Dark6 ?? osuColour.GreySeaFoamDarker;
}

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
@ -39,7 +38,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] OverlayColourProvider colourProvider, OsuColour colours)
private void load(OverlayColourProvider? colourProvider, OsuColour colours)
{
Background.Colour = Arrow.Colour = colourProvider?.Background4 ?? colours.GreySeaFoamDarker;
}

View File

@ -3,7 +3,6 @@
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Configuration;
@ -20,13 +19,11 @@ namespace osu.Game.IO
/// <summary>
/// The custom storage path as selected by the user.
/// </summary>
[CanBeNull]
public string CustomStoragePath => storageConfig.Get<string>(StorageConfig.FullPath);
public string? CustomStoragePath => storageConfig.Get<string>(StorageConfig.FullPath);
/// <summary>
/// The default storage path to be used if a custom storage path hasn't been selected or is not accessible.
/// </summary>
[NotNull]
public string DefaultStoragePath => defaultStorage.GetFullPath(".");
private readonly GameHost host;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -64,7 +63,6 @@ namespace osu.Game.Overlays.BeatmapListing
Current = filterWithValue.Current;
}
[NotNull]
protected virtual Drawable CreateFilter() => new BeatmapSearchFilter();
protected partial class BeatmapSearchFilter : TabControl<T>

View File

@ -3,6 +3,7 @@
#nullable disable
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -24,6 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private readonly BindableBool playing = new BindableBool();
[CanBeNull]
public PreviewTrack Preview { get; private set; }
private APIBeatmapSet beatmapSet;

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private readonly Box background, progress;
private readonly PlayButton playButton;
private PreviewTrack preview => playButton.Preview;
private PreviewTrack? preview => playButton.Preview;
public IBindable<bool> Playing => playButton.Playing;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Changelog
{
public partial class ChangelogListing : ChangelogContent
{
private readonly List<APIChangelogBuild> entries;
private readonly List<APIChangelogBuild>? entries;
public ChangelogListing(List<APIChangelogBuild> entries)
{

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -81,7 +80,6 @@ namespace osu.Game.Overlays
Waves.FourthWaveColour = ColourProvider.Dark3;
}
[NotNull]
protected abstract T CreateHeader();
public override void Show()

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -96,10 +95,8 @@ namespace osu.Game.Overlays
titleBackground.Colour = colourProvider.Dark5;
}
[NotNull]
protected virtual Drawable CreateContent() => Empty();
[NotNull]
protected virtual Drawable CreateBackground() => Empty();
protected abstract OverlayTitle CreateTitle();

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -71,7 +70,6 @@ namespace osu.Game.Overlays
scrollbarBackground.Colour = colourProvider.Background3;
}
[NotNull]
protected virtual Drawable CreateContent() => Empty();
private partial class SidebarScrollContainer : OsuScrollContainer

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
protected override LocalisableString Header => DebugSettingsStrings.GeneralHeader;
[BackgroundDependencyLoader(true)]
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig, IPerformFromScreenRunner performer)
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig, IPerformFromScreenRunner? performer)
{
Children = new Drawable[]
{

View File

@ -5,6 +5,7 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Logging;
@ -56,7 +57,7 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{
try
{
var token = realm.BlockAllOperations("maintenance");
IDisposable? token = realm.BlockAllOperations("maintenance");
blockAction.Enabled.Value = false;
@ -73,10 +74,10 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
void unblock()
{
if (token == null)
if (token.IsNull())
return;
token?.Dispose();
token.Dispose();
token = null;
Scheduler.Add(() =>

View File

@ -2,19 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.Settings.Sections.Input
{
public partial class RulesetBindingsSection : SettingsSection
{
public override Drawable CreateIcon() => ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon
{
Icon = OsuIcon.Hot
};
public override Drawable CreateIcon() => ruleset.CreateInstance().CreateIcon();
public override LocalisableString Header => ruleset.Name;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
protected override bool IsValidDirectory(DirectoryInfo info) => info?.GetFiles("osu!.*.cfg").Any() ?? false;
protected override bool IsValidDirectory(DirectoryInfo? info) => info?.GetFiles("osu!.*.cfg").Any() ?? false;
public override LocalisableString HeaderText => "Please select your osu!stable install location";

View File

@ -92,8 +92,8 @@ namespace osu.Game.Overlays.Settings
Height = 20;
}
[BackgroundDependencyLoader(true)]
private void load(ChangelogOverlay changelog)
[BackgroundDependencyLoader]
private void load(ChangelogOverlay? changelog)
{
Action = () => changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
@ -83,13 +82,11 @@ namespace osu.Game.Overlays
controlBackground.Colour = colourProvider.Dark4;
}
[NotNull]
protected virtual OsuTabControl<T> CreateTabControl() => new OverlayHeaderTabControl();
/// <summary>
/// Creates a <see cref="Drawable"/> on the opposite side of the <see cref="OsuTabControl{T}"/>. Used mostly to create <see cref="OverlayRulesetSelector"/>.
/// </summary>
[NotNull]
protected virtual Drawable CreateTabControlContent() => Empty();
public partial class OverlayHeaderTabControl : OverlayTabControl<T>

View File

@ -41,8 +41,7 @@ namespace osu.Game.Overlays.Toolbar
{
StateContainer = notificationOverlay as NotificationOverlay;
if (notificationOverlay != null)
NotificationCount.BindTo(notificationOverlay.UnreadCount);
NotificationCount.BindTo(notificationOverlay.UnreadCount);
NotificationCount.ValueChanged += count =>
{

View File

@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Edit.Checks
{
protected override CheckCategory Category => CheckCategory.Audio;
protected override string TypeOfFile => "audio";
protected override string? GetFilename(IBeatmap beatmap) => beatmap.Metadata?.AudioFile;
protected override string GetFilename(IBeatmap beatmap) => beatmap.Metadata.AudioFile;
}
}

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Edit.Checks
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
{
string? audioFile = context.Beatmap.Metadata?.AudioFile;
string audioFile = context.Beatmap.Metadata.AudioFile;
if (string.IsNullOrEmpty(audioFile))
yield break;

View File

@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Edit.Checks
{
protected override CheckCategory Category => CheckCategory.Resources;
protected override string TypeOfFile => "background";
protected override string? GetFilename(IBeatmap beatmap) => beatmap.Metadata?.BackgroundFile;
protected override string GetFilename(IBeatmap beatmap) => beatmap.Metadata.BackgroundFile;
}
}

View File

@ -33,8 +33,8 @@ namespace osu.Game.Rulesets.Edit.Checks
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
{
string? backgroundFile = context.Beatmap.Metadata?.BackgroundFile;
if (backgroundFile == null)
string backgroundFile = context.Beatmap.Metadata.BackgroundFile;
if (string.IsNullOrEmpty(backgroundFile))
yield break;
var texture = context.WorkingBeatmap.GetBackground();

View File

@ -3,6 +3,7 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mods;
@ -92,7 +93,7 @@ namespace osu.Game.Rulesets.Edit
{
base.Dispose(isDisposing);
if (beatmap != null)
if (beatmap.IsNotNull())
{
beatmap.HitObjectAdded -= addHitObject;
beatmap.HitObjectRemoved -= removeHitObject;

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
@ -22,13 +21,11 @@ namespace osu.Game.Rulesets.Judgements
/// <summary>
/// The <see cref="HitObject"/> which was judged.
/// </summary>
[NotNull]
public readonly HitObject HitObject;
/// <summary>
/// The <see cref="Judgement"/> which this <see cref="JudgementResult"/> applies for.
/// </summary>
[NotNull]
public readonly Judgement Judgement;
/// <summary>
@ -97,7 +94,7 @@ namespace osu.Game.Rulesets.Judgements
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> which was judged.</param>
/// <param name="judgement">The <see cref="Judgement"/> to refer to for scoring information.</param>
public JudgementResult([NotNull] HitObject hitObject, [NotNull] Judgement judgement)
public JudgementResult(HitObject hitObject, Judgement judgement)
{
HitObject = hitObject;
Judgement = judgement;

View File

@ -5,6 +5,6 @@ namespace osu.Game.Rulesets.Objects
{
public abstract class HitObjectParser
{
public abstract HitObject Parse(string text);
public abstract HitObject? Parse(string text);
}
}

View File

@ -44,7 +44,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
FormatVersion = formatVersion;
}
[CanBeNull]
public override HitObject Parse(string text)
{
string[] split = text.Split(',');

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
@ -15,7 +14,6 @@ namespace osu.Game.Rulesets.UI
/// <param name="hitObject">The <see cref="HitObject"/> to retrieve the <see cref="DrawableHitObject"/> representation of.</param>
/// <param name="parent">The parenting <see cref="DrawableHitObject"/>, if any.</param>
/// <returns>The <see cref="DrawableHitObject"/> representing <see cref="HitObject"/>, or <c>null</c> if no poolable representation exists.</returns>
[CanBeNull]
DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject, [CanBeNull] DrawableHitObject parent);
DrawableHitObject? GetPooledDrawableRepresentation(HitObject hitObject, DrawableHitObject? parent);
}
}

View File

@ -126,19 +126,16 @@ namespace osu.Game.Scoring.Legacy
// As this is baked into hitobject timing (see `LegacyBeatmapDecoder`) we also need to apply this to replay frame timing.
double offset = beatmap?.BeatmapInfo.BeatmapVersion < 5 ? -LegacyBeatmapDecoder.EARLY_VERSION_TIMING_OFFSET : 0;
if (score.Replay != null)
int lastTime = 0;
foreach (var f in score.Replay.Frames)
{
int lastTime = 0;
var legacyFrame = getLegacyFrame(f);
foreach (var f in score.Replay.Frames)
{
var legacyFrame = getLegacyFrame(f);
// Rounding because stable could only parse integral values
int time = (int)Math.Round(legacyFrame.Time + offset);
replayData.Append(FormattableString.Invariant($"{time - lastTime}|{legacyFrame.MouseX ?? 0}|{legacyFrame.MouseY ?? 0}|{(int)legacyFrame.ButtonState},"));
lastTime = time;
}
// Rounding because stable could only parse integral values
int time = (int)Math.Round(legacyFrame.Time + offset);
replayData.Append(FormattableString.Invariant($"{time - lastTime}|{legacyFrame.MouseX ?? 0}|{legacyFrame.MouseY ?? 0}|{(int)legacyFrame.ButtonState},"));
lastTime = time;
}
// Warning: this is purposefully hardcoded as a string rather than interpolating, as in some cultures the minus sign is not encoded as the standard ASCII U+00C2 codepoint,

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens
/// </summary>
/// <param name="screen">The screen to attempt to push.</param>
/// <returns>Whether the push succeeded. For example, if the existing screen was already of the correct type this will return <c>false</c>.</returns>
public bool Push(BackgroundScreen screen)
public bool Push(BackgroundScreen? screen)
{
if (screen == null)
return false;

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Edit;
@ -67,7 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
base.Dispose(isDisposing);
if (editorBeatmap != null)
if (editorBeatmap.IsNotNull())
editorBeatmap.BeatmapReprocessed -= SortInternal;
}
}

View File

@ -3,6 +3,7 @@
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Online.Multiplayer;
@ -93,7 +94,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
base.Dispose(isDisposing);
if (client != null)
if (client.IsNotNull())
client.RoomUpdated -= onRoomUpdated;
}
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Game.Scoring;
using osu.Game.Screens.Menu;
@ -15,7 +14,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
public partial class MultiSpectatorPlayerLoader : SpectatorPlayerLoader
{
public MultiSpectatorPlayerLoader([NotNull] Score score, [NotNull] Func<MultiSpectatorPlayer> createPlayer)
public MultiSpectatorPlayerLoader(Score score, Func<MultiSpectatorPlayer> createPlayer)
: base(score, createPlayer)
{
}

View File

@ -1,18 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using osu.Framework.Screens;
namespace osu.Game.Screens.OnlinePlay
{
public partial class OnlinePlaySubScreenStack : OsuScreenStack
{
protected override void ScreenChanged(IScreen prev, IScreen next)
protected override void ScreenChanged(IScreen prev, IScreen? next)
{
base.ScreenChanged(prev, next);
// because this is a screen stack within a screen stack, let's manually handle disabled changes to simplify things.
var osuScreen = ((OsuScreen)next);
var osuScreen = next as OsuScreen;
Debug.Assert(osuScreen != null);
bool disallowChanges = osuScreen.DisallowExternalBeatmapRulesetChanges;

View File

@ -52,12 +52,12 @@ namespace osu.Game.Screens
ScreenChanged(prev, next);
}
protected virtual void ScreenChanged(IScreen prev, IScreen next)
protected virtual void ScreenChanged(IScreen prev, IScreen? next)
{
setParallax(next);
}
private void setParallax(IScreen next) =>
parallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * (((IOsuScreen)next)?.BackgroundParallaxAmount ?? 1.0f);
private void setParallax(IScreen? next) =>
parallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * ((next as IOsuScreen)?.BackgroundParallaxAmount ?? 1.0f);
}
}

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
@ -59,7 +60,7 @@ namespace osu.Game.Screens.Play.HUD
{
base.Dispose(isDisposing);
if (HealthProcessor != null)
if (HealthProcessor.IsNotNull())
HealthProcessor.NewJudgement -= onNewJudgement;
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Play.HUD
public ExpansionMode ExpansionMode = ExpansionMode.ExpandOnHover;
private readonly BindableWithCurrent<IReadOnlyList<Mod>> current = new BindableWithCurrent<IReadOnlyList<Mod>>();
private readonly BindableWithCurrent<IReadOnlyList<Mod>> current = new BindableWithCurrent<IReadOnlyList<Mod>>(Array.Empty<Mod>());
public Bindable<IReadOnlyList<Mod>> Current
{
@ -63,8 +63,6 @@ namespace osu.Game.Screens.Play.HUD
{
iconsContainer.Clear();
if (mods.NewValue == null) return;
foreach (Mod mod in mods.NewValue)
iconsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.6f) });

View File

@ -4,6 +4,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -75,10 +76,11 @@ namespace osu.Game.Screens.Play.HUD
{
base.Dispose(isDisposing);
if (scoreProcessor == null) return;
scoreProcessor.NewJudgement -= updateDisplay;
scoreProcessor.JudgementReverted -= updateDisplay;
if (scoreProcessor.IsNotNull())
{
scoreProcessor.NewJudgement -= updateDisplay;
scoreProcessor.JudgementReverted -= updateDisplay;
}
}
private partial class TextComponent : CompositeDrawable, IHasText

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Screens;
using osu.Game.Online.Spectator;
using osu.Game.Scoring;
@ -40,7 +41,7 @@ namespace osu.Game.Screens.Play
{
base.Dispose(isDisposing);
if (spectatorClient != null)
if (spectatorClient.IsNotNull())
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics.CodeAnalysis;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -22,7 +21,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// Creates a new <see cref="StatisticContainer"/>.
/// </summary>
/// <param name="item">The <see cref="StatisticItem"/> to display.</param>
public StatisticContainer([NotNull] StatisticItem item)
public StatisticContainer(StatisticItem item)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
@ -34,7 +33,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// <param name="name">The name of the item. Can be <see langword="null"/> to hide the item header.</param>
/// <param name="createContent">A function returning the <see cref="Drawable"/> content to be displayed.</param>
/// <param name="requiresHitEvents">Whether this item requires hit events. If true, <see cref="CreateContent"/> will not be called if no hit events are available.</param>
public StatisticItem(LocalisableString name, [NotNull] Func<Drawable> createContent, bool requiresHitEvents = false)
public StatisticItem(LocalisableString name, Func<Drawable> createContent, bool requiresHitEvents = false)
{
Name = name;
RequiresHitEvents = requiresHitEvents;

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
@ -106,7 +107,7 @@ namespace osu.Game.Storyboards.Drawables
{
base.Dispose(isDisposing);
if (skin != null)
if (skin.IsNotNull())
skin.SourceChanged -= skinSourceChanged;
}
}