mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Resolve new nullability warnings
This commit is contained in:
parent
dd045f851f
commit
938428d264
@ -37,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private partial class ToggleTextContainer : TextContainer
|
||||
{
|
||||
private readonly StatefulMenuItem menuItem;
|
||||
private readonly Bindable<object> state;
|
||||
private readonly Bindable<object?> state;
|
||||
private readonly SpriteIcon stateIcon;
|
||||
|
||||
public ToggleTextContainer(StatefulMenuItem menuItem)
|
||||
@ -61,7 +61,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
state.BindValueChanged(updateState, true);
|
||||
}
|
||||
|
||||
private void updateState(ValueChangedEvent<object> state)
|
||||
private void updateState(ValueChangedEvent<object?> state)
|
||||
{
|
||||
var icon = menuItem.GetIconForState(state.NewValue);
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
/// <param name="state">The state to retrieve the relevant icon for.</param>
|
||||
/// <returns>The icon to be displayed for <paramref name="state"/>.</returns>
|
||||
public abstract IconUsage? GetIconForState(object state);
|
||||
public abstract IconUsage? GetIconForState(object? state);
|
||||
}
|
||||
|
||||
public abstract class StatefulMenuItem<T> : StatefulMenuItem
|
||||
@ -97,7 +97,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
State.BindValueChanged(state => base.State.Value = state.NewValue);
|
||||
}
|
||||
|
||||
public sealed override IconUsage? GetIconForState(object state) => GetIconForState((T)state);
|
||||
public sealed override IconUsage? GetIconForState(object? state) => GetIconForState((T)state!);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the icon to be displayed for a state.
|
||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
syncingColours = true;
|
||||
|
||||
comboColours.Colours.Clear();
|
||||
comboColours.Colours.AddRange(Beatmap.BeatmapSkin?.ComboColours);
|
||||
comboColours.Colours.AddRange(Beatmap.BeatmapSkin?.ComboColours ?? []);
|
||||
|
||||
syncingColours = false;
|
||||
});
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -38,6 +39,10 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
|
||||
// Roslyn sees required non-nullable property as nullable in constructor,
|
||||
// as it can't see the implementation provides a fallback.
|
||||
Debug.Assert(SelectedItem != null);
|
||||
|
||||
base.SelectedItem.BindTo(SelectedItem);
|
||||
}
|
||||
|
||||
|
@ -994,7 +994,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
selectedMods.BindValueChanged(_ =>
|
||||
{
|
||||
if (decoupledRuleset.Value.Equals(rulesetNoDebounce))
|
||||
if (decoupledRuleset.Value?.Equals(rulesetNoDebounce) ?? false)
|
||||
advancedStats.Mods.Value = selectedMods.Value;
|
||||
}, true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user