Smoother movement within song select.

This commit is contained in:
Thomas Müller 2016-11-21 07:59:46 +01:00
parent ac8c180168
commit d32f11b5e2
3 changed files with 47 additions and 13 deletions

@ -1 +1 @@
Subproject commit 9ed3a191bf76ead6ff34ac468898a0119b8e5454 Subproject commit f839a542eed0508c2e7eeb9ba86b5c7ba0620652

View File

@ -6,6 +6,7 @@ using osu.Framework.Caching;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Drawable; using osu.Game.Beatmaps.Drawable;
using osu.Game.Database; using osu.Game.Database;
using System; using System;
@ -18,7 +19,9 @@ namespace osu.Game.Screens.Select
{ {
private Container<Panel> scrollableContent; private Container<Panel> scrollableContent;
private List<BeatmapGroup> groups = new List<BeatmapGroup>(); private List<BeatmapGroup> groups = new List<BeatmapGroup>();
public BeatmapGroup SelectedGroup { get; private set; } public BeatmapGroup SelectedGroup { get; private set; }
public BeatmapPanel SelectedPanel { get; private set; }
private Cached yPositions = new Cached(); private Cached yPositions = new Cached();
@ -26,9 +29,7 @@ namespace osu.Game.Screens.Select
{ {
Add(scrollableContent = new Container<Panel> Add(scrollableContent = new Container<Panel>
{ {
Padding = new MarginPadding { Left = 25, Top = 25, Bottom = 25 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}); });
} }
@ -43,21 +44,38 @@ namespace osu.Game.Screens.Select
private void computeYPositions() private void computeYPositions()
{ {
float currentY = 0; float currentY = DrawHeight / 2;
float selectedY = currentY;
foreach (BeatmapGroup group in groups) 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; currentY += group.Header.DrawSize.Y + 5;
if (group.State == BeatmapGroupState.Expanded) if (group.State == BeatmapGroupState.Expanded)
{ {
foreach (BeatmapPanel panel in group.BeatmapPanels) foreach (BeatmapPanel panel in group.BeatmapPanels)
{ {
panel.Position = new Vector2(panel.Position.X, currentY); if (panel == SelectedPanel)
currentY += panel.DrawSize.Y + 5; 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) public void SelectBeatmap(BeatmapInfo beatmap)
@ -77,6 +95,7 @@ namespace osu.Game.Screens.Select
SelectedGroup = group; SelectedGroup = group;
panel.State = PanelSelectedState.Selected; panel.State = PanelSelectedState.Selected;
SelectedPanel = panel;
yPositions.Invalidate(); yPositions.Invalidate();
} }
@ -89,6 +108,25 @@ namespace osu.Game.Screens.Select
yPositions.Refresh(computeYPositions); 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() protected override void Update()
{ {
base.Update(); base.Update();
@ -110,12 +148,11 @@ namespace osu.Game.Screens.Select
continue; continue;
Vector2 panelPosLocal = panel.Position; Vector2 panelPosLocal = panel.Position;
Vector2 panelPos = panel.ToSpaceOfOtherDrawable(panel.DrawSize / 2.0f, this); Vector2 panelPos = getDrawPos(panel);
float halfHeight = DrawSize.Y / 2; float halfHeight = DrawSize.Y / 2;
float dist = Math.Abs(panelPos.Y - halfHeight); float dist = Math.Abs(panelPos.Y - halfHeight);
panel.Position = new Vector2( panel.Position = new Vector2(offsetX(panelPos, panel, dist), panelPosLocal.Y);
(panel is BeatmapSetHeader && panel.State == PanelSelectedState.Selected ? 0 : 100) + dist * 0.1f, panelPosLocal.Y);
panel.Alpha = MathHelper.Clamp(1.75f - 1.5f * dist / halfHeight, 0, 1); panel.Alpha = MathHelper.Clamp(1.75f - 1.5f * dist / halfHeight, 0, 1);
} }

View File

@ -105,9 +105,6 @@ namespace osu.Game.Screens.Select
Roundness = 15, Roundness = 15,
}, },
Shear = wedged_container_shear, Shear = wedged_container_shear,
Children = new Drawable[]
{
},
}, },
new Container new Container
{ {