mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 12:22:57 +08:00
Only handle beatmap panels that are visible in song select.
This commit is contained in:
parent
ba1d3ab20e
commit
9bf23bc4ad
@ -46,7 +46,10 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
// Task.WhenAll(difficulties.Children.Select(d => d.Preload(Game))).ContinueWith(t => difficulties.Show());
|
// Task.WhenAll(difficulties.Children.Select(d => d.Preload(Game))).ContinueWith(t => difficulties.Show());
|
||||||
//else
|
//else
|
||||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||||
panel.Show();
|
{
|
||||||
|
panel.Hidden = false;
|
||||||
|
panel.FadeIn(250);
|
||||||
|
}
|
||||||
|
|
||||||
Header.State = PanelSelectedState.Selected;
|
Header.State = PanelSelectedState.Selected;
|
||||||
if (SelectedPanel != null)
|
if (SelectedPanel != null)
|
||||||
@ -58,7 +61,10 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
SelectedPanel.State = PanelSelectedState.NotSelected;
|
SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||||
|
|
||||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||||
panel.Hide();
|
{
|
||||||
|
panel.Hidden = true;
|
||||||
|
panel.FadeOut(250);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
Hidden = false;
|
||||||
|
|
||||||
Children = new Framework.Graphics.Drawable[]
|
Children = new Framework.Graphics.Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -17,15 +12,32 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
{
|
{
|
||||||
class Panel : Container, IStateful<PanelSelectedState>
|
class Panel : Container, IStateful<PanelSelectedState>
|
||||||
{
|
{
|
||||||
|
public const float MAX_HEIGHT = 80;
|
||||||
|
|
||||||
|
public bool Hidden = true;
|
||||||
|
private Container nestedContainer;
|
||||||
|
|
||||||
|
protected override Container<Framework.Graphics.Drawable> Content => nestedContainer;
|
||||||
|
|
||||||
public Panel()
|
public Panel()
|
||||||
{
|
{
|
||||||
Height = 80;
|
Height = MAX_HEIGHT;
|
||||||
|
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 10;
|
CornerRadius = 10;
|
||||||
BorderColour = new Color4(221, 255, 255, 255);
|
BorderColour = new Color4(221, 255, 255, 255);
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
AddInternal(nestedContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMultiplicativeAlpha(float alpha)
|
||||||
|
{
|
||||||
|
nestedContainer.Alpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -18,12 +18,14 @@ 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>();
|
||||||
|
private List<Panel> panels = new List<Panel>();
|
||||||
|
|
||||||
public BeatmapGroup SelectedGroup { get; private set; }
|
public BeatmapGroup SelectedGroup { get; private set; }
|
||||||
public BeatmapPanel SelectedPanel { get; private set; }
|
public BeatmapPanel SelectedPanel { get; private set; }
|
||||||
|
|
||||||
private Cached yPositions = new Cached();
|
private Cached yPositionsCached = new Cached();
|
||||||
|
private List<float> yPositions = new List<float>();
|
||||||
|
|
||||||
public CarouselContainer()
|
public CarouselContainer()
|
||||||
{
|
{
|
||||||
DistanceDecayJump = 0.01;
|
DistanceDecayJump = 0.01;
|
||||||
@ -39,25 +41,32 @@ namespace osu.Game.Screens.Select
|
|||||||
group.State = BeatmapGroupState.Collapsed;
|
group.State = BeatmapGroupState.Collapsed;
|
||||||
|
|
||||||
groups.Add(group);
|
groups.Add(group);
|
||||||
|
panels.Add(group.Header);
|
||||||
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
|
panels.Add(panel);
|
||||||
|
|
||||||
yPositions.Invalidate();
|
yPositionsCached.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addPanel(Panel panel, ref float currentY)
|
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||||
{
|
{
|
||||||
panel.Depth = -currentY;
|
yPositions.Add(currentY);
|
||||||
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||||
currentY += panel.DrawHeight + 5;
|
|
||||||
|
if (advance)
|
||||||
|
currentY += panel.DrawHeight + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeYPositions()
|
private void computeYPositions()
|
||||||
{
|
{
|
||||||
|
yPositions.Clear();
|
||||||
|
|
||||||
float currentY = DrawHeight / 2;
|
float currentY = DrawHeight / 2;
|
||||||
float selectedY = currentY;
|
float selectedY = currentY;
|
||||||
|
|
||||||
foreach (BeatmapGroup group in groups)
|
foreach (BeatmapGroup group in groups)
|
||||||
{
|
{
|
||||||
addPanel(group.Header, ref currentY);
|
movePanel(group.Header, true, ref currentY);
|
||||||
|
|
||||||
if (group.State == BeatmapGroupState.Expanded)
|
if (group.State == BeatmapGroupState.Expanded)
|
||||||
{
|
{
|
||||||
@ -66,14 +75,17 @@ namespace osu.Game.Screens.Select
|
|||||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
{
|
{
|
||||||
if (panel == SelectedPanel)
|
if (panel == SelectedPanel)
|
||||||
selectedY = currentY + 1.5f * panel.DrawHeight - DrawHeight / 2;
|
selectedY = currentY + panel.DrawHeight / 2 - DrawHeight / 2;
|
||||||
|
|
||||||
addPanel(panel, ref currentY);
|
movePanel(panel, true, ref currentY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
group.Header.MoveToX(0, 500, EasingTypes.OutExpo);
|
group.Header.MoveToX(0, 500, EasingTypes.OutExpo);
|
||||||
|
|
||||||
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
|
movePanel(panel, false, ref currentY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +95,6 @@ namespace osu.Game.Screens.Select
|
|||||||
ScrollTo(selectedY);
|
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)
|
||||||
{
|
{
|
||||||
foreach (BeatmapGroup group in groups)
|
foreach (BeatmapGroup group in groups)
|
||||||
@ -116,18 +121,18 @@ namespace osu.Game.Screens.Select
|
|||||||
panel.State = PanelSelectedState.Selected;
|
panel.State = PanelSelectedState.Selected;
|
||||||
SelectedPanel = panel;
|
SelectedPanel = panel;
|
||||||
|
|
||||||
yPositions.Invalidate();
|
yPositionsCached.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateLayout()
|
protected override void UpdateLayout()
|
||||||
{
|
{
|
||||||
base.UpdateLayout();
|
base.UpdateLayout();
|
||||||
|
|
||||||
if (!yPositions.EnsureValid())
|
if (!yPositionsCached.EnsureValid())
|
||||||
yPositions.Refresh(computeYPositions);
|
yPositionsCached.Refresh(computeYPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float offsetX(Vector2 pos, Panel panel, float dist, float halfHeight)
|
private static float offsetX(Panel panel, float dist, float halfHeight)
|
||||||
{
|
{
|
||||||
// The radius of the circle the carousel moves on.
|
// The radius of the circle the carousel moves on.
|
||||||
const float CIRCLE_RADIUS = 4;
|
const float CIRCLE_RADIUS = 4;
|
||||||
@ -137,44 +142,52 @@ namespace osu.Game.Screens.Select
|
|||||||
return 125 + x;
|
return 125 + x;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 getScrollPos(Panel panel)
|
private void addPanel(int index)
|
||||||
{
|
{
|
||||||
return panel.Position + panel.DrawSize;;
|
Panel panel = panels[index];
|
||||||
}
|
if (panel.Hidden)
|
||||||
|
return;
|
||||||
|
|
||||||
private Vector2 getDrawPos(Panel panel)
|
panel.Depth = index + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||||
{
|
|
||||||
return panel.ToSpaceOfOtherDrawable(panel.DrawSize / 2.0f, this);
|
if (!scrollableContent.Contains(panel))
|
||||||
|
scrollableContent.Add(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
scrollableContent.Clear(false);
|
float drawHeight = DrawHeight;
|
||||||
|
scrollableContent.RemoveAll(delegate (Panel p)
|
||||||
|
{
|
||||||
|
float panelPosY = p.Position.Y;
|
||||||
|
return panelPosY < Current - p.DrawHeight || panelPosY > Current + drawHeight || !IsVisible;
|
||||||
|
});
|
||||||
|
|
||||||
foreach (BeatmapGroup group in groups)
|
int firstIndex = yPositions.BinarySearch(Current - Panel.MAX_HEIGHT);
|
||||||
{
|
if (firstIndex < 0) firstIndex = ~firstIndex;
|
||||||
scrollableContent.Add(group.Header);
|
int lastIndex = yPositions.BinarySearch(Current + drawHeight);
|
||||||
|
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||||
|
|
||||||
if (group.State == BeatmapGroupState.Expanded)
|
for (int i = firstIndex; i < lastIndex; ++i)
|
||||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
addPanel(i);
|
||||||
scrollableContent.Add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
float halfHeight = drawHeight / 2;
|
||||||
foreach (Panel panel in scrollableContent.Children)
|
foreach (Panel panel in scrollableContent.Children)
|
||||||
{
|
{
|
||||||
if (panel.Position.Y < 0)
|
float panelDrawY = panel.Position.Y - Current;
|
||||||
continue;
|
float dist = Math.Abs(1f - panelDrawY / halfHeight);
|
||||||
|
|
||||||
Vector2 panelPosLocal = panel.Position;
|
// Setting the origin position serves as an additive position on top of potential
|
||||||
Vector2 panelPos = getDrawPos(panel);
|
// local transformation we may want to apply (e.g. when a panel gets selected, we
|
||||||
|
// may want to smoothly transform it leftwards.)
|
||||||
|
panel.OriginPosition = new Vector2(-offsetX(panel, dist, halfHeight), 0);
|
||||||
|
|
||||||
float halfHeight = DrawSize.Y / 2;
|
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||||
float dist = Math.Abs(1f - panelPos.Y / halfHeight);
|
// additional container and setting that container's alpha) such that we can
|
||||||
panel.OriginPosition = new Vector2(-offsetX(panelPos, panel, dist, halfHeight), 0);
|
// layer transformations on top, with a similar reasoning to the previous comment.
|
||||||
|
panel.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||||
panel.Alpha = MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -148,8 +148,6 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
playMode = osuGame.PlayMode;
|
playMode = osuGame.PlayMode;
|
||||||
playMode.ValueChanged += playMode_ValueChanged;
|
playMode.ValueChanged += playMode_ValueChanged;
|
||||||
// Temporary:
|
|
||||||
carousell.Padding = new MarginPadding { Top = ToolbarPadding };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database == null)
|
if (database == null)
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
<Compile Include="Screens\Multiplayer\Lobby.cs" />
|
<Compile Include="Screens\Multiplayer\Lobby.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\Match.cs" />
|
<Compile Include="Screens\Multiplayer\Match.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
||||||
<Compile Include="Screens\Select\CarousellContainer.cs" />
|
<Compile Include="Screens\Select\CarouselContainer.cs" />
|
||||||
<Compile Include="Screens\Select\MatchSongSelect.cs" />
|
<Compile Include="Screens\Select\MatchSongSelect.cs" />
|
||||||
<Compile Include="Screens\OsuGameMode.cs" />
|
<Compile Include="Screens\OsuGameMode.cs" />
|
||||||
<Compile Include="Screens\Play\ModSelect.cs" />
|
<Compile Include="Screens\Play\ModSelect.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user