From d32f11b5e29c40a509a73b674160d5fbc953074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 21 Nov 2016 07:59:46 +0100 Subject: [PATCH] Smoother movement within song select. --- osu-framework | 2 +- osu.Game/Screens/Select/CarousellContainer.cs | 55 ++++++++++++++++--- osu.Game/Screens/Select/PlaySongSelect.cs | 3 - 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/osu-framework b/osu-framework index 9ed3a191bf..f839a542ee 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 9ed3a191bf76ead6ff34ac468898a0119b8e5454 +Subproject commit f839a542eed0508c2e7eeb9ba86b5c7ba0620652 diff --git a/osu.Game/Screens/Select/CarousellContainer.cs b/osu.Game/Screens/Select/CarousellContainer.cs index 4bde7838b2..37fe20a00a 100644 --- a/osu.Game/Screens/Select/CarousellContainer.cs +++ b/osu.Game/Screens/Select/CarousellContainer.cs @@ -6,6 +6,7 @@ using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps.Drawable; using osu.Game.Database; using System; @@ -18,7 +19,9 @@ namespace osu.Game.Screens.Select { private Container scrollableContent; private List groups = new List(); + public BeatmapGroup SelectedGroup { get; private set; } + public BeatmapPanel SelectedPanel { get; private set; } private Cached yPositions = new Cached(); @@ -26,9 +29,7 @@ namespace osu.Game.Screens.Select { Add(scrollableContent = new Container { - Padding = new MarginPadding { Left = 25, Top = 25, Bottom = 25 }, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, }); } @@ -43,21 +44,38 @@ namespace osu.Game.Screens.Select private void computeYPositions() { - float currentY = 0; + float currentY = DrawHeight / 2; + float selectedY = currentY; + foreach (BeatmapGroup group in groups) { - group.Header.Position = new Vector2(group.Header.Position.X, currentY); + group.Header.MoveToY(currentY, 500, EasingTypes.OutExpo); currentY += group.Header.DrawSize.Y + 5; if (group.State == BeatmapGroupState.Expanded) { foreach (BeatmapPanel panel in group.BeatmapPanels) { - panel.Position = new Vector2(panel.Position.X, currentY); - currentY += panel.DrawSize.Y + 5; + if (panel == SelectedPanel) + selectedY = currentY + panel.DrawHeight - DrawHeight / 2; + + panel.MoveToY(currentY, 500, EasingTypes.OutExpo); + currentY += panel.DrawHeight + 5; } } } + + currentY += DrawHeight / 2; + scrollableContent.Height = currentY; + + ScrollTo(selectedY); + } + + private void scrollToSelected() + { + if (SelectedPanel == null) + return; + ScrollTo(getScrollPos(SelectedPanel).Y - DrawHeight / 2); } public void SelectBeatmap(BeatmapInfo beatmap) @@ -77,6 +95,7 @@ namespace osu.Game.Screens.Select SelectedGroup = group; panel.State = PanelSelectedState.Selected; + SelectedPanel = panel; yPositions.Invalidate(); } @@ -89,6 +108,25 @@ namespace osu.Game.Screens.Select yPositions.Refresh(computeYPositions); } + private static float offsetX(Vector2 pos, Panel panel, float dist) + { + float result = 25 + dist * 0.1f; + if (!(panel is BeatmapSetHeader) || panel.State != PanelSelectedState.Selected) + result += 100; + + return result; + } + + private Vector2 getScrollPos(Panel panel) + { + return panel.Position + panel.DrawSize;; + } + + private Vector2 getDrawPos(Panel panel) + { + return panel.ToSpaceOfOtherDrawable(panel.DrawSize / 2.0f, this); + } + protected override void Update() { base.Update(); @@ -110,12 +148,11 @@ namespace osu.Game.Screens.Select continue; Vector2 panelPosLocal = panel.Position; - Vector2 panelPos = panel.ToSpaceOfOtherDrawable(panel.DrawSize / 2.0f, this); + Vector2 panelPos = getDrawPos(panel); float halfHeight = DrawSize.Y / 2; float dist = Math.Abs(panelPos.Y - halfHeight); - panel.Position = new Vector2( - (panel is BeatmapSetHeader && panel.State == PanelSelectedState.Selected ? 0 : 100) + dist * 0.1f, panelPosLocal.Y); + panel.Position = new Vector2(offsetX(panelPos, panel, dist), panelPosLocal.Y); panel.Alpha = MathHelper.Clamp(1.75f - 1.5f * dist / halfHeight, 0, 1); } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index d5b66d5bd7..dae703232a 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -105,9 +105,6 @@ namespace osu.Game.Screens.Select Roundness = 15, }, Shear = wedged_container_shear, - Children = new Drawable[] - { - }, }, new Container {