2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-19 17:00:35 +08:00
|
|
|
|
|
2016-10-26 16:26:26 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-09 14:52:40 +08:00
|
|
|
|
using System.Linq;
|
2016-11-28 10:38:32 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-02-17 17:59:30 +08:00
|
|
|
|
using osu.Framework.Screens.Testing;
|
2016-10-19 17:00:35 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-11-02 17:08:08 +08:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2016-10-26 16:26:26 +08:00
|
|
|
|
using OpenTK;
|
2016-11-17 20:29:35 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-02-24 12:43:21 +08:00
|
|
|
|
using osu.Game.Beatmaps.IO;
|
2016-11-28 10:38:32 +08:00
|
|
|
|
using osu.Game.Database;
|
|
|
|
|
using osu.Game.Modes;
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2016-11-14 17:54:24 +08:00
|
|
|
|
using osu.Game.Modes.Osu.Objects;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2016-11-17 20:29:35 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2016-10-19 17:00:35 +08:00
|
|
|
|
|
2016-10-26 16:26:26 +08:00
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
2016-10-19 17:00:35 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
internal class TestCasePlayer : TestCase
|
2016-10-19 17:00:35 +08:00
|
|
|
|
{
|
2017-03-02 15:08:37 +08:00
|
|
|
|
protected Player Player;
|
|
|
|
|
private BeatmapDatabase db;
|
|
|
|
|
|
2016-10-19 17:00:35 +08:00
|
|
|
|
|
|
|
|
|
public override string Description => @"Showing everything to play the game.";
|
|
|
|
|
|
2016-11-28 10:38:32 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(BeatmapDatabase db)
|
|
|
|
|
{
|
2017-03-02 15:08:37 +08:00
|
|
|
|
this.db = db;
|
2016-11-28 10:38:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 17:00:35 +08:00
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
|
2017-03-02 15:08:37 +08:00
|
|
|
|
WorkingBeatmap beatmap = null;
|
|
|
|
|
|
2017-03-09 14:52:40 +08:00
|
|
|
|
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Mode == PlayMode.Osu);
|
2017-03-02 15:08:37 +08:00
|
|
|
|
if (beatmapInfo != null)
|
|
|
|
|
beatmap = db.GetWorkingBeatmap(beatmapInfo);
|
|
|
|
|
|
2017-02-23 15:44:59 +08:00
|
|
|
|
if (beatmap?.Track == null)
|
2016-10-19 17:00:35 +08:00
|
|
|
|
{
|
2016-11-28 10:38:32 +08:00
|
|
|
|
var objects = new List<HitObject>();
|
|
|
|
|
|
|
|
|
|
int time = 1500;
|
|
|
|
|
for (int i = 0; i < 50; i++)
|
2016-10-19 17:00:35 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
objects.Add(new HitCircle
|
2016-11-28 10:38:32 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = time,
|
|
|
|
|
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
|
|
|
|
|
i % 4 < 2 ? 0 : 384),
|
|
|
|
|
NewCombo = i % 4 == 0
|
|
|
|
|
});
|
2016-10-19 17:00:35 +08:00
|
|
|
|
|
2016-11-28 10:38:32 +08:00
|
|
|
|
time += 500;
|
|
|
|
|
}
|
2016-10-19 17:00:35 +08:00
|
|
|
|
|
2016-11-28 10:38:32 +08:00
|
|
|
|
var decoder = new ConstructableBeatmapDecoder();
|
2016-11-02 17:08:08 +08:00
|
|
|
|
|
2016-11-28 10:38:32 +08:00
|
|
|
|
Beatmap b = new Beatmap
|
|
|
|
|
{
|
2017-02-22 22:27:29 +08:00
|
|
|
|
HitObjects = objects,
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Artist = @"Unknown",
|
|
|
|
|
Title = @"Sample Beatmap",
|
|
|
|
|
Author = @"peppy",
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-28 10:38:32 +08:00
|
|
|
|
};
|
2016-11-02 17:08:08 +08:00
|
|
|
|
|
2016-11-28 10:38:32 +08:00
|
|
|
|
decoder.Process(b);
|
|
|
|
|
|
2017-02-24 12:43:21 +08:00
|
|
|
|
beatmap = new TestWorkingBeatmap(b);
|
2016-11-28 10:38:32 +08:00
|
|
|
|
}
|
2016-11-02 17:08:08 +08:00
|
|
|
|
|
2016-11-17 20:29:35 +08:00
|
|
|
|
Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
2017-02-18 14:54:26 +08:00
|
|
|
|
Colour = Color4.Black,
|
2016-11-17 20:29:35 +08:00
|
|
|
|
});
|
|
|
|
|
|
2017-03-02 15:08:37 +08:00
|
|
|
|
Add(new PlayerLoader(Player = CreatePlayer(beatmap))
|
2016-11-09 07:13:20 +08:00
|
|
|
|
{
|
2016-11-28 10:38:32 +08:00
|
|
|
|
Beatmap = beatmap
|
2017-03-02 15:08:37 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual Player CreatePlayer(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
return new Player
|
2017-02-22 20:43:29 +08:00
|
|
|
|
{
|
|
|
|
|
Beatmap = beatmap
|
2017-03-02 15:08:37 +08:00
|
|
|
|
};
|
2016-10-19 17:00:35 +08:00
|
|
|
|
}
|
2017-02-24 12:43:21 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private class TestWorkingBeatmap : WorkingBeatmap
|
2017-02-24 12:43:21 +08:00
|
|
|
|
{
|
|
|
|
|
public TestWorkingBeatmap(Beatmap beatmap)
|
|
|
|
|
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)
|
|
|
|
|
{
|
|
|
|
|
Beatmap = beatmap;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 10:46:34 +08:00
|
|
|
|
protected override ArchiveReader GetReader() => null;
|
2017-02-24 12:43:21 +08:00
|
|
|
|
}
|
2016-10-19 17:00:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|