mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 01:22:59 +08:00
Merge pull request #22174 from mk56-spn/song_select_nullability
Enable NRT annotations in `SongSelect` classes
This commit is contained in:
commit
dd5db58a53
@ -173,7 +173,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
IsValidMod = IsValidMod
|
||||
};
|
||||
|
||||
protected override IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons()
|
||||
protected override IEnumerable<(FooterButton, OverlayContainer?)> CreateFooterButtons()
|
||||
{
|
||||
var buttons = base.CreateFooterButtons().ToList();
|
||||
buttons.Insert(buttons.FindIndex(b => b.Item1 is FooterButtonMods) + 1, (new FooterButtonFreeMods { Current = FreeMods }, freeModSelectOverlay));
|
||||
|
@ -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.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
@ -36,7 +34,7 @@ using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Collections;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
@ -49,7 +47,7 @@ namespace osu.Game.Screens.Select
|
||||
protected const float BACKGROUND_BLUR = 20;
|
||||
private const float left_area_padding = 20;
|
||||
|
||||
public FilterControl FilterControl { get; private set; }
|
||||
public FilterControl FilterControl { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this song select instance should take control of the global track,
|
||||
@ -64,75 +62,71 @@ namespace osu.Game.Screens.Select
|
||||
/// <summary>
|
||||
/// Can be null if <see cref="ShowFooter"/> is false.
|
||||
/// </summary>
|
||||
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; }
|
||||
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Can be null if <see cref="ShowFooter"/> is false.
|
||||
/// </summary>
|
||||
protected Footer Footer { get; private set; }
|
||||
protected Footer? Footer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains any panel which is triggered by a footer button.
|
||||
/// Helps keep them located beneath the footer itself.
|
||||
/// </summary>
|
||||
protected Container FooterPanels { get; private set; }
|
||||
protected Container FooterPanels { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether entering editor mode should be allowed.
|
||||
/// </summary>
|
||||
public virtual bool AllowEditing => true;
|
||||
|
||||
public bool BeatmapSetsLoaded => IsLoaded && Carousel?.BeatmapSetsLoaded == true;
|
||||
public bool BeatmapSetsLoaded => IsLoaded && Carousel.BeatmapSetsLoaded;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
|
||||
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
|
||||
|
||||
protected BeatmapCarousel Carousel { get; private set; }
|
||||
protected BeatmapCarousel Carousel { get; private set; } = null!;
|
||||
|
||||
private ParallaxContainer wedgeBackground;
|
||||
private ParallaxContainer wedgeBackground = null!;
|
||||
|
||||
protected Container LeftArea { get; private set; }
|
||||
protected Container LeftArea { get; private set; } = null!;
|
||||
|
||||
private BeatmapInfoWedge beatmapInfoWedge;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
private BeatmapInfoWedge beatmapInfoWedge = null!;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
protected ModSelectOverlay ModSelect { get; private set; }
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; } = null!;
|
||||
|
||||
protected Sample SampleConfirm { get; private set; }
|
||||
protected ModSelectOverlay ModSelect { get; private set; } = null!;
|
||||
|
||||
private Sample sampleChangeDifficulty;
|
||||
private Sample sampleChangeBeatmap;
|
||||
protected Sample? SampleConfirm { get; private set; }
|
||||
|
||||
private Container carouselContainer;
|
||||
private Sample sampleChangeDifficulty = null!;
|
||||
private Sample sampleChangeBeatmap = null!;
|
||||
|
||||
protected BeatmapDetailArea BeatmapDetails { get; private set; }
|
||||
private Container carouselContainer = null!;
|
||||
|
||||
private FooterButtonOptions beatmapOptionsButton;
|
||||
protected BeatmapDetailArea BeatmapDetails { get; private set; } = null!;
|
||||
|
||||
private FooterButtonOptions beatmapOptionsButton = null!;
|
||||
|
||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private double audioFeedbackLastPlaybackTime;
|
||||
|
||||
[CanBeNull]
|
||||
private IDisposable modSelectOverlayRegistration;
|
||||
private IDisposable? modSelectOverlayRegistration;
|
||||
|
||||
[Resolved]
|
||||
private MusicController music { get; set; }
|
||||
private MusicController music { get; set; } = null!;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
internal IOverlayManager OverlayManager { get; private set; }
|
||||
[Resolved]
|
||||
internal IOverlayManager? OverlayManager { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
||||
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender)
|
||||
{
|
||||
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
|
||||
transferRulesetValue();
|
||||
|
||||
LoadComponentAsync(Carousel = new BeatmapCarousel
|
||||
{
|
||||
AllowSelection = false, // delay any selection until our bindables are ready to make a good choice.
|
||||
@ -146,6 +140,9 @@ namespace osu.Game.Screens.Select
|
||||
GetRecommendedBeatmap = s => recommender?.GetRecommendedBeatmap(s),
|
||||
}, c => carouselContainer.Child = c);
|
||||
|
||||
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
|
||||
transferRulesetValue();
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new ResetScrollContainer(() => Carousel.ScrollToSelected())
|
||||
@ -273,7 +270,7 @@ namespace osu.Game.Screens.Select
|
||||
BeatmapOptions = new BeatmapOptionsOverlay(),
|
||||
}
|
||||
},
|
||||
Footer = new Footer(),
|
||||
Footer = new Footer()
|
||||
});
|
||||
}
|
||||
|
||||
@ -318,7 +315,7 @@ namespace osu.Game.Screens.Select
|
||||
/// Creates the buttons to be displayed in the footer.
|
||||
/// </summary>
|
||||
/// <returns>A set of <see cref="FooterButton"/> and an optional <see cref="OverlayContainer"/> which the button opens when pressed.</returns>
|
||||
protected virtual IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons() => new (FooterButton, OverlayContainer)[]
|
||||
protected virtual IEnumerable<(FooterButton, OverlayContainer?)> CreateFooterButtons() => new (FooterButton, OverlayContainer?)[]
|
||||
{
|
||||
(new FooterButtonMods { Current = Mods }, ModSelect),
|
||||
(new FooterButtonRandom
|
||||
@ -339,7 +336,7 @@ namespace osu.Game.Screens.Select
|
||||
Carousel.Filter(criteria, shouldDebounce);
|
||||
}
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
private DependencyContainer dependencies = null!;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
@ -357,7 +354,7 @@ namespace osu.Game.Screens.Select
|
||||
/// </summary>
|
||||
protected abstract BeatmapDetailArea CreateBeatmapDetailArea();
|
||||
|
||||
public void Edit(BeatmapInfo beatmapInfo = null)
|
||||
public void Edit(BeatmapInfo? beatmapInfo = null)
|
||||
{
|
||||
if (!AllowEditing)
|
||||
throw new InvalidOperationException($"Attempted to edit when {nameof(AllowEditing)} is disabled");
|
||||
@ -372,7 +369,7 @@ namespace osu.Game.Screens.Select
|
||||
/// <param name="beatmapInfo">An optional beatmap to override the current carousel selection.</param>
|
||||
/// <param name="ruleset">An optional ruleset to override the current carousel selection.</param>
|
||||
/// <param name="customStartAction">An optional custom action to perform instead of <see cref="OnStart"/>.</param>
|
||||
public void FinaliseSelection(BeatmapInfo beatmapInfo = null, RulesetInfo ruleset = null, Action customStartAction = null)
|
||||
public void FinaliseSelection(BeatmapInfo? beatmapInfo = null, RulesetInfo? ruleset = null, Action? customStartAction = null)
|
||||
{
|
||||
// This is very important as we have not yet bound to screen-level bindables before the carousel load is completed.
|
||||
if (!Carousel.BeatmapSetsLoaded)
|
||||
@ -419,9 +416,9 @@ namespace osu.Game.Screens.Select
|
||||
/// <returns>If a resultant action occurred that takes the user away from SongSelect.</returns>
|
||||
protected abstract bool OnStart();
|
||||
|
||||
private ScheduledDelegate selectionChangedDebounce;
|
||||
private ScheduledDelegate? selectionChangedDebounce;
|
||||
|
||||
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap> e = null)
|
||||
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap>? e = null)
|
||||
{
|
||||
var beatmap = e?.NewValue ?? Beatmap.Value;
|
||||
if (beatmap is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
|
||||
@ -451,11 +448,11 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
private BeatmapInfo beatmapInfoPrevious;
|
||||
private BeatmapInfo beatmapInfoNoDebounce;
|
||||
private RulesetInfo rulesetNoDebounce;
|
||||
private BeatmapInfo? beatmapInfoPrevious;
|
||||
private BeatmapInfo? beatmapInfoNoDebounce;
|
||||
private RulesetInfo? rulesetNoDebounce;
|
||||
|
||||
private void updateSelectedBeatmap(BeatmapInfo beatmapInfo)
|
||||
private void updateSelectedBeatmap(BeatmapInfo? beatmapInfo)
|
||||
{
|
||||
if (beatmapInfo == null && beatmapInfoNoDebounce == null)
|
||||
return;
|
||||
@ -467,7 +464,7 @@ namespace osu.Game.Screens.Select
|
||||
performUpdateSelected();
|
||||
}
|
||||
|
||||
private void updateSelectedRuleset(RulesetInfo ruleset)
|
||||
private void updateSelectedRuleset(RulesetInfo? ruleset)
|
||||
{
|
||||
if (ruleset == null && rulesetNoDebounce == null)
|
||||
return;
|
||||
@ -485,7 +482,7 @@ namespace osu.Game.Screens.Select
|
||||
private void performUpdateSelected()
|
||||
{
|
||||
var beatmap = beatmapInfoNoDebounce;
|
||||
var ruleset = rulesetNoDebounce;
|
||||
RulesetInfo? ruleset = rulesetNoDebounce;
|
||||
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
@ -694,6 +691,7 @@ namespace osu.Game.Screens.Select
|
||||
isHandlingLooping = true;
|
||||
|
||||
ensureTrackLooping(Beatmap.Value, TrackChangeDirection.None);
|
||||
|
||||
music.TrackChanged += ensureTrackLooping;
|
||||
}
|
||||
|
||||
@ -728,7 +726,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
decoupledRuleset.UnbindAll();
|
||||
|
||||
if (music != null)
|
||||
if (music.IsNotNull())
|
||||
music.TrackChanged -= ensureTrackLooping;
|
||||
|
||||
modSelectOverlayRegistration?.Dispose();
|
||||
@ -763,7 +761,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
|
||||
private readonly WeakReference<ITrack?> lastTrack = new WeakReference<ITrack?>(null);
|
||||
|
||||
/// <summary>
|
||||
/// Ensures some music is playing for the current track.
|
||||
@ -864,18 +862,18 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
// if we have a pending filter operation, we want to run it now.
|
||||
// it could change selection (ie. if the ruleset has been changed).
|
||||
Carousel?.FlushPendingFilterOperations();
|
||||
Carousel.FlushPendingFilterOperations();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void delete(BeatmapSetInfo beatmap)
|
||||
private void delete(BeatmapSetInfo? beatmap)
|
||||
{
|
||||
if (beatmap == null) return;
|
||||
|
||||
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||
}
|
||||
|
||||
private void clearScores(BeatmapInfo beatmapInfo)
|
||||
private void clearScores(BeatmapInfo? beatmapInfo)
|
||||
{
|
||||
if (beatmapInfo == null) return;
|
||||
|
||||
@ -950,7 +948,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private partial class ResetScrollContainer : Container
|
||||
{
|
||||
private readonly Action onHoverAction;
|
||||
private readonly Action? onHoverAction;
|
||||
|
||||
public ResetScrollContainer(Action onHoverAction)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user