1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:23:21 +08:00

Add test case for song selection

This commit is contained in:
Drew DeVault 2016-10-13 15:10:00 -04:00
parent d21b7f0050
commit bc6e705e2b
8 changed files with 148 additions and 17 deletions

View File

@ -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();
}

View File

@ -0,0 +1,31 @@
//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.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());
}
}
}

View File

@ -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

View File

@ -146,6 +146,7 @@
<Compile Include="Tests\TestCaseMenuButtonSystem.cs" />
<Compile Include="Tests\TestCaseScoreCounter.cs" />
<Compile Include="Tests\TestCaseTextAwesome.cs" />
<Compile Include="Tests\TestCasePlaySongSelect.cs" />
<Compile Include="VisualTestGame.cs" />
</ItemGroup>
<ItemGroup />

View File

@ -0,0 +1,38 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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);
}
}
}

View File

@ -0,0 +1,62 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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);
}
}
}

View File

@ -15,7 +15,7 @@ using osu.Framework.Graphics.Primitives;
namespace osu.Game.GameModes.Play
{
class PlaySongSelect : OsuGameMode
public class PlaySongSelect : OsuGameMode
{
private Bindable<PlayMode> 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)

View File

@ -116,6 +116,8 @@
<Compile Include="GameModes\OsuGameMode.cs" />
<Compile Include="GameModes\Play\ModSelect.cs" />
<Compile Include="GameModes\Play\Osu\ScoreOverlayOsu.cs" />
<Compile Include="GameModes\Play\BeatmapGroup.cs" />
<Compile Include="GameModes\Play\BeatmapButton.cs" />
<Compile Include="GameModes\Play\Player.cs" />
<Compile Include="GameModes\Charts\ChartListing.cs" />
<Compile Include="GameModes\Play\PlayMode.cs" />
@ -215,4 +217,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>