1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Apply nullability to osu!mania skinning classes

This commit is contained in:
Dean Herbert 2022-11-09 13:37:04 +09:00
parent 82ff142b1b
commit a6165ea78a
19 changed files with 42 additions and 93 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 osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania

View File

@ -1,10 +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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -27,8 +24,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Default
protected readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
protected readonly IBindable<bool> IsHitting = new Bindable<bool>();
protected Drawable Background { get; private set; }
private Container foregroundContainer;
protected Drawable Background { get; private set; } = null!;
private Container foregroundContainer = null!;
public DefaultBodyPiece()
{
@ -36,7 +33,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Default
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] DrawableHitObject drawableObject)
private void load(DrawableHitObject? drawableObject)
{
InternalChildren = new[]
{
@ -74,9 +71,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Default
private readonly LayoutValue subtractionCache = new LayoutValue(Invalidation.DrawSize);
private BufferedContainer foregroundBuffer;
private BufferedContainer subtractionBuffer;
private Container subtractionLayer;
private BufferedContainer foregroundBuffer = null!;
private BufferedContainer subtractionBuffer = null!;
private Container subtractionLayer = null!;
public ForegroundPiece()
{

View File

@ -1,9 +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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -53,7 +50,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Default
}
[BackgroundDependencyLoader(true)]
private void load([NotNull] IScrollingInfo scrollingInfo, [CanBeNull] DrawableHitObject drawableObject)
private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
{
direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true);

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
namespace osu.Game.Rulesets.Mania.Skinning.Default
{
/// <summary>

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;

View File

@ -1,12 +1,10 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Textures;
@ -20,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
public class LegacyBodyPiece : LegacyManiaColumnElement
{
private DrawableHoldNote holdNote;
private DrawableHoldNote holdNote = null!;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly IBindable<bool> isHitting = new Bindable<bool>();
@ -31,14 +29,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
/// </summary>
private readonly Bindable<double?> missFadeTime = new Bindable<double?>();
[CanBeNull]
private Drawable bodySprite;
private Drawable? bodySprite;
[CanBeNull]
private Drawable lightContainer;
private Drawable? lightContainer;
[CanBeNull]
private Drawable light;
private Drawable? light;
public LegacyBodyPiece()
{
@ -214,7 +209,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
base.Dispose(isDisposing);
if (holdNote != null)
if (holdNote.IsNotNull())
holdNote.ApplyCustomUpdateState -= applyCustomUpdateState;
lightContainer?.Expire();

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -21,8 +19,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Container lightContainer;
private Sprite light;
private Container lightContainer = null!;
private Sprite light = null!;
public LegacyColumnBackground()
{

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.Bindables;
@ -23,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Drawable explosion;
private Drawable? explosion;
public LegacyHitExplosion()
{

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -20,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Container directionContainer;
private Container directionContainer = null!;
[BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)

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 osu.Framework.Graphics;
using osu.Game.Skinning;
@ -10,7 +8,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
public class LegacyHoldNoteHeadPiece : LegacyNotePiece
{
protected override Drawable GetAnimation(ISkinSource skin)
protected override Drawable? GetAnimation(ISkinSource skin)
{
// TODO: Should fallback to the head from default legacy skin instead of note.
return GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)

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 osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
@ -20,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
: new ValueChangedEvent<ScrollingDirection>(ScrollingDirection.Up, ScrollingDirection.Up));
}
protected override Drawable GetAnimation(ISkinSource skin)
protected override Drawable? GetAnimation(ISkinSource skin)
{
// TODO: Should fallback to the head from default legacy skin instead of note.
return GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteTailImage)

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -21,12 +19,12 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Container directionContainer;
private Sprite upSprite;
private Sprite downSprite;
private Container directionContainer = null!;
private Sprite upSprite = null!;
private Sprite downSprite = null!;
[Resolved]
private Column column { get; set; }
private Column column { get; set; } = null!;
public LegacyKeyArea()
{

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.Bindables;
@ -19,15 +17,15 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
public class LegacyManiaColumnElement : CompositeDrawable
{
[Resolved]
protected Column Column { get; private set; }
protected Column Column { get; private set; } = null!;
[Resolved]
private StageDefinition stage { get; set; }
private StageDefinition stage { get; set; } = null!;
/// <summary>
/// The column type identifier to use for texture lookups, in the case of no user-provided configuration.
/// </summary>
protected string FallbackColumnIndex { get; private set; }
protected string FallbackColumnIndex { get; private set; } = null!;
[BackgroundDependencyLoader]
private void load()
@ -41,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
protected IBindable<T> GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
protected IBindable<T>? GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup) where T : notnull
=> skin.GetManiaSkinConfig<T>(lookup, Column.Index);
}
}

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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
@ -41,21 +39,15 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
Y = scorePosition ?? 0;
if (animation != null)
InternalChild = animation.With(d =>
{
InternalChild = animation.With(d =>
{
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
});
}
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
});
}
public void PlayAnimation()
{
if (animation == null)
return;
(animation as IFramedAnimation)?.GotoFrame(0);
this.FadeInFromZero(20, Easing.Out)
@ -86,6 +78,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
public Drawable GetAboveHitObjectsProxiedContent() => null;
public Drawable? GetAboveHitObjectsProxiedContent() => null;
}
}

View File

@ -1,9 +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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -21,10 +18,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Container directionContainer;
private Container directionContainer = null!;
[CanBeNull]
private Drawable noteAnimation;
private Drawable noteAnimation = null!;
private float? minimumColumnWidth;
@ -55,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
base.Update();
Texture texture = null;
Texture? texture = null;
if (noteAnimation is Sprite sprite)
texture = sprite.Texture;
@ -84,11 +80,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
}
}
[CanBeNull]
protected virtual Drawable GetAnimation(ISkinSource skin) => GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
protected virtual Drawable? GetAnimation(ISkinSource skin) => GetAnimationFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
[CanBeNull]
protected Drawable GetAnimationFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
protected Drawable? GetAnimationFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
{
string suffix = string.Empty;

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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -17,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private Drawable sprite;
private Drawable? sprite;
public LegacyStageForeground()
{

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
}
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
{
if (lookup is ManiaSkinConfigurationLookup maniaLookup)
{

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 osu.Framework.Bindables;
using osu.Game.Skinning;
@ -16,8 +14,8 @@ namespace osu.Game.Rulesets.Mania.Skinning
/// <param name="skin">The skin from which configuration is retrieved.</param>
/// <param name="lookup">The value to retrieve.</param>
/// <param name="columnIndex">If not null, denotes the index of the column to which the entry applies.</param>
public static IBindable<T> GetManiaSkinConfig<T>(this ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? columnIndex = null)
=> skin.GetConfig<ManiaSkinConfigurationLookup, T>(
new ManiaSkinConfigurationLookup(lookup, columnIndex));
public static IBindable<T>? GetManiaSkinConfig<T>(this ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? columnIndex = null)
where T : notnull
=> skin.GetConfig<ManiaSkinConfigurationLookup, T>(new ManiaSkinConfigurationLookup(lookup, columnIndex));
}
}

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 osu.Game.Rulesets.Mania.UI;
using osu.Game.Skinning;