Skip to content

Commit

Permalink
Merge pull request #2064 from andy840119/remove-nullable-disable-anno…
Browse files Browse the repository at this point in the history
…tation-in-the-graphic-namepace

Remove nullable disable annotation in the graphic namespace.
  • Loading branch information
andy840119 authored Jul 13, 2023
2 parents 5eca2d0 + 4c516ac commit 55d24fc
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void TestUpdateTranslateWithNullText()
}
});

TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), ""));
TriggerHandlerChanged(c => c.UpdateTranslate(new CultureInfo(17), string.Empty));

AssertSelectedHitObject(h =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
Expand All @@ -15,14 +13,14 @@ namespace osu.Game.Rulesets.Karaoke.Graphics.Containers;
public partial class MessageContainer : OsuTextFlowContainer
{
[Resolved]
private OsuColour colours { get; set; }
private OsuColour colours { get; set; } = null!;

public MessageContainer(Action<SpriteText> defaultCreationParameters = null)
public MessageContainer(Action<SpriteText>? defaultCreationParameters = null)
: base(defaultCreationParameters)
{
}

public void AddSuccessParagraph(string text, Action<SpriteText> creationParameters = null)
public void AddSuccessParagraph(string text, Action<SpriteText>? creationParameters = null)
{
NewParagraph();
AddIcon(FontAwesome.Solid.Check, icon =>
Expand All @@ -32,7 +30,7 @@ public void AddSuccessParagraph(string text, Action<SpriteText> creationParamete
AddText($" {text}", creationParameters);
}

public void AddWarningParagraph(string text, Action<SpriteText> creationParameters = null)
public void AddWarningParagraph(string text, Action<SpriteText>? creationParameters = null)
{
NewParagraph();
AddIcon(FontAwesome.Solid.ExclamationTriangle, icon =>
Expand All @@ -43,7 +41,7 @@ public void AddWarningParagraph(string text, Action<SpriteText> creationParamete
AddText($" {text}", creationParameters);
}

public void AddAlertParagraph(string text, Action<SpriteText> creationParameters = null)
public void AddAlertParagraph(string text, Action<SpriteText>? creationParameters = null)
{
NewParagraph();
AddIcon(FontAwesome.Solid.TimesCircle, icon =>
Expand All @@ -53,7 +51,7 @@ public void AddAlertParagraph(string text, Action<SpriteText> creationParameters
AddText($" {text}", creationParameters);
}

public void AddHighlightText(string text, Action<SpriteText> creationParameters = null)
public void AddHighlightText(string text, Action<SpriteText>? creationParameters = null)
{
AddText($" {text}", c =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
Expand All @@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Karaoke.Graphics.Containers;

public abstract partial class OrderRearrangeableListContainer<TModel> : OsuRearrangeableListContainer<TModel>
{
public event Action<TModel, int> OnOrderChanged;
public event Action<TModel, int>? OnOrderChanged;

protected abstract Vector2 Spacing { get; }

Expand All @@ -25,13 +25,15 @@ protected OrderRearrangeableListContainer()
Items.CollectionChanged += collectionChanged;
}

private void collectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void collectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
// should get the event if user change the position.
case NotifyCollectionChangedAction.Move:
var item = (TModel)e.NewItems[0];
Debug.Assert(e.NewItems != null);

var item = e.NewItems.OfType<TModel>().First();
int newIndex = e.NewStartingIndex;
OnOrderChanged?.Invoke(item, newIndex);
break;
Expand All @@ -42,7 +44,7 @@ protected override FillFlowContainer<RearrangeableListItem<TModel>> CreateListFi
=> base.CreateListFillFlowContainer().With(x => x.Spacing = Spacing);

private bool displayBottomDrawable;
private Drawable bottomDrawable;
private Drawable? bottomDrawable;

public bool DisplayBottomDrawable
{
Expand Down Expand Up @@ -78,5 +80,5 @@ public bool DisplayBottomDrawable
}
}

protected virtual Drawable CreateBottomDrawable() => null;
protected virtual Drawable? CreateBottomDrawable() => null;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Rulesets.Karaoke/Graphics/Cursor/LyricToolTip.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Graphics.Sprites;
Expand All @@ -12,7 +10,7 @@ namespace osu.Game.Rulesets.Karaoke.Graphics.Cursor;

public partial class LyricTooltip : BackgroundToolTip<Lyric>
{
private Lyric lastLyric;
private Lyric? lastLyric;

public override void SetContent(Lyric lyric)
{
Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
Expand Down Expand Up @@ -134,7 +132,7 @@ public SingerToolTip()
bindableDescription.BindValueChanged(e => singerDescription.Text = string.IsNullOrEmpty(e.NewValue) ? "<No description>" : e.NewValue, true);
}

private ISinger lastSinger;
private ISinger? lastSinger;

public override void SetContent(ISinger singer)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using osu.Game.Overlays.Dialog;

namespace osu.Game.Rulesets.Karaoke.Graphics.Overlays.Dialog;

public partial class OkPopupDialog : PopupDialog
{
public OkPopupDialog(Action<bool> okAction = null)
public OkPopupDialog(Action<bool>? okAction = null)
{
Buttons = new PopupDialogButton[]
{
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Graphics/Shapes/CornerBackground.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas;
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas.Types;
using osu.Game.Rulesets.Karaoke.Beatmaps.Utils;
Expand All @@ -18,19 +16,19 @@ public partial class DrawableCircleSingerAvatar : DrawableSingerAvatar
private readonly IBindable<float> bindableHue = new Bindable<float>();

[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
private void load(OsuColour colour)
{
Masking = true;
CornerRadius = Math.Min(DrawSize.X, DrawSize.Y) / 2f;
BorderThickness = 5;

bindableHue.BindValueChanged(_ =>
{
BorderColour = SingerUtils.GetContentColour(Singer);
BorderColour = Singer != null ? SingerUtils.GetContentColour(Singer) : colour.Gray0;
}, true);
}

public override ISinger Singer
public override ISinger? Singer
{
get => base.Singer;
set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -49,9 +47,9 @@ Texture getDefaultAvatar()
=> textures.Get(@"Online/avatar-guest");
}

private ISinger singer;
private ISinger? singer;

public virtual ISinger Singer
public virtual ISinger? Singer
{
get => singer;
set
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Graphics/Sprites/KaraokeIcon.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
Expand All @@ -28,8 +26,8 @@ public partial class CircleCheckbox : Checkbox, IHasAccentColour, IHasTooltip
private readonly SpriteIcon border;
private readonly SpriteIcon selectedIcon;

private Sample sampleChecked;
private Sample sampleUnchecked;
private Sample? sampleChecked;
private Sample? sampleUnchecked;

/// <summary>
/// Whether to play sounds when the state changes as a result of user interaction.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
Expand Down Expand Up @@ -83,7 +81,7 @@ public MicrophoneSoundVisualizer()
updateDeviceInfo();
}

private string deviceName;
private string deviceName = string.Empty;

public string DeviceName
{
Expand Down Expand Up @@ -169,7 +167,7 @@ internal partial class MicrophoneInfo : CompositeDrawable
private readonly OsuSpriteText deviceName;

[Resolved]
private OsuColour colours { get; set; }
private OsuColour colours { get; set; } = null!;

public MicrophoneInfo()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
Expand All @@ -26,9 +24,9 @@ public partial class RearrangeableTextFlowListContainer<TModel> : OsuRearrangeab
{
public readonly Bindable<TModel> SelectedSet = new();

public Action<TModel> RequestSelection;
public Action<TModel>? RequestSelection;

private SearchContainer<RearrangeableListItem<TModel>> searchContainer;
private SearchContainer<RearrangeableListItem<TModel>> searchContainer = null!;

protected sealed override FillFlowContainer<RearrangeableListItem<TModel>> CreateListFillFlowContainer() => searchContainer = new SearchContainer<RearrangeableListItem<TModel>>
{
Expand Down Expand Up @@ -56,9 +54,9 @@ public partial class DrawableTextListItem : OsuRearrangeableListItem<TModel>, IF
{
public readonly Bindable<TModel> SelectedSet = new();

public Action<TModel> RequestSelection;
public Action<TModel>? RequestSelection;

private TextFlowContainer text;
private TextFlowContainer text = null!;

private Color4 selectedColour;

Expand Down Expand Up @@ -112,11 +110,11 @@ protected override bool OnClick(ClickEvent e)

public virtual IEnumerable<LocalisableString> FilterTerms => new[]
{
new LocalisableString(Model.ToString())
new LocalisableString(Model?.ToString() ?? string.Empty)
};

protected virtual void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, TModel model)
=> textFlowContainer.AddText(model.ToString());
=> textFlowContainer.AddText(model?.ToString() ?? string.Empty);

private bool matchingFilter = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Collections.Generic;
using osu.Framework.Bindables;
Expand Down Expand Up @@ -135,7 +133,7 @@ private partial class DrawableSinger : DrawableCircleSingerAvatar, IHasCustomToo
{
public ITooltip<ISinger> GetCustomTooltip() => new SingerToolTip();

public ISinger TooltipContent => Singer;
public ISinger? TooltipContent => Singer;
}
}

Expand Down
Loading

0 comments on commit 55d24fc

Please sign in to comment.