mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:02:54 +08:00
Add background to song select
This commit is contained in:
parent
71f58285fc
commit
3d53af155f
@ -21,11 +21,14 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
class BeatmapGroup : FlowContainer
|
||||
class BeatmapGroup : AutoSizeContainer
|
||||
{
|
||||
private const float collapsedAlpha = 0.75f;
|
||||
|
||||
public event Action<BeatmapSet> SetSelected;
|
||||
public event Action<BeatmapSet, Beatmap> BeatmapSelected;
|
||||
public BeatmapSet BeatmapSet;
|
||||
private FlowContainer topContainer;
|
||||
private FlowContainer difficulties;
|
||||
private bool collapsed;
|
||||
public bool Collapsed
|
||||
@ -37,7 +40,6 @@ namespace osu.Game.GameModes.Play
|
||||
return;
|
||||
collapsed = value;
|
||||
this.ClearTransformations();
|
||||
const float collapsedAlpha = 0.75f;
|
||||
const float uncollapsedAlpha = 1;
|
||||
Transforms.Add(new TransformAlpha(Clock)
|
||||
{
|
||||
@ -47,19 +49,29 @@ namespace osu.Game.GameModes.Play
|
||||
EndTime = Time + 250,
|
||||
});
|
||||
if (collapsed)
|
||||
Remove(difficulties);
|
||||
topContainer.Remove(difficulties);
|
||||
else
|
||||
Add(difficulties);
|
||||
topContainer.Add(difficulties);
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(BeatmapSet beatmapSet)
|
||||
{
|
||||
BeatmapSet = beatmapSet;
|
||||
Direction = FlowDirection.VerticalOnly;
|
||||
Alpha = collapsedAlpha;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 },
|
||||
new Box
|
||||
{
|
||||
Colour = new Color4(0, 0, 0, 0.75f),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(1),
|
||||
},
|
||||
topContainer = new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = new[] { new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 } }
|
||||
}
|
||||
};
|
||||
difficulties = new FlowContainer // Deliberately not added to children
|
||||
{
|
||||
|
@ -12,7 +12,10 @@ using osu.Game.GameModes.Backgrounds;
|
||||
using osu.Framework;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
@ -50,10 +53,30 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
public PlaySongSelect()
|
||||
{
|
||||
Children = new[]
|
||||
const float backgroundWidth = 0.6f;
|
||||
const float backgroundSlant = 25;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BackgroundBox(backgroundSlant)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(backgroundWidth, 0.5f),
|
||||
Colour = new Color4(0, 0, 0, 0.5f),
|
||||
},
|
||||
new BackgroundBox(-backgroundSlant)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Size = new Vector2(backgroundWidth, 0.5f),
|
||||
Position = new Vector2(0, 0.5f),
|
||||
Colour = new Color4(0, 0, 0, 0.5f),
|
||||
},
|
||||
scrollContainer = new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Size = new Vector2(0.5f, 1),
|
||||
Position = new Vector2(0.5f, 0),
|
||||
Children = new[]
|
||||
{
|
||||
setList = new FlowContainer
|
||||
@ -95,5 +118,27 @@ namespace osu.Game.GameModes.Play
|
||||
private void PlayMode_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
class BackgroundBox : Box
|
||||
{
|
||||
private float wedgeWidth;
|
||||
|
||||
public BackgroundBox(float wedgeWidth)
|
||||
{
|
||||
this.wedgeWidth = wedgeWidth;
|
||||
}
|
||||
|
||||
protected override Quad DrawQuad
|
||||
{
|
||||
get
|
||||
{
|
||||
Quad q = base.DrawQuad;
|
||||
q.TopRight.X += wedgeWidth;
|
||||
q.BottomRight.X -= wedgeWidth;
|
||||
return q;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user