mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Use memory database again, local to TestCasePlaySongSelect.
This commit is contained in:
parent
33ef55df88
commit
a764a97602
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.GameModes.Testing;
|
||||
using System.Collections.Generic;
|
||||
using osu.Desktop.Platform;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.GameModes.Play;
|
||||
using SQLiteNetExtensions.Extensions;
|
||||
@ -14,22 +15,18 @@ namespace osu.Desktop.Tests
|
||||
class TestCasePlaySongSelect : TestCase
|
||||
{
|
||||
private BeatmapDatabase db;
|
||||
private TestStorage storage;
|
||||
|
||||
public override string Name => @"Song Select";
|
||||
public override string Description => @"Testing song selection UI";
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
db = (game as OsuGameBase).Beatmaps;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
db.Reset();
|
||||
|
||||
storage = new TestStorage(@"TestCasePlaySongSelect");
|
||||
db = new BeatmapDatabase(storage);
|
||||
|
||||
var sets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 0; i < 100; i += 10)
|
||||
@ -37,7 +34,7 @@ namespace osu.Desktop.Tests
|
||||
|
||||
db.Import(sets);
|
||||
|
||||
Add(new PlaySongSelect());
|
||||
Add(new PlaySongSelect(db));
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createTestBeatmapSet(int i)
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.GameModes.Play
|
||||
public class PlaySongSelect : OsuGameMode
|
||||
{
|
||||
private Bindable<PlayMode> playMode;
|
||||
private BeatmapDatabase beatmaps;
|
||||
private BeatmapDatabase database;
|
||||
private BeatmapGroup selectedBeatmapGroup;
|
||||
private BeatmapInfo selectedBeatmap;
|
||||
// TODO: use currently selected track as bg
|
||||
@ -32,8 +32,10 @@ namespace osu.Game.GameModes.Play
|
||||
private ScrollContainer scrollContainer;
|
||||
private FlowContainer setList;
|
||||
|
||||
public PlaySongSelect()
|
||||
public PlaySongSelect(BeatmapDatabase database = null)
|
||||
{
|
||||
this.database = database;
|
||||
|
||||
const float scrollWidth = 640;
|
||||
const float bottomToolHeight = 50;
|
||||
Children = new Drawable[]
|
||||
@ -103,7 +105,7 @@ namespace osu.Game.GameModes.Play
|
||||
Width = 100,
|
||||
Text = "Play",
|
||||
Colour = new Color4(238, 51, 153, 255),
|
||||
Action = () => Push(new Player { Beatmap = beatmaps.GetBeatmap(selectedBeatmap) }),
|
||||
Action = () => Push(new Player { Beatmap = this.database.GetBeatmap(selectedBeatmap) }),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -123,8 +125,11 @@ namespace osu.Game.GameModes.Play
|
||||
scrollContainer.Padding = new MarginPadding { Top = osuGame.Toolbar.Height };
|
||||
}
|
||||
|
||||
beatmaps = (game as OsuGameBase).Beatmaps;
|
||||
beatmaps.BeatmapSetAdded += s => Scheduler.Add(() => addBeatmapSet(s));
|
||||
if (database == null)
|
||||
database = (game as OsuGameBase).Beatmaps;
|
||||
|
||||
database.BeatmapSetAdded += s => Scheduler.Add(() => addBeatmapSet(s));
|
||||
|
||||
Task.Factory.StartNew(addBeatmapSets);
|
||||
}
|
||||
|
||||
@ -153,8 +158,8 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
beatmapSet = beatmaps.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
||||
beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b));
|
||||
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
||||
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
|
||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();
|
||||
Schedule(() =>
|
||||
{
|
||||
@ -169,7 +174,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
private void addBeatmapSets()
|
||||
{
|
||||
foreach (var beatmapSet in beatmaps.Query<BeatmapSetInfo>())
|
||||
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
|
||||
addBeatmapSet(beatmapSet);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user