Merge branch 'master' into fix-transform-mutation-mod-selection

This commit is contained in:
Dean Herbert
2021-01-08 11:16:15 +09:00
60 changed files with 779 additions and 684 deletions

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Layout;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
@ -124,6 +125,8 @@ namespace osu.Game.Screens.Select
{
BeatmapSetsChanged?.Invoke();
BeatmapSetsLoaded = true;
itemsCache.Invalidate();
});
}
@ -567,6 +570,15 @@ namespace osu.Game.Screens.Select
#endregion
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
{
// handles the vertical size of the carousel changing (ie. on window resize when aspect ratio has changed).
if ((invalidation & Invalidation.Layout) > 0)
itemsCache.Invalidate();
return base.OnInvalidate(invalidation, source);
}
protected override void Update()
{
base.Update();
@ -777,13 +789,19 @@ namespace osu.Game.Screens.Select
Scroll.ScrollContent.Height = currentY;
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
{
selectedBeatmapSet = null;
SelectionChanged?.Invoke(null);
}
itemsCache.Validate();
// update and let external consumers know about selection loss.
if (BeatmapSetsLoaded)
{
bool selectionLost = selectedBeatmapSet != null && selectedBeatmapSet.State.Value != CarouselItemState.Selected;
if (selectionLost)
{
selectedBeatmapSet = null;
SelectionChanged?.Invoke(null);
}
}
}
private bool firstScroll = true;
@ -806,14 +824,13 @@ namespace osu.Game.Screens.Select
break;
case PendingScrollOperation.Immediate:
// in order to simplify animation logic, rather than using the animated version of ScrollTo,
// we take the difference in scroll height and apply to all visible panels.
// this avoids edge cases like when the visible panels is reduced suddenly, causing ScrollContainer
// to enter clamp-special-case mode where it animates completely differently to normal.
float scrollChange = scrollTarget.Value - Scroll.Current;
Scroll.ScrollTo(scrollTarget.Value, false);
foreach (var i in Scroll.Children)
i.Y += scrollChange;
break;
@ -919,7 +936,6 @@ namespace osu.Game.Screens.Select
Masking = false;
}
// ReSharper disable once OptionalParameterHierarchyMismatch 2020.3 EAP4 bug. (https://youtrack.jetbrains.com/issue/RSRP-481535?p=RIDER-51910)
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
{
UserScrolling = true;

View File

@ -63,8 +63,6 @@ namespace osu.Game.Screens.Select
public BeatmapDetails()
{
Container content;
Children = new Drawable[]
{
new Box
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
content = new Container
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = spacing },
@ -159,7 +157,7 @@ namespace osu.Game.Screens.Select
},
},
},
loading = new LoadingLayer(content),
loading = new LoadingLayer(true),
};
}

View File

@ -5,6 +5,8 @@ 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;
@ -36,10 +38,14 @@ namespace osu.Game.Screens.Select.Carousel
public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.Children ?? Enumerable.Empty<DrawableCarouselItem>();
[CanBeNull]
private Container<DrawableCarouselItem> beatmapContainer;
private BeatmapSetInfo beatmapSet;
[CanBeNull]
private Task beatmapsLoadTask;
[Resolved]
private BeatmapManager manager { get; set; }
@ -85,7 +91,9 @@ namespace osu.Game.Screens.Select.Carousel
base.UpdateItem();
Content.Clear();
beatmapContainer = null;
beatmapsLoadTask = null;
if (Item == null)
return;
@ -122,11 +130,7 @@ namespace osu.Game.Screens.Select.Carousel
MovementContainer.MoveToX(0, 500, Easing.OutExpo);
if (beatmapContainer != null)
{
foreach (var beatmap in beatmapContainer)
beatmap.MoveToY(0, 800, Easing.OutQuint);
}
updateBeatmapYPositions();
}
protected override void Selected()
@ -163,7 +167,7 @@ namespace osu.Game.Screens.Select.Carousel
ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation())
};
LoadComponentAsync(beatmapContainer, loaded =>
beatmapsLoadTask = LoadComponentAsync(beatmapContainer, loaded =>
{
// make sure the pooled target hasn't changed.
if (beatmapContainer != loaded)
@ -173,16 +177,29 @@ namespace osu.Game.Screens.Select.Carousel
updateBeatmapYPositions();
});
}
}
void updateBeatmapYPositions()
private void updateBeatmapYPositions()
{
if (beatmapContainer == null)
return;
if (beatmapsLoadTask == null || !beatmapsLoadTask.IsCompleted)
return;
float yPos = DrawableCarouselBeatmap.CAROUSEL_BEATMAP_SPACING;
bool isSelected = Item.State.Value == CarouselItemState.Selected;
foreach (var panel in beatmapContainer.Children)
{
float yPos = DrawableCarouselBeatmap.CAROUSEL_BEATMAP_SPACING;
foreach (var panel in beatmapContainer.Children)
if (isSelected)
{
panel.MoveToY(yPos, 800, Easing.OutQuint);
yPos += panel.Item.TotalHeight;
}
else
panel.MoveToY(0, 800, Easing.OutQuint);
}
}

View File

@ -19,7 +19,6 @@ using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Select.Options;
@ -38,10 +37,11 @@ using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
using System.Diagnostics;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.Select
{
public abstract class SongSelect : OsuScreen, IKeyBindingHandler<GlobalAction>
public abstract class SongSelect : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>
{
public static readonly float WEDGE_HEIGHT = 245;
@ -76,8 +76,6 @@ namespace osu.Game.Screens.Select
[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected BeatmapCarousel Carousel { get; private set; }
private BeatmapInfoWedge beatmapInfoWedge;
@ -428,16 +426,21 @@ namespace osu.Game.Screens.Select
private void updateSelectedBeatmap(BeatmapInfo beatmap)
{
if (beatmap == null && beatmapNoDebounce == null)
return;
if (beatmap?.Equals(beatmapNoDebounce) == true)
return;
beatmapNoDebounce = beatmap;
performUpdateSelected();
}
private void updateSelectedRuleset(RulesetInfo ruleset)
{
if (ruleset == null && rulesetNoDebounce == null)
return;
if (ruleset?.Equals(rulesetNoDebounce) == true)
return;
@ -684,12 +687,12 @@ namespace osu.Game.Screens.Select
/// <param name="beatmap">The working beatmap.</param>
private void updateComponentFromBeatmap(WorkingBeatmap beatmap)
{
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
ApplyToBackground(backgroundModeBeatmap =>
{
backgroundModeBeatmap.Beatmap = beatmap;
backgroundModeBeatmap.BlurAmount.Value = BACKGROUND_BLUR;
backgroundModeBeatmap.FadeColour(Color4.White, 250);
}
});
beatmapInfoWedge.Beatmap = beatmap;