From c4bed0e6d29944cb6045267a3a4fdd17cf40bf34 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 25 Jul 2019 15:31:21 +0900 Subject: [PATCH 1/7] Resize BeatmapCarousel, update carouselitem logic --- osu.Game/Screens/Select/BeatmapCarousel.cs | 21 +++++++++------- osu.Game/Screens/Select/FilterControl.cs | 6 ----- osu.Game/Screens/Select/SongSelect.cs | 28 +++++++++++++++------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 16354534f4..938ae1c028 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -108,10 +108,12 @@ namespace osu.Game.Screens.Select root = new CarouselRoot(this); Child = new OsuContextMenuContainer { + Masking = false, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Child = scrollableContent = new Container { + Masking = false, RelativeSizeAxes = Axes.X, } }; @@ -424,7 +426,9 @@ namespace osu.Game.Screens.Select if (!scrollPositionCache.IsValid) updateScrollPosition(); - float drawHeight = DrawHeight; + // The draw positions of individual sets extend beyond the size of the carousel and into its parent + // As a result, this should use the Parent's draw height instead. + float drawHeight = Parent.DrawHeight; // Remove all items that should no longer be on-screen scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + drawHeight || !p.IsPresent); @@ -432,9 +436,9 @@ namespace osu.Game.Screens.Select // Find index range of all items that should be on-screen Trace.Assert(Items.Count == yPositions.Count); - int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT); + int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - Parent.Padding.Top); if (firstIndex < 0) firstIndex = ~firstIndex; - int lastIndex = yPositions.BinarySearch(Current + drawHeight); + int lastIndex = yPositions.BinarySearch(Current + drawHeight + Parent.Padding.Bottom); if (lastIndex < 0) lastIndex = ~lastIndex; int notVisibleCount = 0; @@ -637,18 +641,19 @@ namespace osu.Game.Screens.Select /// the current scroll position. /// /// The item to be updated. - /// Half the draw height of the carousel container. - private void updateItem(DrawableCarouselItem p, float halfHeight) + /// Half the draw height of the carousel container's parent. + private void updateItem(DrawableCarouselItem p, float parentHalfHeight) { var height = p.IsPresent ? p.DrawHeight : 0; - float itemDrawY = p.Position.Y - Current + height / 2; - float dist = Math.Abs(1f - itemDrawY / halfHeight); + // The actual Y position of the item needs to be offset by any potential padding set by the container's parent. + float itemDrawY = p.Position.Y - Current + Parent.Padding.Top + height / 2; + float dist = Math.Abs(1f - itemDrawY / parentHalfHeight); // Setting the origin position serves as an additive position on top of potential // local transformation we may want to apply (e.g. when a item gets selected, we // may want to smoothly transform it leftwards.) - p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0); + p.OriginPosition = new Vector2(-offsetX(dist, parentHalfHeight), 0); // We are applying a multiplicative alpha (which is internally done by nesting an // additional container and setting that container's alpha) such that we can diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 57fe15fd99..97ba1cce6b 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -187,11 +187,5 @@ namespace osu.Game.Screens.Select } private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); - - protected override bool OnMouseDown(MouseDownEvent e) => true; - - protected override bool OnMouseMove(MouseMoveEvent e) => true; - - protected override bool OnClick(ClickEvent e) => true; } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 20dbcf2693..011c62f0eb 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -45,6 +45,7 @@ namespace osu.Game.Screens.Select protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; + private const float filter_control_height = 100; public readonly FilterControl FilterControl; @@ -121,7 +122,7 @@ namespace osu.Game.Screens.Select Size = new Vector2(wedged_container_size.X, 1), Padding = new MarginPadding { - Bottom = 50, + Bottom = Footer.HEIGHT, Top = wedged_container_size.Y + left_area_padding, Left = left_area_padding, Right = left_area_padding * 2, @@ -147,20 +148,29 @@ namespace osu.Game.Screens.Select Width = 0.5f, Children = new Drawable[] { - Carousel = new BeatmapCarousel + new Container { - Masking = false, RelativeSizeAxes = Axes.Both, - Size = new Vector2(1 - wedged_container_size.X, 1), - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - SelectionChanged = updateSelectedBeatmap, - BeatmapSetsChanged = carouselBeatmapsLoaded, + Padding = new MarginPadding + { + Top = filter_control_height, + Bottom = Footer.HEIGHT + }, + Child = Carousel = new BeatmapCarousel + { + Masking = false, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1 - wedged_container_size.X, 1), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + SelectionChanged = updateSelectedBeatmap, + BeatmapSetsChanged = carouselBeatmapsLoaded, + }, }, FilterControl = new FilterControl { RelativeSizeAxes = Axes.X, - Height = 100, + Height = filter_control_height, FilterChanged = c => Carousel.Filter(c), Background = { Width = 2 }, Exit = () => From 97eb5293a87102dbf918bd4b69ca0486937abd03 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 25 Jul 2019 17:32:21 +0900 Subject: [PATCH 2/7] Don't depend on parent sizing --- osu.Game/Screens/Select/BeatmapCarousel.cs | 28 +++++++++++----------- osu.Game/Screens/Select/FilterControl.cs | 1 - osu.Game/Screens/Select/Footer.cs | 4 ---- osu.Game/Screens/Select/SongSelect.cs | 21 ++++++++++------ 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 938ae1c028..e4b75a3540 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -426,19 +426,18 @@ namespace osu.Game.Screens.Select if (!scrollPositionCache.IsValid) updateScrollPosition(); - // The draw positions of individual sets extend beyond the size of the carousel and into its parent - // As a result, this should use the Parent's draw height instead. - float drawHeight = Parent.DrawHeight; + // The draw positions of individual sets extend beyond the size of the carousel and into the footer and header. + float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT; // Remove all items that should no longer be on-screen - scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + drawHeight || !p.IsPresent); + scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent); // Find index range of all items that should be on-screen Trace.Assert(Items.Count == yPositions.Count); - int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - Parent.Padding.Top); + int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - SongSelect.FILTER_CONTROL_HEIGHT); if (firstIndex < 0) firstIndex = ~firstIndex; - int lastIndex = yPositions.BinarySearch(Current + drawHeight + Parent.Padding.Bottom); + int lastIndex = yPositions.BinarySearch(Current + visibleHeight + SongSelect.FOOTER_HEIGHT); if (lastIndex < 0) lastIndex = ~lastIndex; int notVisibleCount = 0; @@ -490,7 +489,7 @@ namespace osu.Game.Screens.Select // Update externally controlled state of currently visible items // (e.g. x-offset and opacity). - float halfHeight = drawHeight / 2; + float halfHeight = visibleHeight / 2; foreach (DrawableCarouselItem p in scrollableContent.Children) updateItem(p, halfHeight); } @@ -546,7 +545,8 @@ namespace osu.Game.Screens.Select yPositions.Clear(); - float currentY = DrawHeight / 2; + float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT; + float currentY = visibleHeight / 2; DrawableCarouselBeatmapSet lastSet = null; scrollTarget = null; @@ -600,7 +600,7 @@ namespace osu.Game.Screens.Select currentY += d.DrawHeight + 5; } - currentY += DrawHeight / 2; + currentY += visibleHeight / 2; scrollableContent.Height = currentY; if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) @@ -641,19 +641,19 @@ namespace osu.Game.Screens.Select /// the current scroll position. /// /// The item to be updated. - /// Half the draw height of the carousel container's parent. - private void updateItem(DrawableCarouselItem p, float parentHalfHeight) + /// Half the draw height of the carousel container's parent. + private void updateItem(DrawableCarouselItem p, float halfHeight) { var height = p.IsPresent ? p.DrawHeight : 0; // The actual Y position of the item needs to be offset by any potential padding set by the container's parent. - float itemDrawY = p.Position.Y - Current + Parent.Padding.Top + height / 2; - float dist = Math.Abs(1f - itemDrawY / parentHalfHeight); + float itemDrawY = p.Position.Y + SongSelect.FILTER_CONTROL_HEIGHT - Current + height / 2; + float dist = Math.Abs(1f - itemDrawY / halfHeight); // Setting the origin position serves as an additive position on top of potential // local transformation we may want to apply (e.g. when a item gets selected, we // may want to smoothly transform it leftwards.) - p.OriginPosition = new Vector2(-offsetX(dist, parentHalfHeight), 0); + p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0); // We are applying a multiplicative alpha (which is internally done by nesting an // additional container and setting that container's alpha) such that we can diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 97ba1cce6b..31b71a21c8 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -14,7 +14,6 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Select.Filter; using Container = osu.Framework.Graphics.Containers.Container; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; using osu.Game.Configuration; using osu.Game.Rulesets; diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 0680711f1c..7db3d65a0b 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -62,10 +62,6 @@ namespace osu.Game.Screens.Select public Footer() { - RelativeSizeAxes = Axes.X; - Height = HEIGHT; - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; Children = new Drawable[] { new Box diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 011c62f0eb..e5576f78cf 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -43,9 +43,10 @@ namespace osu.Game.Screens.Select { private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); + public const float FILTER_CONTROL_HEIGHT = 100; + public const float FOOTER_HEIGHT = 50; protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; - private const float filter_control_height = 100; public readonly FilterControl FilterControl; @@ -122,7 +123,7 @@ namespace osu.Game.Screens.Select Size = new Vector2(wedged_container_size.X, 1), Padding = new MarginPadding { - Bottom = Footer.HEIGHT, + Bottom = FOOTER_HEIGHT, Top = wedged_container_size.Y + left_area_padding, Left = left_area_padding, Right = left_area_padding * 2, @@ -153,8 +154,8 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { - Top = filter_control_height, - Bottom = Footer.HEIGHT + Top = FILTER_CONTROL_HEIGHT, + Bottom = FOOTER_HEIGHT }, Child = Carousel = new BeatmapCarousel { @@ -170,7 +171,7 @@ namespace osu.Game.Screens.Select FilterControl = new FilterControl { RelativeSizeAxes = Axes.X, - Height = filter_control_height, + Height = FILTER_CONTROL_HEIGHT, FilterChanged = c => Carousel.Filter(c), Background = { Width = 2 }, Exit = () => @@ -209,7 +210,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = Footer.HEIGHT }, + Margin = new MarginPadding { Bottom = FOOTER_HEIGHT }, Children = new Drawable[] { BeatmapOptions = new BeatmapOptionsOverlay(), @@ -221,7 +222,13 @@ namespace osu.Game.Screens.Select } } }, - Footer = new Footer() + Footer = new Footer + { + RelativeSizeAxes = Axes.X, + Height = FOOTER_HEIGHT, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + } }); } From a9f0dda9d7ec20b4a0492f670c02e03be26e4a1b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 25 Jul 2019 17:36:13 +0900 Subject: [PATCH 3/7] Confine positional input --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e4b75a3540..b917fc4bb4 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -53,6 +53,8 @@ namespace osu.Game.Screens.Select public override bool HandleNonPositionalInput => AllowSelection; public override bool HandlePositionalInput => AllowSelection; + protected override bool ConfinePositionalInput => true; + /// /// Whether carousel items have completed asynchronously loaded. /// From c89830f3d89cd1bd2baa0e1731d8f67bf1147b94 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 26 Jul 2019 13:07:28 +0900 Subject: [PATCH 4/7] move constants, combine local vars into properties --- osu.Game/Screens/Select/BeatmapCarousel.cs | 22 ++++++++++++---------- osu.Game/Screens/Select/FilterControl.cs | 2 ++ osu.Game/Screens/Select/Footer.cs | 4 ++++ osu.Game/Screens/Select/SongSelect.cs | 22 +++++++--------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index b917fc4bb4..44aebf73c9 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -26,6 +26,9 @@ namespace osu.Game.Screens.Select { public class BeatmapCarousel : OsuScrollContainer { + private const float bleed_top = FilterControl.HEIGHT; + private const float bleed_bottom = Footer.HEIGHT; + /// /// Triggered when the loaded change and are completely loaded. /// @@ -110,12 +113,10 @@ namespace osu.Game.Screens.Select root = new CarouselRoot(this); Child = new OsuContextMenuContainer { - Masking = false, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Child = scrollableContent = new Container { - Masking = false, RelativeSizeAxes = Axes.X, } }; @@ -342,6 +343,12 @@ namespace osu.Game.Screens.Select public bool AllowSelection = true; + /// + /// The total bounds of what is displayable in the beatmap carousel. + /// + /// + private float visibleHeight => DrawHeight + bleed_bottom + bleed_top; + public void FlushPendingFilterOperations() { if (PendingFilter?.Completed == false) @@ -428,18 +435,15 @@ namespace osu.Game.Screens.Select if (!scrollPositionCache.IsValid) updateScrollPosition(); - // The draw positions of individual sets extend beyond the size of the carousel and into the footer and header. - float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT; - // Remove all items that should no longer be on-screen scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent); // Find index range of all items that should be on-screen Trace.Assert(Items.Count == yPositions.Count); - int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - SongSelect.FILTER_CONTROL_HEIGHT); + int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - bleed_top); if (firstIndex < 0) firstIndex = ~firstIndex; - int lastIndex = yPositions.BinarySearch(Current + visibleHeight + SongSelect.FOOTER_HEIGHT); + int lastIndex = yPositions.BinarySearch(Current + visibleHeight + bleed_bottom); if (lastIndex < 0) lastIndex = ~lastIndex; int notVisibleCount = 0; @@ -547,7 +551,6 @@ namespace osu.Game.Screens.Select yPositions.Clear(); - float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT; float currentY = visibleHeight / 2; DrawableCarouselBeatmapSet lastSet = null; @@ -648,8 +651,7 @@ namespace osu.Game.Screens.Select { var height = p.IsPresent ? p.DrawHeight : 0; - // The actual Y position of the item needs to be offset by any potential padding set by the container's parent. - float itemDrawY = p.Position.Y + SongSelect.FILTER_CONTROL_HEIGHT - Current + height / 2; + float itemDrawY = p.Position.Y + bleed_top - Current + height / 2; float dist = Math.Abs(1f - itemDrawY / halfHeight); // Setting the origin position serves as an additive position on top of potential diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 31b71a21c8..84e8e90f54 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -21,6 +21,8 @@ namespace osu.Game.Screens.Select { public class FilterControl : Container { + public const float HEIGHT = 100; + public Action FilterChanged; private readonly OsuTabControl sortTabs; diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 7db3d65a0b..0680711f1c 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -62,6 +62,10 @@ namespace osu.Game.Screens.Select public Footer() { + RelativeSizeAxes = Axes.X; + Height = HEIGHT; + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; Children = new Drawable[] { new Box diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e5576f78cf..73848cc740 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -42,9 +42,7 @@ namespace osu.Game.Screens.Select public abstract class SongSelect : OsuScreen, IKeyBindingHandler { private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); - - public const float FILTER_CONTROL_HEIGHT = 100; - public const float FOOTER_HEIGHT = 50; + protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; @@ -123,7 +121,7 @@ namespace osu.Game.Screens.Select Size = new Vector2(wedged_container_size.X, 1), Padding = new MarginPadding { - Bottom = FOOTER_HEIGHT, + Bottom = Footer.HEIGHT, Top = wedged_container_size.Y + left_area_padding, Left = left_area_padding, Right = left_area_padding * 2, @@ -154,8 +152,8 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { - Top = FILTER_CONTROL_HEIGHT, - Bottom = FOOTER_HEIGHT + Top = FilterControl.HEIGHT, + Bottom = Footer.HEIGHT }, Child = Carousel = new BeatmapCarousel { @@ -171,7 +169,7 @@ namespace osu.Game.Screens.Select FilterControl = new FilterControl { RelativeSizeAxes = Axes.X, - Height = FILTER_CONTROL_HEIGHT, + Height = FilterControl.HEIGHT, FilterChanged = c => Carousel.Filter(c), Background = { Width = 2 }, Exit = () => @@ -210,7 +208,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = FOOTER_HEIGHT }, + Margin = new MarginPadding { Bottom = Footer.HEIGHT }, Children = new Drawable[] { BeatmapOptions = new BeatmapOptionsOverlay(), @@ -222,13 +220,7 @@ namespace osu.Game.Screens.Select } } }, - Footer = new Footer - { - RelativeSizeAxes = Axes.X, - Height = FOOTER_HEIGHT, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - } + Footer = new Footer() }); } From 6765e9f7fa6a6d0dbfb75aa2e012ac18eef3e99c Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 26 Jul 2019 15:13:10 +0900 Subject: [PATCH 5/7] Combine into properties and update for framework changes --- osu.Game/Screens/Select/BeatmapCarousel.cs | 32 ++++++++++++++-------- osu.Game/Screens/Select/SongSelect.cs | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 44aebf73c9..c8746579b5 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -56,8 +56,6 @@ namespace osu.Game.Screens.Select public override bool HandleNonPositionalInput => AllowSelection; public override bool HandlePositionalInput => AllowSelection; - protected override bool ConfinePositionalInput => true; - /// /// Whether carousel items have completed asynchronously loaded. /// @@ -344,11 +342,24 @@ namespace osu.Game.Screens.Select public bool AllowSelection = true; /// - /// The total bounds of what is displayable in the beatmap carousel. - /// + /// The total height of the displayable portion of the Beatmap Carousel. + /// + /// This is different from , since + /// the beatmap carousel bleeds into the and the + /// /// private float visibleHeight => DrawHeight + bleed_bottom + bleed_top; + /// + /// The position of the lower visible bound with respect to the current scroll position. + /// + private float visibleBottomBound => Current + DrawHeight + bleed_bottom; + + /// + /// The position of the upper visible bound with respect to the current scroll position. + /// + private float visibleUpperBound => Current - bleed_top; + public void FlushPendingFilterOperations() { if (PendingFilter?.Completed == false) @@ -425,6 +436,8 @@ namespace osu.Game.Screens.Select return true; } + protected override bool ReceiveSubTreePositionalInputAt(Vector2 screenSpacePos) => ReceivePositionalInputAt(screenSpacePos); + protected override void Update() { base.Update(); @@ -436,14 +449,14 @@ namespace osu.Game.Screens.Select updateScrollPosition(); // Remove all items that should no longer be on-screen - scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent); + scrollableContent.RemoveAll(p => p.Y < visibleUpperBound - p.DrawHeight || p.Y > visibleBottomBound || !p.IsPresent); // Find index range of all items that should be on-screen Trace.Assert(Items.Count == yPositions.Count); - int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - bleed_top); + int firstIndex = yPositions.BinarySearch(visibleUpperBound - DrawableCarouselItem.MAX_HEIGHT); if (firstIndex < 0) firstIndex = ~firstIndex; - int lastIndex = yPositions.BinarySearch(Current + visibleHeight + bleed_bottom); + int lastIndex = yPositions.BinarySearch(visibleBottomBound); if (lastIndex < 0) lastIndex = ~lastIndex; int notVisibleCount = 0; @@ -584,7 +597,6 @@ namespace osu.Game.Screens.Select float? setY = null; if (!d.IsLoaded || beatmap.Alpha == 0) // can't use IsPresent due to DrawableCarouselItem override. - // ReSharper disable once PossibleNullReferenceException (resharper broken?) setY = lastSet.Y + lastSet.DrawHeight + 5; if (d.IsLoaded) @@ -649,9 +661,7 @@ namespace osu.Game.Screens.Select /// Half the draw height of the carousel container's parent. private void updateItem(DrawableCarouselItem p, float halfHeight) { - var height = p.IsPresent ? p.DrawHeight : 0; - - float itemDrawY = p.Position.Y + bleed_top - Current + height / 2; + float itemDrawY = p.Position.Y - visibleUpperBound + p.DrawHeight / 2; float dist = Math.Abs(1f - itemDrawY / halfHeight); // Setting the origin position serves as an additive position on top of potential diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 73848cc740..7dd934f91a 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select public abstract class SongSelect : OsuScreen, IKeyBindingHandler { private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); - + protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; From 0f6c6c7de0b981ab517e35b3f1a1f2c9aae31315 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 26 Jul 2019 15:22:29 +0900 Subject: [PATCH 6/7] consolidate halfheight as well --- osu.Game/Screens/Select/BeatmapCarousel.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index c8746579b5..cbe54cce1a 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -342,13 +342,13 @@ namespace osu.Game.Screens.Select public bool AllowSelection = true; /// - /// The total height of the displayable portion of the Beatmap Carousel. + /// Half the height of the visible content. /// - /// This is different from , since + /// This is different from the height of , since /// the beatmap carousel bleeds into the and the /// /// - private float visibleHeight => DrawHeight + bleed_bottom + bleed_top; + private float visibleHalfHeight => (DrawHeight + bleed_bottom + bleed_top) / 2; /// /// The position of the lower visible bound with respect to the current scroll position. @@ -508,9 +508,8 @@ namespace osu.Game.Screens.Select // Update externally controlled state of currently visible items // (e.g. x-offset and opacity). - float halfHeight = visibleHeight / 2; foreach (DrawableCarouselItem p in scrollableContent.Children) - updateItem(p, halfHeight); + updateItem(p); } protected override void Dispose(bool isDisposing) @@ -564,7 +563,7 @@ namespace osu.Game.Screens.Select yPositions.Clear(); - float currentY = visibleHeight / 2; + float currentY = visibleHalfHeight; DrawableCarouselBeatmapSet lastSet = null; scrollTarget = null; @@ -617,7 +616,7 @@ namespace osu.Game.Screens.Select currentY += d.DrawHeight + 5; } - currentY += visibleHeight / 2; + currentY += visibleHalfHeight; scrollableContent.Height = currentY; if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) @@ -658,16 +657,15 @@ namespace osu.Game.Screens.Select /// the current scroll position. /// /// The item to be updated. - /// Half the draw height of the carousel container's parent. - private void updateItem(DrawableCarouselItem p, float halfHeight) + private void updateItem(DrawableCarouselItem p) { float itemDrawY = p.Position.Y - visibleUpperBound + p.DrawHeight / 2; - float dist = Math.Abs(1f - itemDrawY / halfHeight); + float dist = Math.Abs(1f - itemDrawY / visibleHalfHeight); // Setting the origin position serves as an additive position on top of potential // local transformation we may want to apply (e.g. when a item gets selected, we // may want to smoothly transform it leftwards.) - p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0); + p.OriginPosition = new Vector2(-offsetX(dist, visibleHalfHeight), 0); // We are applying a multiplicative alpha (which is internally done by nesting an // additional container and setting that container's alpha) such that we can From 3571cb96b0b923405beeccfd4f306f55f3be7b6a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 27 Jul 2019 12:56:55 +0900 Subject: [PATCH 7/7] Fix broken merge --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 40079f01e4..cf88b697d9 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -434,7 +434,7 @@ namespace osu.Game.Screens.Select return true; } - protected override bool ReceiveSubTreePositionalInputAt(Vector2 screenSpacePos) => ReceivePositionalInputAt(screenSpacePos); + protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => ReceivePositionalInputAt(screenSpacePos); protected override void Update() {