mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Remove nullable disabling in carousel
This commit is contained in:
parent
74b11cc8f1
commit
47fb467012
@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("select next and enter", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
|
||||
.First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
|
||||
.First(b => !((CarouselBeatmap)b.Item!).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
|
||||
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
||||
@ -235,7 +235,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("select next and enter", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
|
||||
.First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
|
||||
.First(b => !((CarouselBeatmap)b.Item!).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
|
||||
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
|
||||
@ -614,7 +614,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddAssert("selected only shows expected ruleset (plus converts)", () =>
|
||||
{
|
||||
var selectedPanel = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First(s => s.Item.State.Value == CarouselItemState.Selected);
|
||||
var selectedPanel = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First(s => s.Item!.State.Value == CarouselItemState.Selected);
|
||||
|
||||
// special case for converts checked here.
|
||||
return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i =>
|
||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Select
|
||||
/// <summary>
|
||||
/// A function to optionally decide on a recommended difficulty from a beatmap set.
|
||||
/// </summary>
|
||||
public Func<IEnumerable<BeatmapInfo>, BeatmapInfo>? GetRecommendedBeatmap;
|
||||
public Func<IEnumerable<BeatmapInfo>, BeatmapInfo?>? GetRecommendedBeatmap;
|
||||
|
||||
private CarouselBeatmapSet? selectedBeatmapSet;
|
||||
|
||||
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
CarouselRoot newRoot = new CarouselRoot(this);
|
||||
|
||||
newRoot.AddItems(beatmapSets.Select(s => createCarouselSet(s.Detach())).Where(g => g != null));
|
||||
newRoot.AddItems(beatmapSets.Select(s => createCarouselSet(s.Detach())).Where(g => g != null)!);
|
||||
|
||||
root = newRoot;
|
||||
|
||||
@ -739,7 +739,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (var panel in Scroll.Children)
|
||||
{
|
||||
if (toDisplay.Remove(panel.Item))
|
||||
if (toDisplay.Remove(panel.Item!))
|
||||
{
|
||||
// panel already displayed.
|
||||
continue;
|
||||
@ -770,7 +770,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
updateItem(item);
|
||||
|
||||
if (item.Item.Visible)
|
||||
if (item.Item!.Visible)
|
||||
{
|
||||
bool isSelected = item.Item.State.Value == CarouselItemState.Selected;
|
||||
|
||||
|
@ -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 System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
|
@ -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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -33,7 +31,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
public Func<IEnumerable<BeatmapInfo>, BeatmapInfo> GetRecommendedBeatmap;
|
||||
public Func<IEnumerable<BeatmapInfo>, BeatmapInfo?>? GetRecommendedBeatmap;
|
||||
|
||||
public CarouselBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
@ -47,7 +45,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
.ForEach(AddItem);
|
||||
}
|
||||
|
||||
protected override CarouselItem GetNextToSelect()
|
||||
protected override CarouselItem? GetNextToSelect()
|
||||
{
|
||||
if (LastSelected == null || LastSelected.Filtered.Value)
|
||||
{
|
||||
@ -132,8 +130,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
bool filtered = Items.All(i => i.Filtered.Value);
|
||||
|
||||
filtered |= criteria.Sort == SortMode.DateRanked && BeatmapSet?.DateRanked == null;
|
||||
filtered |= criteria.Sort == SortMode.DateSubmitted && BeatmapSet?.DateSubmitted == null;
|
||||
filtered |= criteria.Sort == SortMode.DateRanked && BeatmapSet.DateRanked == null;
|
||||
filtered |= criteria.Sort == SortMode.DateSubmitted && BeatmapSet.DateSubmitted == null;
|
||||
|
||||
Filtered.Value = filtered;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// </summary>
|
||||
public class CarouselGroup : CarouselItem
|
||||
{
|
||||
public override DrawableCarouselItem? CreateDrawableRepresentation() => null;
|
||||
public override DrawableCarouselItem CreateDrawableRepresentation() => null!;
|
||||
|
||||
public IReadOnlyList<CarouselItem> Items => items;
|
||||
|
||||
|
@ -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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -26,7 +24,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// <summary>
|
||||
/// The last selected item.
|
||||
/// </summary>
|
||||
protected CarouselItem LastSelected { get; private set; }
|
||||
protected CarouselItem? LastSelected { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// We need to keep track of the index for cases where the selection is removed but we want to select a new item based on its old location.
|
||||
@ -112,7 +110,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// Finds the item this group would select next if it attempted selection
|
||||
/// </summary>
|
||||
/// <returns>An unfiltered item nearest to the last selected one or null if all items are filtered</returns>
|
||||
protected virtual CarouselItem GetNextToSelect()
|
||||
protected virtual CarouselItem? GetNextToSelect()
|
||||
{
|
||||
if (Items.Count == 0)
|
||||
return null;
|
||||
@ -141,7 +139,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected virtual void PerformSelection()
|
||||
{
|
||||
CarouselItem nextToSelect = GetNextToSelect();
|
||||
CarouselItem? nextToSelect = GetNextToSelect();
|
||||
|
||||
if (nextToSelect != null)
|
||||
nextToSelect.State.Value = CarouselItemState.Selected;
|
||||
@ -149,7 +147,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
updateSelected(null);
|
||||
}
|
||||
|
||||
private void updateSelected(CarouselItem newSelection)
|
||||
private void updateSelected(CarouselItem? newSelection)
|
||||
{
|
||||
if (newSelection != null)
|
||||
LastSelected = newSelection;
|
||||
|
@ -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;
|
||||
@ -95,9 +93,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
public partial class HoverLayer : HoverSampleDebounceComponent
|
||||
{
|
||||
private Sample sampleHover;
|
||||
private Sample? sampleHover;
|
||||
|
||||
private Box box;
|
||||
private Box box = null!;
|
||||
|
||||
public HoverLayer()
|
||||
{
|
||||
|
@ -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.Bindables;
|
||||
|
||||
@ -51,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ItemID.CompareTo(other.ItemID);
|
||||
|
||||
public int CompareTo(CarouselItem other) => CarouselYPosition.CompareTo(other.CarouselYPosition);
|
||||
public int CompareTo(CarouselItem? other) => CarouselYPosition.CompareTo(other!.CarouselYPosition);
|
||||
}
|
||||
|
||||
public enum CarouselItemState
|
||||
|
@ -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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -47,31 +45,31 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private readonly BeatmapInfo beatmapInfo;
|
||||
|
||||
private Sprite background;
|
||||
private Sprite background = null!;
|
||||
|
||||
private Action<BeatmapInfo> startRequested;
|
||||
private Action<BeatmapInfo> editRequested;
|
||||
private Action<BeatmapInfo> hideRequested;
|
||||
private Action<BeatmapInfo>? startRequested;
|
||||
private Action<BeatmapInfo>? editRequested;
|
||||
private Action<BeatmapInfo>? hideRequested;
|
||||
|
||||
private Triangles triangles;
|
||||
private Triangles triangles = null!;
|
||||
|
||||
private StarCounter starCounter;
|
||||
private DifficultyIcon difficultyIcon;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
||||
private StarCounter starCounter = null!;
|
||||
private DifficultyIcon difficultyIcon = null!;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapDifficultyCache difficultyCache { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
||||
private BeatmapSetOverlay? beatmapOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; }
|
||||
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
|
||||
|
||||
private IBindable<StarDifficulty?> starDifficultyBindable;
|
||||
private CancellationTokenSource starDifficultyCancellationSource;
|
||||
[Resolved]
|
||||
private ManageCollectionsDialog? manageCollectionsDialog { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
private IBindable<StarDifficulty?> starDifficultyBindable = null!;
|
||||
private CancellationTokenSource? starDifficultyCancellationSource;
|
||||
|
||||
public DrawableCarouselBeatmap(CarouselBeatmap panel)
|
||||
{
|
||||
@ -79,8 +77,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
Item = panel;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapManager manager, SongSelect songSelect)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager? manager, SongSelect? songSelect)
|
||||
{
|
||||
Header.Height = height;
|
||||
|
||||
@ -194,7 +192,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Item.State.Value == CarouselItemState.Selected)
|
||||
if (Item!.State.Value == CarouselItemState.Selected)
|
||||
startRequested?.Invoke(beatmapInfo);
|
||||
|
||||
return base.OnClick(e);
|
||||
@ -202,7 +200,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected override void ApplyState()
|
||||
{
|
||||
if (Item.State.Value != CarouselItemState.Collapsed && Alpha == 0)
|
||||
if (Item!.State.Value != CarouselItemState.Collapsed && Alpha == 0)
|
||||
starCounter.ReplayAnimation();
|
||||
|
||||
starDifficultyCancellationSource?.Cancel();
|
||||
|
@ -1,14 +1,11 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -27,30 +24,28 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public const float HEIGHT = MAX_HEIGHT;
|
||||
|
||||
private Action<BeatmapSetInfo> restoreHiddenRequested;
|
||||
private Action<int> viewDetails;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
||||
private Action<BeatmapSetInfo> restoreHiddenRequested = null!;
|
||||
private Action<int>? viewDetails;
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; }
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private ManageCollectionsDialog? manageCollectionsDialog { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Enumerable.Empty<DrawableCarouselItem>() : beatmapContainer.AliveChildren;
|
||||
|
||||
[CanBeNull]
|
||||
private Container<DrawableCarouselItem> beatmapContainer;
|
||||
private Container<DrawableCarouselItem>? beatmapContainer;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private BeatmapSetInfo beatmapSet = null!;
|
||||
|
||||
[CanBeNull]
|
||||
private Task beatmapsLoadTask;
|
||||
private Task? beatmapsLoadTask;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager manager { get; set; }
|
||||
private BeatmapManager manager { get; set; } = null!;
|
||||
|
||||
protected override void FreeAfterUse()
|
||||
{
|
||||
@ -61,8 +56,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
ClearTransforms();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapSetOverlay beatmapOverlay)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapSetOverlay? beatmapOverlay)
|
||||
{
|
||||
restoreHiddenRequested = s =>
|
||||
{
|
||||
@ -80,7 +75,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
// position updates should not occur if the item is filtered away.
|
||||
// this avoids panels flying across the screen only to be eventually off-screen or faded out.
|
||||
if (!Item.Visible)
|
||||
if (!Item!.Visible)
|
||||
return;
|
||||
|
||||
float targetY = Item.CarouselYPosition;
|
||||
@ -151,7 +146,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private void updateBeatmapDifficulties()
|
||||
{
|
||||
var carouselBeatmapSet = (CarouselBeatmapSet)Item;
|
||||
var carouselBeatmapSet = (CarouselBeatmapSet)Item!;
|
||||
|
||||
var visibleBeatmaps = carouselBeatmapSet.Items.Where(c => c.Visible).ToArray();
|
||||
|
||||
@ -196,14 +191,14 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
float yPos = DrawableCarouselBeatmap.CAROUSEL_BEATMAP_SPACING;
|
||||
|
||||
bool isSelected = Item.State.Value == CarouselItemState.Selected;
|
||||
bool isSelected = Item!.State.Value == CarouselItemState.Selected;
|
||||
|
||||
foreach (var panel in beatmapContainer.Children)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
panel.MoveToY(yPos, 800, Easing.OutQuint);
|
||||
yPos += panel.Item.TotalHeight;
|
||||
yPos += panel.Item!.TotalHeight;
|
||||
}
|
||||
else
|
||||
panel.MoveToY(0, 800, Easing.OutQuint);
|
||||
@ -218,7 +213,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (Item.State.Value == CarouselItemState.NotSelected)
|
||||
if (Item!.State.Value == CarouselItemState.NotSelected)
|
||||
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected));
|
||||
|
||||
if (beatmapSet.OnlineID > 0 && viewDetails != null)
|
||||
|
@ -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.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -34,9 +32,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||
Header.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
private CarouselItem item;
|
||||
private CarouselItem? item;
|
||||
|
||||
public CarouselItem Item
|
||||
public CarouselItem? Item
|
||||
{
|
||||
get => item;
|
||||
set
|
||||
@ -105,7 +103,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected virtual void UpdateItem()
|
||||
{
|
||||
if (item == null)
|
||||
if (item == null || Item == null)
|
||||
return;
|
||||
|
||||
Scheduler.AddOnce(ApplyState);
|
||||
@ -130,9 +128,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
// Use the fact that we know the precise height of the item from the model to avoid the need for AutoSize overhead.
|
||||
// Additionally, AutoSize doesn't work well due to content starting off-screen and being masked away.
|
||||
Height = Item.TotalHeight;
|
||||
|
||||
Debug.Assert(Item != null);
|
||||
Height = Item!.TotalHeight;
|
||||
|
||||
switch (Item.State.Value)
|
||||
{
|
||||
@ -162,7 +158,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
Item.State.Value = CarouselItemState.Selected;
|
||||
Item!.State.Value = CarouselItemState.Selected;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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.Framework.Input.Events;
|
||||
|
@ -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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
|
@ -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.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
@ -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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
|
Loading…
Reference in New Issue
Block a user