Enable nullability for editor components

This commit is contained in:
ansel
2023-01-12 18:07:54 +03:00
parent b3d4da8fc9
commit 2365b065a4
24 changed files with 27 additions and 72 deletions

View File

@ -1,8 +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.
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@ -24,7 +22,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// <summary>
/// Invoked when this <see cref="EditorRadioButton"/> has been selected.
/// </summary>
public Action<RadioButton> Selected;
public Action<RadioButton>? Selected;
public readonly RadioButton Button;
@ -33,10 +31,10 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
private Color4 selectedBackgroundColour;
private Color4 selectedIconColour;
private Drawable icon;
private Drawable icon = null!;
[Resolved(canBeNull: true)]
private EditorBeatmap editorBeatmap { get; set; }
[Resolved]
private EditorBeatmap? editorBeatmap { get; set; }
public EditorRadioButton(RadioButton button)
{

View File

@ -1,8 +1,7 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
@ -13,7 +12,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
{
public partial class EditorRadioButtonCollection : CompositeDrawable
{
private IReadOnlyList<RadioButton> items;
private IReadOnlyList<RadioButton> items = Array.Empty<RadioButton>();
public IReadOnlyList<RadioButton> Items
{
@ -45,7 +44,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
};
}
private RadioButton currentlySelected;
private RadioButton? currentlySelected;
private void addButton(RadioButton button)
{

View File

@ -1,8 +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.
#nullable disable
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -24,11 +22,11 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// <summary>
/// A function which creates a drawable icon to represent this item. If null, a sane default should be used.
/// </summary>
public readonly Func<Drawable> CreateIcon;
public readonly Func<Drawable>? CreateIcon;
private readonly Action action;
private readonly Action? action;
public RadioButton(string label, Action action, Func<Drawable> createIcon = null)
public RadioButton(string label, Action? action, Func<Drawable>? createIcon = null)
{
Label = label;
CreateIcon = createIcon;