diff --git a/osu.Game/GameModes/Play/BeatmapButton.cs b/osu.Game/GameModes/Play/BeatmapButton.cs index 8a1451e853..8025f1bc16 100644 --- a/osu.Game/GameModes/Play/BeatmapButton.cs +++ b/osu.Game/GameModes/Play/BeatmapButton.cs @@ -29,10 +29,5 @@ namespace osu.Game.GameModes.Play new SpriteText { Text = beatmap.Version }, }; } - - public override void Load(BaseGame game) - { - base.Load(game); - } } } diff --git a/osu.Game/GameModes/Play/BeatmapGroup.cs b/osu.Game/GameModes/Play/BeatmapGroup.cs index 3fc29d9528..5a889d82fa 100644 --- a/osu.Game/GameModes/Play/BeatmapGroup.cs +++ b/osu.Game/GameModes/Play/BeatmapGroup.cs @@ -15,48 +15,66 @@ using osu.Framework.Graphics.Primitives; using OpenTK; using System.Linq; using osu.Framework.Graphics.Drawables; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Input; +using OpenTK.Graphics; namespace osu.Game.GameModes.Play { class BeatmapGroup : FlowContainer { - private BeatmapSet beatmapSet; + public event Action SetSelected; + public event Action BeatmapSelected; + public BeatmapSet BeatmapSet; + private FlowContainer difficulties; private bool collapsed; public bool Collapsed { get { return collapsed; } set { + if (collapsed == value) + return; collapsed = value; + this.ClearTransformations(); + const float collapsedAlpha = 0.75f; + const float uncollapsedAlpha = 1; + Transforms.Add(new TransformAlpha(Clock) + { + StartValue = collapsed ? uncollapsedAlpha : collapsedAlpha, + EndValue = collapsed ? collapsedAlpha : uncollapsedAlpha, + StartTime = Time, + EndTime = Time + 250, + }); if (collapsed) - Alpha = 0.75f; + Remove(difficulties); else - Alpha = 1; - // TODO: whatever + Add(difficulties); } } public BeatmapGroup(BeatmapSet beatmapSet) { - this.beatmapSet = beatmapSet; - this.collapsed = true; + BeatmapSet = beatmapSet; Direction = FlowDirection.VerticalOnly; - Children = new[] + Children = new Drawable[] { - new SpriteText() { Text = this.beatmapSet.Metadata.Title, TextSize = 25 }, - new FlowContainer - { - Spacing = new Vector2(0, 10), - Padding = new MarginPadding { Left = 50 }, - Direction = FlowDirection.VerticalOnly, - Children = this.beatmapSet.Beatmaps.Select(b => new BeatmapButton(this.beatmapSet, b)) - }, + new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 }, }; + difficulties = new FlowContainer // Deliberately not added to children + { + Spacing = new Vector2(0, 10), + Padding = new MarginPadding { Left = 50 }, + Direction = FlowDirection.VerticalOnly, + Children = this.BeatmapSet.Beatmaps.Select(b => new BeatmapButton(this.BeatmapSet, b)) + }; + collapsed = true; } - - public override void Load(BaseGame game) + + protected override bool OnClick(InputState state) { - base.Load(game); + SetSelected?.Invoke(BeatmapSet); + return true; } } } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index d0fa70643f..f86d1b5efd 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -12,6 +12,7 @@ using osu.Game.GameModes.Backgrounds; using osu.Framework; using osu.Game.Database; using osu.Framework.Graphics.Primitives; +using System.Linq; namespace osu.Game.GameModes.Play { @@ -25,12 +26,26 @@ namespace osu.Game.GameModes.Play private ScrollContainer scrollContainer; private FlowContainer setList; + + private void addBeatmapSet(BeatmapSet beatmapSet) + { + var group = new BeatmapGroup(beatmapSet); + group.SetSelected += (selectedSet) => + { + foreach (var child in setList.Children) + { + var childGroup = child as BeatmapGroup; + childGroup.Collapsed = childGroup.BeatmapSet != selectedSet; + } + }; + setList.Add(group); + } private void addBeatmapSets() { var sets = beatmaps.GetBeatmapSets(); foreach (var beatmapSet in sets) - setList.Add(new BeatmapGroup(beatmapSet)); + addBeatmapSet(beatmapSet); } public PlaySongSelect() @@ -65,8 +80,9 @@ namespace osu.Game.GameModes.Play } beatmaps = (game as OsuGameBase).Beatmaps; - beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => setList.Add(new BeatmapGroup(bset))); + beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset)); addBeatmapSets(); + (setList.Children.First() as BeatmapGroup).Collapsed = false; } protected override void Dispose(bool isDisposing)