mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge pull request #22078 from mk56-spn/carousel_nullability_disabling_removal
Remove #nullable-disable from carousel and related classes
This commit is contained in:
commit
c7151ad69b
@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
var visibleBeatmapPanels = carousel.Items.OfType<DrawableCarouselBeatmap>().Where(p => p.IsPresent).ToArray();
|
||||
|
||||
return visibleBeatmapPanels.Length == 1
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item).BeatmapInfo.Ruleset.OnlineID == 0) == 1;
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item)!.BeatmapInfo.Ruleset.OnlineID == 0) == 1;
|
||||
});
|
||||
|
||||
AddStep("filter to ruleset 1", () => carousel.Filter(new FilterCriteria
|
||||
@ -86,8 +86,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
var visibleBeatmapPanels = carousel.Items.OfType<DrawableCarouselBeatmap>().Where(p => p.IsPresent).ToArray();
|
||||
|
||||
return visibleBeatmapPanels.Length == 2
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item).BeatmapInfo.Ruleset.OnlineID == 0) == 1
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item).BeatmapInfo.Ruleset.OnlineID == 1) == 1;
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item)!.BeatmapInfo.Ruleset.OnlineID == 0) == 1
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item)!.BeatmapInfo.Ruleset.OnlineID == 1) == 1;
|
||||
});
|
||||
|
||||
AddStep("filter to ruleset 2", () => carousel.Filter(new FilterCriteria
|
||||
@ -101,8 +101,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
var visibleBeatmapPanels = carousel.Items.OfType<DrawableCarouselBeatmap>().Where(p => p.IsPresent).ToArray();
|
||||
|
||||
return visibleBeatmapPanels.Length == 2
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item).BeatmapInfo.Ruleset.OnlineID == 0) == 1
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item).BeatmapInfo.Ruleset.OnlineID == 2) == 1;
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item!).BeatmapInfo.Ruleset.OnlineID == 0) == 1
|
||||
&& visibleBeatmapPanels.Count(p => ((CarouselBeatmap)p.Item!).BeatmapInfo.Ruleset.OnlineID == 2) == 1;
|
||||
});
|
||||
}
|
||||
|
||||
@ -1069,7 +1069,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
return Precision.AlmostEquals(
|
||||
carousel.ScreenSpaceDrawQuad.Centre,
|
||||
carousel.Items
|
||||
.First(i => i.Item.State.Value == CarouselItemState.Selected)
|
||||
.First(i => i.Item?.State.Value == CarouselItemState.Selected)
|
||||
.ScreenSpaceDrawQuad.Centre, 100);
|
||||
});
|
||||
}
|
||||
@ -1103,7 +1103,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
if (currentlySelected == null)
|
||||
return true;
|
||||
|
||||
return currentlySelected.Item.Visible;
|
||||
return currentlySelected.Item!.Visible;
|
||||
}
|
||||
|
||||
private void checkInvisibleDifficultiesUnselectable()
|
||||
|
@ -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())).OfType<CarouselBeatmapSet>());
|
||||
|
||||
root = newRoot;
|
||||
|
||||
@ -739,6 +739,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (var panel in Scroll.Children)
|
||||
{
|
||||
Debug.Assert(panel.Item != null);
|
||||
|
||||
if (toDisplay.Remove(panel.Item))
|
||||
{
|
||||
// panel already displayed.
|
||||
@ -770,6 +772,8 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
updateItem(item);
|
||||
|
||||
Debug.Assert(item.Item != null);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -43,7 +41,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
/// <summary>
|
||||
/// Create a fresh drawable version of this item.
|
||||
/// </summary>
|
||||
public abstract DrawableCarouselItem CreateDrawableRepresentation();
|
||||
public abstract DrawableCarouselItem? CreateDrawableRepresentation();
|
||||
|
||||
public virtual void Filter(FilterCriteria criteria)
|
||||
{
|
||||
@ -51,7 +49,12 @@ 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)
|
||||
{
|
||||
if (other == null) return 1;
|
||||
|
||||
return 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,13 +200,13 @@ 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();
|
||||
|
||||
// Only compute difficulty when the item is visible.
|
||||
if (Item.State.Value != CarouselItemState.Collapsed)
|
||||
if (Item?.State.Value != CarouselItemState.Collapsed)
|
||||
{
|
||||
// We've potentially cancelled the computation above so a new bindable is required.
|
||||
starDifficultyBindable = difficultyCache.GetBindableDifficulty(beatmapInfo, (starDifficultyCancellationSource = new CancellationTokenSource()).Token);
|
||||
|
@ -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 =>
|
||||
{
|
||||
@ -78,10 +73,11 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
// 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)
|
||||
return;
|
||||
if (!Item.Visible) return;
|
||||
|
||||
float targetY = Item.CarouselYPosition;
|
||||
|
||||
@ -151,6 +147,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private void updateBeatmapDifficulties()
|
||||
{
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
var carouselBeatmapSet = (CarouselBeatmapSet)Item;
|
||||
|
||||
var visibleBeatmaps = carouselBeatmapSet.Items.Where(c => c.Visible).ToArray();
|
||||
@ -171,7 +169,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
X = 100,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation())
|
||||
ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation()!)
|
||||
};
|
||||
|
||||
beatmapsLoadTask = LoadComponentAsync(beatmapContainer, loaded =>
|
||||
@ -196,10 +194,12 @@ 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)
|
||||
{
|
||||
Debug.Assert(panel.Item != null);
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
panel.MoveToY(yPos, 800, Easing.OutQuint);
|
||||
@ -218,7 +218,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)
|
||||
return;
|
||||
|
||||
Scheduler.AddOnce(ApplyState);
|
||||
@ -128,12 +126,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected virtual void ApplyState()
|
||||
{
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
// 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);
|
||||
|
||||
switch (Item.State.Value)
|
||||
{
|
||||
case CarouselItemState.NotSelected:
|
||||
@ -162,6 +160,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
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