From bc6e705e2b84a5a67fb6ebd3bdd3ae94eb110a7c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 13 Oct 2016 15:10:00 -0400 Subject: [PATCH] Add test case for song selection --- osu.Desktop.VisualTests/Program.cs | 2 +- .../Tests/TestCasePlaySongSelect.cs | 31 ++++++++++ osu.Desktop.VisualTests/VisualTestGame.cs | 1 + .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/GameModes/Play/BeatmapButton.cs | 38 ++++++++++++ osu.Game/GameModes/Play/BeatmapGroup.cs | 62 +++++++++++++++++++ osu.Game/GameModes/Play/PlaySongSelect.cs | 26 ++++---- osu.Game/osu.Game.csproj | 4 +- 8 files changed, 148 insertions(+), 17 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs create mode 100644 osu.Game/GameModes/Play/BeatmapButton.cs create mode 100644 osu.Game/GameModes/Play/BeatmapGroup.cs diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 4dcfaff987..52aceb1ee8 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -12,7 +12,7 @@ namespace osu.Framework.VisualTests [STAThread] public static void Main(string[] args) { - BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests"); + BasicGameHost host = Host.GetSuitableHost(@"osu"); host.Add(new VisualTestGame()); host.Run(); } diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs new file mode 100644 index 0000000000..7dcc7026b1 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -0,0 +1,31 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Threading; +using osu.Game; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using osu.Framework.Graphics.Sprites; +using osu.Game.Online.Chat.Display; +using osu.Framework; +using osu.Game.GameModes.Play; + +namespace osu.Desktop.Tests +{ + class TestCasePlaySongSelect : TestCase + { + public override string Name => @"Song Select"; + public override string Description => @"Testing song selection UI"; + + public override void Reset() + { + base.Reset(); + Add(new PlaySongSelect()); + } + } +} diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 323923591d..5a51f28d82 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -3,6 +3,7 @@ using osu.Framework.GameModes.Testing; using osu.Framework.Graphics.Cursor; +using osu.Game.Database; using osu.Game; namespace osu.Framework.VisualTests diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 55de7cf39b..3dfe829651 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -146,6 +146,7 @@ + diff --git a/osu.Game/GameModes/Play/BeatmapButton.cs b/osu.Game/GameModes/Play/BeatmapButton.cs new file mode 100644 index 0000000000..8a1451e853 --- /dev/null +++ b/osu.Game/GameModes/Play/BeatmapButton.cs @@ -0,0 +1,38 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; +using osu.Game.GameModes.Backgrounds; +using osu.Framework; +using osu.Game.Database; +using osu.Framework.Graphics.Primitives; + +namespace osu.Game.GameModes.Play +{ + class BeatmapButton : FlowContainer + { + private BeatmapSet beatmapSet; + private Beatmap beatmap; + + public BeatmapButton(BeatmapSet set, Beatmap beatmap) + { + this.beatmapSet = set; + this.beatmap = beatmap; + Children = new[] + { + 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 new file mode 100644 index 0000000000..3fc29d9528 --- /dev/null +++ b/osu.Game/GameModes/Play/BeatmapGroup.cs @@ -0,0 +1,62 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; +using osu.Game.GameModes.Backgrounds; +using osu.Framework; +using osu.Game.Database; +using osu.Framework.Graphics.Primitives; +using OpenTK; +using System.Linq; +using osu.Framework.Graphics.Drawables; + +namespace osu.Game.GameModes.Play +{ + class BeatmapGroup : FlowContainer + { + private BeatmapSet beatmapSet; + private bool collapsed; + public bool Collapsed + { + get { return collapsed; } + set + { + collapsed = value; + if (collapsed) + Alpha = 0.75f; + else + Alpha = 1; + // TODO: whatever + } + } + + public BeatmapGroup(BeatmapSet beatmapSet) + { + this.beatmapSet = beatmapSet; + this.collapsed = true; + Direction = FlowDirection.VerticalOnly; + Children = new[] + { + 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)) + }, + }; + } + + public override void Load(BaseGame game) + { + base.Load(game); + } + } +} diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index edf144db6f..d0fa70643f 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -15,7 +15,7 @@ using osu.Framework.Graphics.Primitives; namespace osu.Game.GameModes.Play { - class PlaySongSelect : OsuGameMode + public class PlaySongSelect : OsuGameMode { private Bindable playMode; private BeatmapDatabase beatmaps; @@ -26,16 +26,11 @@ namespace osu.Game.GameModes.Play private ScrollContainer scrollContainer; private FlowContainer setList; - private Drawable createSetUI(BeatmapSet bset) - { - return new SpriteText { Text = bset.Metadata.Title }; - } - private void addBeatmapSets() { var sets = beatmaps.GetBeatmapSets(); foreach (var beatmapSet in sets) - setList.Add(createSetUI(beatmapSet)); + setList.Add(new BeatmapGroup(beatmapSet)); } public PlaySongSelect() @@ -61,16 +56,17 @@ namespace osu.Game.GameModes.Play base.Load(game); OsuGame osu = game as OsuGame; - - playMode = osu.PlayMode; - playMode.ValueChanged += PlayMode_ValueChanged; - beatmaps = osu.Beatmaps; + if (osu != null) + { + playMode = osu.PlayMode; + playMode.ValueChanged += PlayMode_ValueChanged; + // Temporary: + scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height }; + } - scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height }; - + beatmaps = (game as OsuGameBase).Beatmaps; + beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => setList.Add(new BeatmapGroup(bset))); addBeatmapSets(); - - beatmaps.BeatmapSetAdded += bset => setList.Add(createSetUI(bset)); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 545d777098..10e384ec01 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -116,6 +116,8 @@ + + @@ -215,4 +217,4 @@ --> - \ No newline at end of file +