mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 00:27:25 +08:00
Merge pull request #184 from Tom94/better-song-select
Better song select
This commit is contained in:
commit
f7766fa384
@ -1 +1 @@
|
|||||||
Subproject commit 1d43e1ed56421fbbefdf6c23dab8deeeaa0f592a
|
Subproject commit 7022964256829c7fab596ce34ad70d09f6433bcf
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -73,15 +79,11 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
{
|
{
|
||||||
GainedSelection = headerGainedSelection,
|
GainedSelection = headerGainedSelection,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
|
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
|
||||||
{
|
{
|
||||||
GainedSelection = panelGainedSelection,
|
GainedSelection = panelGainedSelection,
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
@ -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,30 @@ 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;
|
|
||||||
CornerRadius = 10;
|
|
||||||
BorderColour = new Color4(221, 255, 255, 255);
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
AddInternal(nestedContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
BorderColour = new Color4(221, 255, 255, 255),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetMultiplicativeAlpha(float alpha)
|
||||||
|
{
|
||||||
|
nestedContainer.Alpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -65,9 +75,8 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
|
|
||||||
protected virtual void Selected()
|
protected virtual void Selected()
|
||||||
{
|
{
|
||||||
BorderThickness = 2.5f;
|
nestedContainer.BorderThickness = 2.5f;
|
||||||
|
nestedContainer.EdgeEffect = new EdgeEffect
|
||||||
EdgeEffect = new EdgeEffect
|
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Glow,
|
Type = EdgeEffectType.Glow,
|
||||||
Colour = new Color4(130, 204, 255, 150),
|
Colour = new Color4(130, 204, 255, 150),
|
||||||
@ -78,9 +87,8 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
|
|
||||||
protected virtual void Deselected()
|
protected virtual void Deselected()
|
||||||
{
|
{
|
||||||
BorderThickness = 0;
|
nestedContainer.BorderThickness = 0;
|
||||||
|
nestedContainer.EdgeEffect = new EdgeEffect
|
||||||
EdgeEffect = new EdgeEffect
|
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
Offset = new Vector2(1),
|
Offset = new Vector2(1),
|
||||||
|
121
osu.Game/Screens/Select/BeatmapInfoOverlay.cs
Normal file
121
osu.Game/Screens/Select/BeatmapInfoOverlay.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Select
|
||||||
|
{
|
||||||
|
class BeatmapInfoOverlay : Container
|
||||||
|
{
|
||||||
|
private Container beatmapInfoContainer;
|
||||||
|
|
||||||
|
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||||
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (beatmapInfoContainer != null)
|
||||||
|
{
|
||||||
|
Drawable oldWedgedBeatmapInfo = beatmapInfoContainer;
|
||||||
|
oldWedgedBeatmapInfo.Depth = 1;
|
||||||
|
oldWedgedBeatmapInfo.FadeOut(250);
|
||||||
|
oldWedgedBeatmapInfo.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
FadeIn(250);
|
||||||
|
|
||||||
|
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
|
||||||
|
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||||
|
Add(beatmapInfoContainer = new BufferedContainer
|
||||||
|
{
|
||||||
|
PixelSnapping = true,
|
||||||
|
CacheDrawnFrameBuffer = true,
|
||||||
|
Shear = -Shear,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
// We will create the white-to-black gradient by modulating transparency and having
|
||||||
|
// a black backdrop. This results in an sRGB-space gradient and not linear space,
|
||||||
|
// transitioning from white to black more perceptually uniformly.
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
},
|
||||||
|
// We use a container, such that we can set the colour gradient to go across the
|
||||||
|
// vertices of the masked container instead of the vertices of the (larger) sprite.
|
||||||
|
beatmap.Background == null ? new Container() : new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)),
|
||||||
|
Children = new []
|
||||||
|
{
|
||||||
|
// Zoomed-in and cropped beatmap background
|
||||||
|
new Sprite
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Texture = beatmap.Background,
|
||||||
|
Scale = new Vector2(1366 / beatmap.Background.Width * 0.6f),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Text for beatmap info
|
||||||
|
new FlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Direction = FlowDirection.VerticalOnly,
|
||||||
|
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new SpriteText
|
||||||
|
{
|
||||||
|
Font = @"Exo2.0-MediumItalic",
|
||||||
|
Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title,
|
||||||
|
TextSize = 28,
|
||||||
|
Shadow = true,
|
||||||
|
},
|
||||||
|
new SpriteText
|
||||||
|
{
|
||||||
|
Font = @"Exo2.0-MediumItalic",
|
||||||
|
Text = beatmapInfo.Version,
|
||||||
|
TextSize = 17,
|
||||||
|
Shadow = true,
|
||||||
|
},
|
||||||
|
new FlowContainer
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Top = 10 },
|
||||||
|
Direction = FlowDirection.HorizontalOnly,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new []
|
||||||
|
{
|
||||||
|
new SpriteText
|
||||||
|
{
|
||||||
|
Font = @"Exo2.0-Medium",
|
||||||
|
Text = "mapped by ",
|
||||||
|
TextSize = 15,
|
||||||
|
Shadow = true,
|
||||||
|
},
|
||||||
|
new SpriteText
|
||||||
|
{
|
||||||
|
Font = @"Exo2.0-Bold",
|
||||||
|
Text = beatmapSetInfo.Metadata.Author,
|
||||||
|
TextSize = 15,
|
||||||
|
Shadow = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
194
osu.Game/Screens/Select/CarouselContainer.cs
Normal file
194
osu.Game/Screens/Select/CarouselContainer.cs
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Framework.Caching;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Game.Beatmaps.Drawable;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Select
|
||||||
|
{
|
||||||
|
class CarouselContainer : ScrollContainer
|
||||||
|
{
|
||||||
|
private Container<Panel> scrollableContent;
|
||||||
|
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||||
|
private List<Panel> panels = new List<Panel>();
|
||||||
|
|
||||||
|
public BeatmapGroup SelectedGroup { get; private set; }
|
||||||
|
public BeatmapPanel SelectedPanel { get; private set; }
|
||||||
|
|
||||||
|
private Cached yPositionsCached = new Cached();
|
||||||
|
private List<float> yPositions = new List<float>();
|
||||||
|
|
||||||
|
public CarouselContainer()
|
||||||
|
{
|
||||||
|
DistanceDecayJump = 0.01;
|
||||||
|
|
||||||
|
Add(scrollableContent = new Container<Panel>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddGroup(BeatmapGroup group)
|
||||||
|
{
|
||||||
|
group.State = BeatmapGroupState.Collapsed;
|
||||||
|
|
||||||
|
groups.Add(group);
|
||||||
|
panels.Add(group.Header);
|
||||||
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
|
panels.Add(panel);
|
||||||
|
|
||||||
|
yPositionsCached.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||||
|
{
|
||||||
|
yPositions.Add(currentY);
|
||||||
|
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||||
|
|
||||||
|
if (advance)
|
||||||
|
currentY += panel.DrawHeight + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeYPositions()
|
||||||
|
{
|
||||||
|
yPositions.Clear();
|
||||||
|
|
||||||
|
float currentY = DrawHeight / 2;
|
||||||
|
float selectedY = currentY;
|
||||||
|
|
||||||
|
foreach (BeatmapGroup group in groups)
|
||||||
|
{
|
||||||
|
movePanel(group.Header, true, ref currentY);
|
||||||
|
|
||||||
|
if (group.State == BeatmapGroupState.Expanded)
|
||||||
|
{
|
||||||
|
group.Header.MoveToX(-100, 500, EasingTypes.OutExpo);
|
||||||
|
|
||||||
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
|
{
|
||||||
|
if (panel == SelectedPanel)
|
||||||
|
selectedY = currentY + panel.DrawHeight / 2 - DrawHeight / 2;
|
||||||
|
|
||||||
|
movePanel(panel, true, ref currentY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
group.Header.MoveToX(0, 500, EasingTypes.OutExpo);
|
||||||
|
|
||||||
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
|
movePanel(panel, false, ref currentY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentY += DrawHeight / 2;
|
||||||
|
scrollableContent.Height = currentY;
|
||||||
|
|
||||||
|
ScrollTo(selectedY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||||
|
{
|
||||||
|
foreach (BeatmapGroup group in groups)
|
||||||
|
{
|
||||||
|
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||||
|
if (panel != null)
|
||||||
|
{
|
||||||
|
SelectGroup(group, panel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel)
|
||||||
|
{
|
||||||
|
if (SelectedGroup != null && SelectedGroup != group)
|
||||||
|
{
|
||||||
|
SelectedGroup.State = BeatmapGroupState.Collapsed;
|
||||||
|
foreach (BeatmapPanel p in group.BeatmapPanels)
|
||||||
|
p.MoveToY(group.Header.Position.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedGroup = group;
|
||||||
|
panel.State = PanelSelectedState.Selected;
|
||||||
|
SelectedPanel = panel;
|
||||||
|
|
||||||
|
yPositionsCached.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateLayout()
|
||||||
|
{
|
||||||
|
base.UpdateLayout();
|
||||||
|
|
||||||
|
if (!yPositionsCached.EnsureValid())
|
||||||
|
yPositionsCached.Refresh(computeYPositions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float offsetX(Panel panel, float dist, float halfHeight)
|
||||||
|
{
|
||||||
|
// The radius of the circle the carousel moves on.
|
||||||
|
const float CIRCLE_RADIUS = 4;
|
||||||
|
double discriminant = Math.Max(0, CIRCLE_RADIUS * CIRCLE_RADIUS - dist * dist);
|
||||||
|
float x = (CIRCLE_RADIUS - (float)Math.Sqrt(discriminant)) * halfHeight;
|
||||||
|
|
||||||
|
return 125 + x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPanel(int index)
|
||||||
|
{
|
||||||
|
Panel panel = panels[index];
|
||||||
|
if (panel.Hidden)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panel.Depth = index + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||||
|
|
||||||
|
if (!scrollableContent.Contains(panel))
|
||||||
|
scrollableContent.Add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
float drawHeight = DrawHeight;
|
||||||
|
scrollableContent.RemoveAll(delegate (Panel p)
|
||||||
|
{
|
||||||
|
float panelPosY = p.Position.Y;
|
||||||
|
return panelPosY < Current - p.DrawHeight || panelPosY > Current + drawHeight || !IsVisible;
|
||||||
|
});
|
||||||
|
|
||||||
|
int firstIndex = yPositions.BinarySearch(Current - Panel.MAX_HEIGHT);
|
||||||
|
if (firstIndex < 0) firstIndex = ~firstIndex;
|
||||||
|
int lastIndex = yPositions.BinarySearch(Current + drawHeight);
|
||||||
|
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||||
|
|
||||||
|
for (int i = firstIndex; i < lastIndex; ++i)
|
||||||
|
addPanel(i);
|
||||||
|
|
||||||
|
float halfHeight = drawHeight / 2;
|
||||||
|
foreach (Panel panel in scrollableContent.Children)
|
||||||
|
{
|
||||||
|
float panelDrawY = panel.Position.Y - Current + panel.DrawHeight / 2;
|
||||||
|
float dist = Math.Abs(1f - panelDrawY / 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 panel gets selected, we
|
||||||
|
// may want to smoothly transform it leftwards.)
|
||||||
|
panel.OriginPosition = new Vector2(-offsetX(panel, 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
|
||||||
|
// layer transformations on top, with a similar reasoning to the previous comment.
|
||||||
|
panel.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,124 +0,0 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Caching;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Primitives;
|
|
||||||
using osu.Game.Beatmaps.Drawable;
|
|
||||||
using osu.Game.Database;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
|
||||||
{
|
|
||||||
class CarousellContainer : ScrollContainer
|
|
||||||
{
|
|
||||||
private Container<Panel> scrollableContent;
|
|
||||||
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
|
||||||
public BeatmapGroup SelectedGroup { get; private set; }
|
|
||||||
|
|
||||||
private Cached yPositions = new Cached();
|
|
||||||
|
|
||||||
public CarousellContainer()
|
|
||||||
{
|
|
||||||
Add(scrollableContent = new Container<Panel>
|
|
||||||
{
|
|
||||||
Padding = new MarginPadding { Left = 25, Top = 25, Bottom = 25 },
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddGroup(BeatmapGroup group)
|
|
||||||
{
|
|
||||||
group.State = BeatmapGroupState.Collapsed;
|
|
||||||
|
|
||||||
groups.Add(group);
|
|
||||||
|
|
||||||
yPositions.Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void computeYPositions()
|
|
||||||
{
|
|
||||||
float currentY = 0;
|
|
||||||
foreach (BeatmapGroup group in groups)
|
|
||||||
{
|
|
||||||
group.Header.Position = new Vector2(group.Header.Position.X, currentY);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
|
||||||
{
|
|
||||||
foreach (BeatmapGroup group in groups)
|
|
||||||
{
|
|
||||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
|
||||||
if (panel != null)
|
|
||||||
SelectGroup(group, panel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel)
|
|
||||||
{
|
|
||||||
if (SelectedGroup != null && SelectedGroup != group)
|
|
||||||
SelectedGroup.State = BeatmapGroupState.Collapsed;
|
|
||||||
|
|
||||||
SelectedGroup = group;
|
|
||||||
panel.State = PanelSelectedState.Selected;
|
|
||||||
|
|
||||||
yPositions.Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateLayout()
|
|
||||||
{
|
|
||||||
base.UpdateLayout();
|
|
||||||
|
|
||||||
if (!yPositions.EnsureValid())
|
|
||||||
yPositions.Refresh(computeYPositions);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
scrollableContent.Clear(false);
|
|
||||||
|
|
||||||
foreach (BeatmapGroup group in groups)
|
|
||||||
{
|
|
||||||
scrollableContent.Add(group.Header);
|
|
||||||
|
|
||||||
if (group.State == BeatmapGroupState.Expanded)
|
|
||||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
|
||||||
scrollableContent.Add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Panel panel in scrollableContent.Children)
|
|
||||||
{
|
|
||||||
if (panel.Position.Y < 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Vector2 panelPosLocal = panel.Position;
|
|
||||||
Vector2 panelPos = panel.ToSpaceOfOtherDrawable(panel.DrawSize / 2.0f, this);
|
|
||||||
|
|
||||||
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.Alpha = MathHelper.Clamp(1.75f - 1.5f * dist / halfHeight, 0, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ using osu.Game.Modes;
|
|||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
|
||||||
@ -34,15 +33,14 @@ namespace osu.Game.Screens.Select
|
|||||||
private BeatmapDatabase database;
|
private BeatmapDatabase database;
|
||||||
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
|
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
|
||||||
|
|
||||||
private CarousellContainer carousell;
|
private CarouselContainer carousell;
|
||||||
private TrackManager trackManager;
|
private TrackManager trackManager;
|
||||||
private Container backgroundWedgesContainer;
|
private Container backgroundWedgesContainer;
|
||||||
|
|
||||||
private static readonly Vector2 wedged_container_size = new Vector2(700, 225);
|
private static readonly Vector2 wedged_container_size = new Vector2(700, 225);
|
||||||
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
||||||
private static readonly Vector2 wedged_container_start_position = new Vector2(0, 50);
|
private static readonly Vector2 wedged_container_start_position = new Vector2(0, 50);
|
||||||
private Container wedgedContainer;
|
private BeatmapInfoOverlay wedgedBeatmapInfoOverlay;
|
||||||
private Container wedgedBeatmapInfo;
|
|
||||||
|
|
||||||
private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
||||||
private CancellationTokenSource initialAddSetsTask;
|
private CancellationTokenSource initialAddSetsTask;
|
||||||
@ -83,18 +81,19 @@ namespace osu.Game.Screens.Select
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carousell = new CarousellContainer
|
carousell = new CarouselContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Size = new Vector2(scrollWidth, 1),
|
Size = new Vector2(scrollWidth, 1),
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
},
|
},
|
||||||
wedgedContainer = new Container
|
wedgedBeatmapInfoOverlay = new BeatmapInfoOverlay
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Position = wedged_container_start_position,
|
Position = wedged_container_start_position,
|
||||||
Size = wedged_container_size,
|
Size = wedged_container_size,
|
||||||
|
Shear = wedged_container_shear,
|
||||||
Margin = new MarginPadding { Top = 20, Right = 20, },
|
Margin = new MarginPadding { Top = 20, Right = 20, },
|
||||||
Masking = true,
|
Masking = true,
|
||||||
BorderColour = new Color4(221, 255, 255, 255),
|
BorderColour = new Color4(221, 255, 255, 255),
|
||||||
@ -106,10 +105,6 @@ namespace osu.Game.Screens.Select
|
|||||||
Radius = 20,
|
Radius = 20,
|
||||||
Roundness = 15,
|
Roundness = 15,
|
||||||
},
|
},
|
||||||
Shear = wedged_container_shear,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -151,8 +146,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)
|
||||||
@ -231,112 +224,7 @@ namespace osu.Game.Screens.Select
|
|||||||
(Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000);
|
(Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: move to own class and fix async logic (move every call on WorkingBeatmap.* to load() and use Preload to create it.
|
wedgedBeatmapInfoOverlay.UpdateBeatmap(beatmap);
|
||||||
refreshWedgedBeatmapInfo(beatmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshWedgedBeatmapInfo(WorkingBeatmap beatmap)
|
|
||||||
{
|
|
||||||
if (beatmap == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (wedgedBeatmapInfo != null)
|
|
||||||
{
|
|
||||||
Drawable oldWedgedBeatmapInfo = wedgedBeatmapInfo;
|
|
||||||
oldWedgedBeatmapInfo.Depth = 1;
|
|
||||||
oldWedgedBeatmapInfo.FadeOut(250);
|
|
||||||
oldWedgedBeatmapInfo.Expire();
|
|
||||||
}
|
|
||||||
|
|
||||||
wedgedContainer.FadeIn(250);
|
|
||||||
|
|
||||||
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
|
|
||||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
|
||||||
wedgedContainer.Add(wedgedBeatmapInfo = new BufferedContainer
|
|
||||||
{
|
|
||||||
PixelSnapping = true,
|
|
||||||
CacheDrawnFrameBuffer = true,
|
|
||||||
Shear = -wedged_container_shear,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
// We will create the white-to-black gradient by modulating transparency and having
|
|
||||||
// a black backdrop. This results in an sRGB-space gradient and not linear space,
|
|
||||||
// transitioning from white to black more perceptually uniformly.
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
},
|
|
||||||
// We use a container, such that we can set the colour gradient to go across the
|
|
||||||
// vertices of the masked container instead of the vertices of the (larger) sprite.
|
|
||||||
beatmap.Background == null ? new Container() : new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)),
|
|
||||||
Children = new []
|
|
||||||
{
|
|
||||||
// Zoomed-in and cropped beatmap background
|
|
||||||
new Sprite
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Texture = beatmap.Background,
|
|
||||||
Scale = new Vector2(1366 / beatmap.Background.Width * 0.6f),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Text for beatmap info
|
|
||||||
new FlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Direction = FlowDirection.VerticalOnly,
|
|
||||||
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Font = @"Exo2.0-MediumItalic",
|
|
||||||
Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title,
|
|
||||||
TextSize = 28,
|
|
||||||
Shadow = true,
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Font = @"Exo2.0-MediumItalic",
|
|
||||||
Text = beatmapInfo.Version,
|
|
||||||
TextSize = 17,
|
|
||||||
Shadow = true,
|
|
||||||
},
|
|
||||||
new FlowContainer
|
|
||||||
{
|
|
||||||
Margin = new MarginPadding { Top = 10 },
|
|
||||||
Direction = FlowDirection.HorizontalOnly,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Children = new []
|
|
||||||
{
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Font = @"Exo2.0-Medium",
|
|
||||||
Text = "mapped by ",
|
|
||||||
TextSize = 15,
|
|
||||||
Shadow = true,
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Font = @"Exo2.0-Bold",
|
|
||||||
Text = beatmapSetInfo.Metadata.Author,
|
|
||||||
TextSize = 15,
|
|
||||||
Shadow = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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" />
|
||||||
@ -159,6 +159,7 @@
|
|||||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||||
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Screens\Select\BeatmapInfoOverlay.cs" />
|
||||||
<Compile Include="Users\User.cs" />
|
<Compile Include="Users\User.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
|
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
|
||||||
<Compile Include="Database\BeatmapDatabase.cs" />
|
<Compile Include="Database\BeatmapDatabase.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user