Apply nullability to skinning support classes

This commit is contained in:
Dean Herbert 2022-11-09 13:44:59 +09:00
parent 2952dbc8fb
commit bf26dbffc2
31 changed files with 60 additions and 119 deletions

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using JetBrains.Annotations;
using osu.Framework.Graphics; using osu.Framework.Graphics;
namespace osu.Game.Rulesets.Judgements namespace osu.Game.Rulesets.Judgements
@ -21,7 +18,6 @@ namespace osu.Game.Rulesets.Judgements
/// <summary> /// <summary>
/// Get proxied content which should be displayed above all hitobjects. /// Get proxied content which should be displayed above all hitobjects.
/// </summary> /// </summary>
[CanBeNull] Drawable? GetAboveHitObjectsProxiedContent();
Drawable GetAboveHitObjectsProxiedContent();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -25,7 +24,7 @@ namespace osu.Game.Skinning
{ {
public static SkinInfo CreateInfo() => new SkinInfo public static SkinInfo CreateInfo() => new SkinInfo
{ {
ID = osu.Game.Skinning.SkinInfo.ARGON_SKIN, ID = Skinning.SkinInfo.ARGON_SKIN,
Name = "osu! \"argon\" (2022)", Name = "osu! \"argon\" (2022)",
Creator = "team osu!", Creator = "team osu!",
Protected = true, Protected = true,
@ -68,9 +67,9 @@ namespace osu.Game.Skinning
}; };
} }
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT);
public override ISample GetSample(ISampleInfo sampleInfo) public override ISample? GetSample(ISampleInfo sampleInfo)
{ {
foreach (string lookup in sampleInfo.LookupNames) foreach (string lookup in sampleInfo.LookupNames)
{ {
@ -82,7 +81,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinComponent component)
{ {
if (base.GetDrawableComponent(component) is Drawable c) if (base.GetDrawableComponent(component) is Drawable c)
return c; return c;
@ -192,7 +191,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
{ {
// todo: this code is pulled from LegacySkin and should not exist. // todo: this code is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes. // will likely change based on how databased storage of skin configuration goes.
@ -202,7 +201,7 @@ namespace osu.Game.Skinning
switch (global) switch (global)
{ {
case GlobalSkinColours.ComboColours: case GlobalSkinColours.ComboColours:
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours)); return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>?>(Configuration.ComboColours));
} }
break; break;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;

View File

@ -1,13 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class GameplaySkinComponent<T> : ISkinComponent public class GameplaySkinComponent<T> : ISkinComponent
where T : notnull
{ {
public readonly T Component; public readonly T Component;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public enum GlobalSkinColours public enum GlobalSkinColours

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using JetBrains.Annotations;
using osu.Game.Audio; using osu.Game.Audio;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -18,7 +15,6 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
/// <param name="sampleInfo">The <see cref="SampleInfo"/> describing the sample to retrieve.</param> /// <param name="sampleInfo">The <see cref="SampleInfo"/> describing the sample to retrieve.</param>
/// <returns>The <see cref="PoolableSkinnableSample"/>.</returns> /// <returns>The <see cref="PoolableSkinnableSample"/>.</returns>
[CanBeNull] PoolableSkinnableSample? GetPooledSample(ISampleInfo sampleInfo);
PoolableSkinnableSample GetPooledSample(ISampleInfo sampleInfo);
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public interface ISkinComponent public interface ISkinComponent

View File

@ -1,11 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -24,8 +21,7 @@ namespace osu.Game.Skinning
/// This should be used for cases where subsequent lookups (for related components) need to occur on the same skin. /// This should be used for cases where subsequent lookups (for related components) need to occur on the same skin.
/// </summary> /// </summary>
/// <returns>The skin to be used for subsequent lookups, or <c>null</c> if none is available.</returns> /// <returns>The skin to be used for subsequent lookups, or <c>null</c> if none is available.</returns>
[CanBeNull] ISkin? FindProvider(Func<ISkin, bool> lookupFunction);
ISkin FindProvider(Func<ISkin, bool> lookupFunction);
/// <summary> /// <summary>
/// Retrieve all sources available for lookup, with highest priority source first. /// Retrieve all sources available for lookup, with highest priority source first.

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Extensions.TypeExtensions;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osuTK.Graphics; using osuTK.Graphics;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Animations;
@ -20,13 +18,13 @@ namespace osu.Game.Skinning
{ {
private readonly HitResult result; private readonly HitResult result;
private readonly LegacyJudgementPieceOld temporaryOldStyle; private readonly LegacyJudgementPieceOld? temporaryOldStyle;
private readonly Drawable mainPiece; private readonly Drawable mainPiece;
private readonly ParticleExplosion particles; private readonly ParticleExplosion? particles;
public LegacyJudgementPieceNew(HitResult result, Func<Drawable> createMainDrawable, Texture particleTexture) public LegacyJudgementPieceNew(HitResult result, Func<Drawable> createMainDrawable, Texture? particleTexture)
{ {
this.result = result; this.result = result;
@ -124,6 +122,6 @@ namespace osu.Game.Skinning
} }
} }
public Drawable GetAboveHitObjectsProxiedContent() => temporaryOldStyle?.CreateProxy(); // for new style judgements, only the old style temporary display is in front of objects. public Drawable? GetAboveHitObjectsProxiedContent() => temporaryOldStyle?.CreateProxy(); // for new style judgements, only the old style temporary display is in front of objects.
} }
} }

View File

@ -9,6 +9,7 @@ using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
@ -379,12 +380,13 @@ namespace osu.Game.Skinning
return null; return null;
case GameplaySkinComponent<HitResult> resultComponent: case GameplaySkinComponent<HitResult> resultComponent:
// TODO: this should be inside the judgement pieces.
Func<Drawable?> createDrawable = () => getJudgementAnimation(resultComponent.Component);
// kind of wasteful that we throw this away, but should do for now. // kind of wasteful that we throw this away, but should do for now.
if (createDrawable() != null) if (getJudgementAnimation(resultComponent.Component) != null)
{ {
// TODO: this should be inside the judgement pieces.
Func<Drawable> createDrawable = () => getJudgementAnimation(resultComponent.Component).AsNonNull();
var particle = getParticleTexture(resultComponent.Component); var particle = getParticleTexture(resultComponent.Component);
if (particle != null) if (particle != null)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Skinning namespace osu.Game.Skinning

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Configuration; using osu.Framework.Configuration;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osuTK.Graphics; using osuTK.Graphics;
@ -52,7 +50,7 @@ namespace osu.Game.Skinning
public List<Color4> CustomComboColours { get; set; } = new List<Color4>(); public List<Color4> CustomComboColours { get; set; } = new List<Color4>();
public IReadOnlyList<Color4> ComboColours public IReadOnlyList<Color4>? ComboColours
{ {
get get
{ {

View File

@ -1,12 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -22,10 +19,9 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public class SkinProvidingContainer : Container, ISkinSource public class SkinProvidingContainer : Container, ISkinSource
{ {
public event Action SourceChanged; public event Action? SourceChanged;
[CanBeNull] protected ISkinSource? ParentSource { get; private set; }
protected ISkinSource ParentSource { get; private set; }
/// <summary> /// <summary>
/// Whether falling back to parent <see cref="ISkinSource"/>s is allowed in this container. /// Whether falling back to parent <see cref="ISkinSource"/>s is allowed in this container.
@ -52,7 +48,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// Constructs a new <see cref="SkinProvidingContainer"/> initialised with a single skin source. /// Constructs a new <see cref="SkinProvidingContainer"/> initialised with a single skin source.
/// </summary> /// </summary>
public SkinProvidingContainer([CanBeNull] ISkin skin) public SkinProvidingContainer(ISkin? skin)
: this() : this()
{ {
if (skin != null) if (skin != null)
@ -82,7 +78,7 @@ namespace osu.Game.Skinning
return dependencies; return dependencies;
} }
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) public ISkin? FindProvider(Func<ISkin, bool> lookupFunction)
{ {
foreach (var (skin, lookupWrapper) in skinSources) foreach (var (skin, lookupWrapper) in skinSources)
{ {
@ -111,11 +107,11 @@ namespace osu.Game.Skinning
} }
} }
public Drawable GetDrawableComponent(ISkinComponent component) public Drawable? GetDrawableComponent(ISkinComponent component)
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
Drawable sourceDrawable; Drawable? sourceDrawable;
if ((sourceDrawable = lookupWrapper.GetDrawableComponent(component)) != null) if ((sourceDrawable = lookupWrapper.GetDrawableComponent(component)) != null)
return sourceDrawable; return sourceDrawable;
} }
@ -126,11 +122,11 @@ namespace osu.Game.Skinning
return ParentSource?.GetDrawableComponent(component); return ParentSource?.GetDrawableComponent(component);
} }
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
Texture sourceTexture; Texture? sourceTexture;
if ((sourceTexture = lookupWrapper.GetTexture(componentName, wrapModeS, wrapModeT)) != null) if ((sourceTexture = lookupWrapper.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
return sourceTexture; return sourceTexture;
} }
@ -141,11 +137,11 @@ namespace osu.Game.Skinning
return ParentSource?.GetTexture(componentName, wrapModeS, wrapModeT); return ParentSource?.GetTexture(componentName, wrapModeS, wrapModeT);
} }
public ISample GetSample(ISampleInfo sampleInfo) public ISample? GetSample(ISampleInfo sampleInfo)
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
ISample sourceSample; ISample? sourceSample;
if ((sourceSample = lookupWrapper.GetSample(sampleInfo)) != null) if ((sourceSample = lookupWrapper.GetSample(sampleInfo)) != null)
return sourceSample; return sourceSample;
} }
@ -156,11 +152,13 @@ namespace osu.Game.Skinning
return ParentSource?.GetSample(sampleInfo); return ParentSource?.GetSample(sampleInfo);
} }
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
where TLookup : notnull
where TValue : notnull
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
IBindable<TValue> bindable; IBindable<TValue>? bindable;
if ((bindable = lookupWrapper.GetConfig<TLookup, TValue>(lookup)) != null) if ((bindable = lookupWrapper.GetConfig<TLookup, TValue>(lookup)) != null)
return bindable; return bindable;
} }
@ -240,7 +238,7 @@ namespace osu.Game.Skinning
this.provider = provider; this.provider = provider;
} }
public Drawable GetDrawableComponent(ISkinComponent component) public Drawable? GetDrawableComponent(ISkinComponent component)
{ {
if (provider.AllowDrawableLookup(component)) if (provider.AllowDrawableLookup(component))
return skin.GetDrawableComponent(component); return skin.GetDrawableComponent(component);
@ -248,7 +246,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{ {
if (provider.AllowTextureLookup(componentName)) if (provider.AllowTextureLookup(componentName))
return skin.GetTexture(componentName, wrapModeS, wrapModeT); return skin.GetTexture(componentName, wrapModeS, wrapModeT);
@ -256,7 +254,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public ISample GetSample(ISampleInfo sampleInfo) public ISample? GetSample(ISampleInfo sampleInfo)
{ {
if (provider.AllowSampleLookup(sampleInfo)) if (provider.AllowSampleLookup(sampleInfo))
return skin.GetSample(sampleInfo); return skin.GetSample(sampleInfo);
@ -264,7 +262,9 @@ namespace osu.Game.Skinning
return null; return null;
} }
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
where TLookup : notnull
where TValue : notnull
{ {
switch (lookup) switch (lookup)
{ {

View File

@ -1,10 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -17,12 +16,12 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// Invoked when <see cref="CurrentSkin"/> has changed. /// Invoked when <see cref="CurrentSkin"/> has changed.
/// </summary> /// </summary>
public event Action OnSkinChanged; public event Action? OnSkinChanged;
/// <summary> /// <summary>
/// The current skin source. /// The current skin source.
/// </summary> /// </summary>
protected ISkinSource CurrentSkin { get; private set; } protected ISkinSource CurrentSkin { get; private set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource source) private void load(ISkinSource source)
@ -60,7 +59,7 @@ namespace osu.Game.Skinning
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (CurrentSkin != null) if (CurrentSkin.IsNotNull())
CurrentSkin.SourceChanged -= onChange; CurrentSkin.SourceChanged -= onChange;
OnSkinChanged = null; OnSkinChanged = null;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Bindables; using osu.Framework.Bindables;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -18,6 +16,6 @@ namespace osu.Game.Skinning
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
/// <typeparam name="TValue">The type of value <paramref name="value"/>, and the type of the resulting bindable.</typeparam> /// <typeparam name="TValue">The type of value <paramref name="value"/>, and the type of the resulting bindable.</typeparam>
/// <returns>The resulting bindable.</returns> /// <returns>The resulting bindable.</returns>
public static Bindable<TValue> As<TValue>(object value) => (Bindable<TValue>)value; public static Bindable<TValue>? As<TValue>(object? value) => (Bindable<TValue>?)value;
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -27,13 +25,13 @@ namespace osu.Game.Skinning
protected override bool ApplySizeRestrictionsToDefault => true; protected override bool ApplySizeRestrictionsToDefault => true;
[Resolved] [Resolved]
private TextureStore textures { get; set; } private TextureStore textures { get; set; } = null!;
[SettingSource("Sprite name", "The filename of the sprite", SettingControlType = typeof(SpriteSelectorControl))] [SettingSource("Sprite name", "The filename of the sprite", SettingControlType = typeof(SpriteSelectorControl))]
public Bindable<string> SpriteName { get; } = new Bindable<string>(string.Empty); public Bindable<string> SpriteName { get; } = new Bindable<string>(string.Empty);
[Resolved] [Resolved]
private ISkinSource source { get; set; } private ISkinSource source { get; set; } = null!;
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling) public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
: base(new SpriteComponent(textureName), confineMode) : base(new SpriteComponent(textureName), confineMode)
@ -88,15 +86,15 @@ namespace osu.Game.Skinning
// but that requires further thought. // but that requires further thought.
var highestPrioritySkin = getHighestPriorityUserSkin(((SkinnableSprite)SettingSourceObject).source.AllSources) as Skin; var highestPrioritySkin = getHighestPriorityUserSkin(((SkinnableSprite)SettingSourceObject).source.AllSources) as Skin;
string[] availableFiles = highestPrioritySkin?.SkinInfo.PerformRead(s => s.Files string[]? availableFiles = highestPrioritySkin?.SkinInfo.PerformRead(s => s.Files
.Where(f => f.Filename.EndsWith(".png", StringComparison.Ordinal) .Where(f => f.Filename.EndsWith(".png", StringComparison.Ordinal)
|| f.Filename.EndsWith(".jpg", StringComparison.Ordinal)) || f.Filename.EndsWith(".jpg", StringComparison.Ordinal))
.Select(f => f.Filename).Distinct()).ToArray(); .Select(f => f.Filename).Distinct()).ToArray();
if (availableFiles?.Length > 0) if (availableFiles?.Length > 0)
Items = availableFiles; Items = availableFiles;
static ISkin getHighestPriorityUserSkin(IEnumerable<ISkin> skins) static ISkin? getHighestPriorityUserSkin(IEnumerable<ISkin> skins)
{ {
foreach (var skin in skins) foreach (var skin in skins)
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public enum SkinnableTarget public enum SkinnableTarget

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class SkinnableTargetComponent : ISkinComponent public class SkinnableTargetComponent : ISkinComponent

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -21,7 +19,7 @@ namespace osu.Game.Skinning
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }
private readonly Action<Container> applyDefaults; private readonly Action<Container>? applyDefaults;
/// <summary> /// <summary>
/// Construct a wrapper with defaults that should be applied once. /// Construct a wrapper with defaults that should be applied once.

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -13,7 +11,7 @@ namespace osu.Game.Skinning
{ {
public class SkinnableTargetContainer : SkinReloadableDrawable, ISkinnableTarget public class SkinnableTargetContainer : SkinReloadableDrawable, ISkinnableTarget
{ {
private SkinnableTargetComponentsContainer content; private SkinnableTargetComponentsContainer? content;
public SkinnableTarget Target { get; } public SkinnableTarget Target { get; }
@ -25,7 +23,7 @@ namespace osu.Game.Skinning
public bool ComponentsLoaded { get; private set; } public bool ComponentsLoaded { get; private set; }
private CancellationTokenSource cancellationSource; private CancellationTokenSource? cancellationSource;
public SkinnableTargetContainer(SkinnableTarget target) public SkinnableTargetContainer(SkinnableTarget target)
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -47,9 +45,9 @@ namespace osu.Game.Skinning
this.resources = resources; this.resources = resources;
} }
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT);
public override ISample GetSample(ISampleInfo sampleInfo) public override ISample? GetSample(ISampleInfo sampleInfo)
{ {
foreach (string lookup in sampleInfo.LookupNames) foreach (string lookup in sampleInfo.LookupNames)
{ {
@ -61,7 +59,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Drawable GetDrawableComponent(ISkinComponent component) public override Drawable? GetDrawableComponent(ISkinComponent component)
{ {
if (base.GetDrawableComponent(component) is Drawable c) if (base.GetDrawableComponent(component) is Drawable c)
return c; return c;
@ -171,7 +169,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public override IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
{ {
// todo: this code is pulled from LegacySkin and should not exist. // todo: this code is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes. // will likely change based on how databased storage of skin configuration goes.
@ -181,7 +179,7 @@ namespace osu.Game.Skinning
switch (global) switch (global)
{ {
case GlobalSkinColours.ComboColours: case GlobalSkinColours.ComboColours:
return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>>(Configuration.ComboColours)); return SkinUtils.As<TValue>(new Bindable<IReadOnlyList<Color4>?>(Configuration.ComboColours));
} }
break; break;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
namespace osu.Game.Skinning namespace osu.Game.Skinning