mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 18:07:27 +09:00
Merge pull request #11405 from peppy/fix-carousel-centering-on-window-resize
This commit is contained in:
commit
e9282e9a2b
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Pooling;
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Layout;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -124,6 +125,8 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
BeatmapSetsChanged?.Invoke();
|
BeatmapSetsChanged?.Invoke();
|
||||||
BeatmapSetsLoaded = true;
|
BeatmapSetsLoaded = true;
|
||||||
|
|
||||||
|
itemsCache.Invalidate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,6 +570,15 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
#endregion
|
#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()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -777,13 +789,19 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
Scroll.ScrollContent.Height = currentY;
|
Scroll.ScrollContent.Height = currentY;
|
||||||
|
|
||||||
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
|
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;
|
selectedBeatmapSet = null;
|
||||||
SelectionChanged?.Invoke(null);
|
SelectionChanged?.Invoke(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
itemsCache.Validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool firstScroll = true;
|
private bool firstScroll = true;
|
||||||
@ -806,14 +824,13 @@ namespace osu.Game.Screens.Select
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PendingScrollOperation.Immediate:
|
case PendingScrollOperation.Immediate:
|
||||||
|
|
||||||
// in order to simplify animation logic, rather than using the animated version of ScrollTo,
|
// 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.
|
// 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
|
// 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.
|
// to enter clamp-special-case mode where it animates completely differently to normal.
|
||||||
float scrollChange = scrollTarget.Value - Scroll.Current;
|
float scrollChange = scrollTarget.Value - Scroll.Current;
|
||||||
|
|
||||||
Scroll.ScrollTo(scrollTarget.Value, false);
|
Scroll.ScrollTo(scrollTarget.Value, false);
|
||||||
|
|
||||||
foreach (var i in Scroll.Children)
|
foreach (var i in Scroll.Children)
|
||||||
i.Y += scrollChange;
|
i.Y += scrollChange;
|
||||||
break;
|
break;
|
||||||
|
@ -428,16 +428,21 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void updateSelectedBeatmap(BeatmapInfo beatmap)
|
private void updateSelectedBeatmap(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null && beatmapNoDebounce == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
beatmapNoDebounce = beatmap;
|
beatmapNoDebounce = beatmap;
|
||||||
|
|
||||||
performUpdateSelected();
|
performUpdateSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelectedRuleset(RulesetInfo ruleset)
|
private void updateSelectedRuleset(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
|
if (ruleset == null && rulesetNoDebounce == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ruleset?.Equals(rulesetNoDebounce) == true)
|
if (ruleset?.Equals(rulesetNoDebounce) == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user