Skip to content

Commit

Permalink
Merge pull request #1989 from andy840119/remove-the-nullable-disable-…
Browse files Browse the repository at this point in the history
…annotation-in-the-editor

Remove the nullable disable annotation in the editor.
  • Loading branch information
andy840119 authored May 8, 2023
2 parents df31f63 + 8e2be88 commit 579225e
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void load()
{
Items = new MenuItem[]
{
new KaraokeSkinEditorMenu(null, null, "Skin editor"),
new KaraokeSkinEditorMenu(null!, null!, "Skin editor"),
}
},
}
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.Reflection;
using osu.Framework.Allocation;
Expand All @@ -18,12 +16,12 @@ namespace osu.Game.Rulesets.Karaoke.Beatmaps;
public partial class KaraokeBeatmapResourcesProvider : Component, IKaraokeBeatmapResourcesProvider
{
[Resolved]
private BeatmapManager beatmapManager { get; set; }
private BeatmapManager beatmapManager { get; set; } = null!;

[Resolved]
private IBindable<WorkingBeatmap> working { get; set; }
private IBindable<WorkingBeatmap> working { get; set; } = null!;

public Texture GetSingerAvatar(ISinger singer)
public Texture? GetSingerAvatar(ISinger singer)
{
var provider = getBeatmapResourceProvider();
if (provider == null)
Expand All @@ -36,11 +34,11 @@ public Texture GetSingerAvatar(ISinger singer)
if (beatmapSetInfo == null)
return null;

string path = beatmapSetInfo.GetPathForFile($"assets/singers/{s.AvatarFile}");
string? path = beatmapSetInfo.GetPathForFile($"assets/singers/{s.AvatarFile}");
return provider.LargeTextureStore.Get(path);
}

private IBeatmapResourceProvider getBeatmapResourceProvider()
private IBeatmapResourceProvider? getBeatmapResourceProvider()
{
// todo : use better way to get the resource provider.
var prop = typeof(BeatmapManager).GetField("workingBeatmapCache", BindingFlags.Instance | BindingFlags.NonPublic);
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.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Karaoke.Objects;
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.Game.Rulesets.Karaoke.Objects;

namespace osu.Game.Rulesets.Karaoke.Edit.Blueprints.Lyrics;
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.Graphics;
using osu.Framework.Graphics.Containers;
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.Extensions;
using osu.Framework.Graphics;
Expand All @@ -25,22 +23,22 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Blueprints.Notes;
public partial class NoteSelectionBlueprint : KaraokeSelectionBlueprint<Note>, IHasPopover
{
[Resolved]
private INotesChangeHandler notesChangeHandler { get; set; }
private INotesChangeHandler notesChangeHandler { get; set; } = null!;

[Resolved]
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; }
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; } = null!;

[Resolved]
private Playfield playfield { get; set; }
private Playfield playfield { get; set; } = null!;

[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
private IScrollingInfo scrollingInfo { get; set; } = null!;

[Resolved]
private INotePositionInfo notePositionInfo { get; set; }
private INotePositionInfo notePositionInfo { get; set; } = null!;

[Resolved]
private EditorBeatmap beatmap { get; set; }
private EditorBeatmap beatmap { get; set; } = null!;

protected ScrollingHitObjectContainer HitObjectContainer => ((KaraokePlayfield)playfield).NotePlayfield.HitObjectContainer;

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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
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.Linq;
using osu.Game.Graphics.UserInterface;
Expand All @@ -17,7 +15,7 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Components.ContextMenu;

public class SingerContextMenu : OsuMenuItem
{
public SingerContextMenu(EditorBeatmap beatmap, ILyricSingerChangeHandler lyricSingerChangeHandler, string name, Action postProcess = null)
public SingerContextMenu(EditorBeatmap beatmap, ILyricSingerChangeHandler lyricSingerChangeHandler, string name, Action? postProcess = null)
: base(name)
{
var lyrics = beatmap.SelectedHitObjects.OfType<Lyric>().ToArray();
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.Game.Rulesets.Karaoke.Edit.Components.Sprites;
using osu.Game.Rulesets.Karaoke.Graphics.Cursor;
Expand All @@ -19,8 +17,8 @@ public partial class LayoutToolTip : BackgroundToolTip<Lyric>

private readonly DrawableLayoutPreview preview;

[Resolved(canBeNull: true)]
private ISkinSource skinSource { get; set; }
[Resolved]
private ISkinSource? skinSource { get; set; }

public LayoutToolTip()
{
Expand All @@ -30,7 +28,7 @@ public LayoutToolTip()
};
}

private Lyric lastLyric;
private Lyric? lastLyric;

public override void SetContent(Lyric lyric)
{
Expand All @@ -40,7 +38,7 @@ public override void SetContent(Lyric lyric)
lastLyric = lyric;

// Get layout
var layout = skinSource?.GetConfig<Lyric, LyricLayout>(lyric).Value;
var layout = skinSource?.GetConfig<Lyric, LyricLayout>(lyric)?.Value;

// Display in content
preview.Layout = layout;
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.Graphics;
using osu.Framework.Graphics.Containers;
Expand All @@ -20,7 +18,7 @@ public partial class TimeTagTooltip : BackgroundToolTip<TimeTag>
{
private const int time_display_height = 25;

private Box background;
private Box background = null!;
private readonly OsuSpriteText trackTimer;
private readonly OsuSpriteText index;
private readonly OsuSpriteText indexState;
Expand Down Expand Up @@ -84,7 +82,7 @@ protected override Drawable SetBackground()
};
}

private TimeTag lastTimeTag;
private TimeTag? lastTimeTag;

public override void SetContent(TimeTag timeTag)
{
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.Graphics.UserInterface;
using osu.Framework.Screens;
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps;
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.Graphics.UserInterface;
using osu.Framework.Screens;
using osu.Game.Rulesets.Karaoke.Screens.Skin;
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.Bindables;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
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.Extensions.EnumExtensions;
using osu.Framework.Graphics;
Expand All @@ -24,8 +22,8 @@ public partial class DrawableLayoutPreview : CompositeDrawable
private readonly Box previewLyric;
private readonly OsuSpriteText notSupportText;

[Resolved(canBeNull: true)]
private ISkinSource skinSource { get; set; }
[Resolved]
private ISkinSource? skinSource { get; set; }

public DrawableLayoutPreview()
{
Expand All @@ -50,9 +48,9 @@ public DrawableLayoutPreview()
notSupportText.Hide();
}

private LyricLayout layout;
private LyricLayout? layout;

public LyricLayout Layout
public LyricLayout? Layout
{
get => layout;
set
Expand All @@ -65,9 +63,9 @@ public LyricLayout Layout
}
}

private Lyric lyric;
private Lyric? lyric;

public Lyric Lyric
public Lyric? Lyric
{
get => lyric;
set
Expand Down Expand Up @@ -104,19 +102,19 @@ private void updateLayout()
previewLyric.Height = text_size * 1.5f * scale;

// Set relative position
previewLyric.Anchor = layout.Alignment;
previewLyric.Origin = layout.Alignment;
previewLyric.Anchor = Layout.Alignment;
previewLyric.Origin = Layout.Alignment;

// Set margin
const float padding = 30 * scale;
float horizontalMargin = layout.HorizontalMargin * scale + padding;
float verticalMargin = layout.VerticalMargin * scale + padding;
float horizontalMargin = Layout.HorizontalMargin * scale + padding;
float verticalMargin = Layout.VerticalMargin * scale + padding;
previewLyric.Margin = new MarginPadding
{
Left = layout.Alignment.HasFlagFast(Anchor.x0) ? horizontalMargin : 0,
Right = layout.Alignment.HasFlagFast(Anchor.x2) ? horizontalMargin : 0,
Top = layout.Alignment.HasFlagFast(Anchor.y0) ? verticalMargin : 0,
Bottom = layout.Alignment.HasFlagFast(Anchor.y2) ? verticalMargin : 0
Left = Layout.Alignment.HasFlagFast(Anchor.x0) ? horizontalMargin : 0,
Right = Layout.Alignment.HasFlagFast(Anchor.x2) ? horizontalMargin : 0,
Top = Layout.Alignment.HasFlagFast(Anchor.y0) ? verticalMargin : 0,
Bottom = Layout.Alignment.HasFlagFast(Anchor.y2) ? verticalMargin : 0
};
}
}
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;
Expand Down Expand Up @@ -42,7 +40,7 @@ public NoteEditPopover(Note note)

private partial class NoteSection : Section
{
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; }
private INotePropertyChangeHandler notePropertyChangeHandler { get; set; } = null!;

protected override LocalisableString Title => "Note property";

Expand Down Expand Up @@ -108,9 +106,6 @@ public NoteSection(Note note)
[BackgroundDependencyLoader(true)]
private void load(HitObjectComposer composer)
{
if (notePropertyChangeHandler != null || composer == null)
return;

// todo: not a good way to get change handler, might remove or found another way eventually.
// cannot get change handler directly in editor screen, so should trying to get from karaoke hit object composer.
notePropertyChangeHandler = composer.Dependencies.Get<INotePropertyChangeHandler>();
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 osu.Framework.Allocation;
using osu.Framework.Bindables;
Expand All @@ -25,7 +23,7 @@ public partial class DrawableKaraokeEditorRuleset : DrawableKaraokeRuleset

protected override bool DisplayNotePlayfield => true;

public DrawableKaraokeEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
public DrawableKaraokeEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
: base(ruleset, beatmap, mods)
{
bindableDisplayRubyToggle.BindValueChanged(x => { Session.SetValue(KaraokeRulesetSession.DisplayRuby, x.NewValue); });
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/EditorNotePlayfield.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 System;
using System.Collections.Generic;
using osu.Framework.Allocation;
Expand Down
6 changes: 2 additions & 4 deletions osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.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 System;
using System.IO;
using System.Linq;
Expand All @@ -22,10 +20,10 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Export;
public partial class ExportLyricManager : Component
{
[Resolved]
private Storage storage { get; set; }
private Storage storage { get; set; } = null!;

[Resolved]
private EditorBeatmap beatmap { get; set; }
private EditorBeatmap beatmap { get; set; } = null!;

public void ExportToLrc()
{
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/KaraokeBlueprintContainer.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 System;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Karaoke.Edit.Blueprints.Lyrics;
Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.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.Game.Rulesets.Karaoke.UI;
using osu.Game.Rulesets.Karaoke.UI.Scrolling;

Expand Down
Loading

0 comments on commit 579225e

Please sign in to comment.